source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Gateway/SubscriptionRepository/test/gov/hhs/fha/nhinc/subscription/repository/data/test/SubscriptionReferenceTest.java@ 507

Last change on this file since 507 was 507, checked in by George Lilly, 15 years ago

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 9.7 KB
Line 
1package gov.hhs.fha.nhinc.subscription.repository.data.test;
2
3import org.junit.Test;
4import static org.junit.Assert.*;
5import gov.hhs.fha.nhinc.subscription.repository.data.ReferenceParameter;
6import gov.hhs.fha.nhinc.subscription.repository.data.SubscriptionReference;
7
8/**
9 * Unit test for the SubscriptionReference class
10 *
11 * @author webbn
12 */
13public class SubscriptionReferenceTest
14{
15 @Test
16 public void testGettersAndSetters()
17 {
18 System.out.println("Begin testGettersAndSetters");
19 try
20 {
21 String subMgrEndptAddr = "Submgredptaddr";
22 String namespace = "namespace";
23 String namespacePrefix = "prefix";
24 String elementName = "elementName";
25 String value = "elementValue";
26
27 ReferenceParameter refParam = new ReferenceParameter();
28 refParam.setNamespace(namespace);
29 refParam.setNamespacePrefix(namespacePrefix);
30 refParam.setElementName(elementName);
31 refParam.setValue(value);
32
33 SubscriptionReference ref = new SubscriptionReference();
34 ref.setSubscriptionManagerEndpointAddress(subMgrEndptAddr);
35 ref.addReferenceParameter(refParam);
36
37 assertEquals("Endpoint address", subMgrEndptAddr, ref.getSubscriptionManagerEndpointAddress());
38 assertNotNull("ReferenceParameters null", ref.getReferenceParameters());
39 assertEquals("ReferenceParameters empty", 1, ref.getReferenceParameters().size());
40 ReferenceParameter retRefParam = ref.getReferenceParameters().get(0);
41 assertNotNull("Retrieved reference param was null", retRefParam);
42 assertEquals("Ref param - namespace", namespace, retRefParam.getNamespace());
43 assertEquals("Ref param - namespace prefix", namespacePrefix, retRefParam.getNamespacePrefix());
44 assertEquals("Ref param - element name", elementName, retRefParam.getElementName());
45 assertEquals("Ref param - value", value, retRefParam.getValue());
46 }
47 catch (Throwable t)
48 {
49 t.printStackTrace();
50 fail(t.getMessage());
51 }
52 System.out.println("End testGettersAndSetters");
53 }
54
55 @Test
56 public void testEquals()
57 {
58 System.out.println("Begin testEquals");
59 try
60 {
61 // Equals - full
62 ReferenceParameter refParam = new ReferenceParameter();
63 refParam.setNamespace("namespace1");
64 refParam.setNamespacePrefix("namespacePrefix1");
65 refParam.setElementName("elementName1");
66 refParam.setValue("value1");
67 SubscriptionReference ref1 = new SubscriptionReference();
68 ref1.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
69 ref1.addReferenceParameter(refParam);
70 refParam = new ReferenceParameter();
71 refParam.setNamespace("namespace1");
72 refParam.setNamespacePrefix("namespacePrefix1");
73 refParam.setElementName("elementName1");
74 refParam.setValue("value1");
75 SubscriptionReference ref2 = new SubscriptionReference();
76 ref2.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
77 ref2.addReferenceParameter(refParam);
78 assertTrue("Equals - full", ref1.equals(ref2));
79
80 // Equals - endpoint address only
81 ref1 = new SubscriptionReference();
82 ref1.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
83 ref2 = new SubscriptionReference();
84 ref2.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
85 assertTrue("Equals - endpoint address only", ref1.equals(ref2));
86
87 // Equals - ref param only
88 refParam = new ReferenceParameter();
89 refParam.setNamespace("namespace1");
90 refParam.setNamespacePrefix("namespacePrefix1");
91 refParam.setElementName("elementName1");
92 refParam.setValue("value1");
93 ref1 = new SubscriptionReference();
94 ref1.addReferenceParameter(refParam);
95 refParam = new ReferenceParameter();
96 refParam.setNamespace("namespace1");
97 refParam.setNamespacePrefix("namespacePrefix1");
98 refParam.setElementName("elementName1");
99 refParam.setValue("value1");
100 ref2 = new SubscriptionReference();
101 ref2.addReferenceParameter(refParam);
102 assertTrue("Equals - ref param only", ref1.equals(ref2));
103
104 // Not equal - full, endpoint address different
105 refParam = new ReferenceParameter();
106 refParam.setNamespace("namespace1");
107 refParam.setNamespacePrefix("namespacePrefix1");
108 refParam.setElementName("elementName1");
109 refParam.setValue("value1");
110 ref1 = new SubscriptionReference();
111 ref1.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
112 ref1.addReferenceParameter(refParam);
113 refParam = new ReferenceParameter();
114 refParam.setNamespace("namespace1");
115 refParam.setNamespacePrefix("namespacePrefix1");
116 refParam.setElementName("elementName1");
117 refParam.setValue("value1");
118 ref2 = new SubscriptionReference();
119 ref2.setSubscriptionManagerEndpointAddress("subMgrEndptAddr2");
120 ref2.addReferenceParameter(refParam);
121 assertFalse("Not equal - full, endpoint address different", ref1.equals(ref2));
122
123 // Not equal - full, ref param different
124 refParam = new ReferenceParameter();
125 refParam.setNamespace("namespace1");
126 refParam.setNamespacePrefix("namespacePrefix1");
127 refParam.setElementName("elementName1");
128 refParam.setValue("value1");
129 ref1 = new SubscriptionReference();
130 ref1.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
131 ref1.addReferenceParameter(refParam);
132 refParam = new ReferenceParameter();
133 refParam.setNamespace("namespace1");
134 refParam.setNamespacePrefix("namespacePrefix1");
135 refParam.setElementName("elementName1");
136 refParam.setValue("value2");
137 ref2 = new SubscriptionReference();
138 ref2.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
139 ref2.addReferenceParameter(refParam);
140 assertFalse("Not equal - full, ref param different", ref1.equals(ref2));
141
142 // Not equal - 1 full, 2 missing endpoint address
143 refParam = new ReferenceParameter();
144 refParam.setNamespace("namespace1");
145 refParam.setNamespacePrefix("namespacePrefix1");
146 refParam.setElementName("elementName1");
147 refParam.setValue("value1");
148 ref1 = new SubscriptionReference();
149 ref1.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
150 ref1.addReferenceParameter(refParam);
151 refParam = new ReferenceParameter();
152 refParam.setNamespace("namespace1");
153 refParam.setNamespacePrefix("namespacePrefix1");
154 refParam.setElementName("elementName1");
155 refParam.setValue("value1");
156 ref2 = new SubscriptionReference();
157 ref2.addReferenceParameter(refParam);
158 assertFalse("Not equal - 1 full, 2 missing endpoint address", ref1.equals(ref2));
159
160 // Not equal - 1 full, 2 missing ref param
161 refParam = new ReferenceParameter();
162 refParam.setNamespace("namespace1");
163 refParam.setNamespacePrefix("namespacePrefix1");
164 refParam.setElementName("elementName1");
165 refParam.setValue("value1");
166 ref1 = new SubscriptionReference();
167 ref1.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
168 ref1.addReferenceParameter(refParam);
169 ref2 = new SubscriptionReference();
170 ref2.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
171 assertFalse("Not equal - 1 full, 2 missing ref param", ref1.equals(ref2));
172
173 // Not equal - 2 full, 1 missing endpoint address
174 refParam = new ReferenceParameter();
175 refParam.setNamespace("namespace1");
176 refParam.setNamespacePrefix("namespacePrefix1");
177 refParam.setElementName("elementName1");
178 refParam.setValue("value1");
179 ref1 = new SubscriptionReference();
180 ref1.addReferenceParameter(refParam);
181 refParam = new ReferenceParameter();
182 refParam.setNamespace("namespace1");
183 refParam.setNamespacePrefix("namespacePrefix1");
184 refParam.setElementName("elementName1");
185 refParam.setValue("value1");
186 ref2 = new SubscriptionReference();
187 ref2.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
188 ref2.addReferenceParameter(refParam);
189 assertFalse("Not equal - 2 full, 1 missing endpoint address", ref1.equals(ref2));
190
191 // Not equal - 2 full, 1 missing ref param
192 ref1 = new SubscriptionReference();
193 ref1.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
194 refParam = new ReferenceParameter();
195 refParam.setNamespace("namespace1");
196 refParam.setNamespacePrefix("namespacePrefix1");
197 refParam.setElementName("elementName1");
198 refParam.setValue("value1");
199 ref2 = new SubscriptionReference();
200 ref2.setSubscriptionManagerEndpointAddress("subMgrEndptAddr1");
201 ref2.addReferenceParameter(refParam);
202 assertFalse("Not equal - 2 full, 1 missing ref param", ref1.equals(ref2));
203
204 }
205 catch (Throwable t)
206 {
207 t.printStackTrace();
208 fail(t.getMessage());
209 }
210 System.out.println("End testEquals");
211 }
212}
Note: See TracBrowser for help on using the repository browser.