Clover Coverage Report - rice-krms-api 2.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
35   164   28   1.25
0   0   0.8   28
28     1  
1    
 
  PropositionParameterTest       Line # 32 35 0% 28 63 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
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    * This class tests out the buiding of a PropositionParameter object.
27    * It also tests XML marshalling / unmarshalling
28    *
29    * @author Kuali Rice Team (rice.collab@kuali.org)
30    *
31    */
 
32    class PropositionParameterTest {
33   
 
34  0 toggle private static final String ID = "1001"
 
35  0 toggle private static final String PROP_ID = "202"
 
36  0 toggle private static final String VALUE = "campusCode"
 
37  0 toggle private static final String PARAMETER_TYPE_C = "C" // Constant
 
38  0 toggle private static final String PARAMETER_TYPE_T = "T" // Term
 
39  0 toggle private static final String PARAMETER_TYPE_F = "F" // Function
 
40  0 toggle private static final String PARAMETER_TYPE_BAD = "X" // some invalid value
41   
 
42  0 toggle private static final Integer SEQUENCE_NUMBER_1 = new Integer(1)
 
43  0 toggle 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   
 
53  0 toggle @Test(expected=IllegalArgumentException.class)
54    void test_Builder_create_fail_all_null() {
55  0 PropositionParameter.Builder.create(null, null, null, null, null)
56    }
57   
 
58  0 toggle @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   
 
63  0 toggle @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   
 
68  0 toggle @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   
 
73  0 toggle @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   
 
78  0 toggle @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   
 
83  0 toggle @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   
 
88  0 toggle @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   
 
93  0 toggle @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   
 
98  0 toggle @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   
 
103  0 toggle @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   
 
108  0 toggle @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   
 
113  0 toggle @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   
 
118  0 toggle @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   
 
123  0 toggle @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   
 
128  0 toggle @Test
129    void test_create_only_required(){
130  0 PropositionParameter.Builder.create(ID, PROP_ID, VALUE, PARAMETER_TYPE_C, SEQUENCE_NUMBER_1)
131    }
132   
 
133  0 toggle @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   
 
138  0 toggle @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   
 
153  0 toggle @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    }