| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.rice.krms.api.repository |
| 17 |
|
|
| 18 |
|
import javax.xml.bind.JAXBContext |
| 19 |
|
import javax.xml.bind.Marshaller |
| 20 |
|
import javax.xml.bind.Unmarshaller |
| 21 |
|
import org.junit.Test |
| 22 |
|
import org.junit.Assert |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
@author |
| 30 |
|
|
| 31 |
|
|
|
|
|
| 0% |
Uncovered Elements: 63 (63) |
Complexity: 28 |
Complexity Density: 0.8 |
|
| 32 |
|
class PropositionParameterTest { |
| 33 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 34 |
0
|
private static final String ID = "1001"... |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 35 |
0
|
private static final String PROP_ID = "202"... |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 36 |
0
|
private static final String VALUE = "campusCode"... |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 37 |
0
|
private static final String PARAMETER_TYPE_C = "C" ... |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 38 |
0
|
private static final String PARAMETER_TYPE_T = "T" ... |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 39 |
0
|
private static final String PARAMETER_TYPE_F = "F" ... |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 40 |
0
|
private static final String PARAMETER_TYPE_BAD = "X" ... |
| 41 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 42 |
0
|
private static final Integer SEQUENCE_NUMBER_1 = new Integer(1)... |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 43 |
0
|
private static final String EXPECTED_XML = """... |
| 44 |
|
<PropositionParameter xmlns="http://rice.kuali.org/krms"> |
| 45 |
|
<id>1001</id> |
| 46 |
|
<propId>202</propId> |
| 47 |
|
<value>campusCode</value> |
| 48 |
|
<parameterType>C</parameterType> |
| 49 |
|
<sequenceNumber>1</sequenceNumber> |
| 50 |
|
</PropositionParameter> |
| 51 |
|
""" |
| 52 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 53 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 54 |
|
void test_Builder_create_fail_all_null() { |
| 55 |
0
|
PropositionParameter.Builder.create(null, null, null, null, null) |
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 58 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 59 |
|
void test_Builder_create_fail_null_id() { |
| 60 |
0
|
PropositionParameter.Builder.create(null, PROP_ID, VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 61 |
|
} |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 63 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 64 |
|
void test_Builder_create_fail_empty_id() { |
| 65 |
0
|
PropositionParameter.Builder.create("", PROP_ID, VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 66 |
|
} |
| 67 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 68 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 69 |
|
void test_Builder_create_fail_whitespace_id() { |
| 70 |
0
|
PropositionParameter.Builder.create(" ", PROP_ID, VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 71 |
|
} |
| 72 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 73 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 74 |
|
void test_Builder_create_fail_null_prop_id() { |
| 75 |
0
|
PropositionParameter.Builder.create(ID, null, VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 76 |
|
} |
| 77 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 78 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 79 |
|
void test_Builder_create_fail_empty_prop_id() { |
| 80 |
0
|
PropositionParameter.Builder.create(ID, "", VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 81 |
|
} |
| 82 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 83 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 84 |
|
void test_Builder_create_fail_whitespace_prop_id() { |
| 85 |
0
|
PropositionParameter.Builder.create(ID, " ", VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 86 |
|
} |
| 87 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 88 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 89 |
|
void test_Builder_create_fail_null_value() { |
| 90 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, null, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 91 |
|
} |
| 92 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 93 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 94 |
|
void test_Builder_create_fail_empty_value() { |
| 95 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, "", PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 96 |
|
} |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 98 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 99 |
|
void test_Builder_create_fail_whitespace_value() { |
| 100 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, " ", PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 101 |
|
} |
| 102 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 103 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 104 |
|
void test_Builder_create_fail_null_parameter_type() { |
| 105 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, VALUE, null, SEQUENCE_NUMBER_1) |
| 106 |
|
} |
| 107 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 108 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 109 |
|
void test_Builder_create_fail_empty_parameter_type() { |
| 110 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, VALUE, "", SEQUENCE_NUMBER_1) |
| 111 |
|
} |
| 112 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 113 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 114 |
|
void test_Builder_create_fail_whitespace_parameter_type() { |
| 115 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, VALUE, " ", SEQUENCE_NUMBER_1) |
| 116 |
|
} |
| 117 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 118 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 119 |
|
void test_Builder_create_fail_invalid_parameter_type() { |
| 120 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, VALUE, PARAMETER_TYPE_BAD, SEQUENCE_NUMBER_1) |
| 121 |
|
} |
| 122 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 123 |
0
|
@Test(expected=IllegalArgumentException.class)... |
| 124 |
|
void test_Builder_create_fail_null_sequence_number() { |
| 125 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, VALUE, PARAMETER_TYPE_C, null) |
| 126 |
|
} |
| 127 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 128 |
0
|
@Test... |
| 129 |
|
void test_create_only_required(){ |
| 130 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1) |
| 131 |
|
} |
| 132 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4
-
|
|
| 133 |
0
|
@Test... |
| 134 |
|
void test_create_and_build_only_required(){ |
| 135 |
0
|
PropositionParameter.Builder.create(ID, PROP_ID, VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1).build() |
| 136 |
|
} |
| 137 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
4
-
|
|
| 138 |
0
|
@Test... |
| 139 |
|
public void testXmlMarshaling() { |
| 140 |
0
|
PropositionParameter myParameter = PropositionParameter.Builder.create(ID, PROP_ID, VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1).build() |
| 141 |
0
|
JAXBContext jc = JAXBContext.newInstance(PropositionParameter.class) |
| 142 |
0
|
Marshaller marshaller = jc.createMarshaller() |
| 143 |
0
|
StringWriter sw = new StringWriter() |
| 144 |
0
|
marshaller.marshal(myParameter, sw) |
| 145 |
0
|
String xml = sw.toString() |
| 146 |
|
|
| 147 |
0
|
Unmarshaller unmarshaller = jc.createUnmarshaller(); |
| 148 |
0
|
Object actual = unmarshaller.unmarshal(new StringReader(xml)) |
| 149 |
0
|
Object expected = unmarshaller.unmarshal(new StringReader(EXPECTED_XML)) |
| 150 |
0
|
Assert.assertEquals(expected, actual) |
| 151 |
|
} |
| 152 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
4
-
|
|
| 153 |
0
|
@Test... |
| 154 |
|
public void testXmlUnmarshal() { |
| 155 |
0
|
JAXBContext jc = JAXBContext.newInstance(PropositionParameter.class) |
| 156 |
0
|
Unmarshaller unmarshaller = jc.createUnmarshaller(); |
| 157 |
0
|
PropositionParameter myParameter = (PropositionParameter) unmarshaller.unmarshal(new StringReader(EXPECTED_XML)) |
| 158 |
0
|
Assert.assertEquals(ID, myParameter.id) |
| 159 |
0
|
Assert.assertEquals(PROP_ID, myParameter.propId) |
| 160 |
0
|
Assert.assertEquals(VALUE, myParameter.value) |
| 161 |
0
|
Assert.assertEquals(PARAMETER_TYPE_C, myParameter.parameterType) |
| 162 |
0
|
Assert.assertEquals(SEQUENCE_NUMBER_1, myParameter.sequenceNumber) |
| 163 |
|
} |
| 164 |
|
} |