Skip to content

Package: StructuralChangeTesterKeyAttribute_Test

StructuralChangeTesterKeyAttribute_Test

nameinstructionbranchcomplexitylinemethod
StructuralChangeTesterKeyAttribute_Test()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createKeyAttributeDMR(VFeaturePathDomainModelReference, VFeaturePathDomainModelReference)
M: 0 C: 24
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
createKeyDMR()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
createValueDMR()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
setUp()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
testIsApplicableCorrectReferenceType()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
testIsApplicableNullReference()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testIsApplicableWrongReferenceType()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
testIsStructureChangedFeaturePathChanged()
M: 0 C: 96
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 22
100%
M: 0 C: 1
100%
testIsStructureChangedKeyChangeIrrelevant()
M: 0 C: 147
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 33
100%
M: 0 C: 1
100%
testIsStructureChangedKeyFromCorrectToIncorrect()
M: 0 C: 147
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 33
100%
M: 0 C: 1
100%
testIsStructureChangedKeyFromIncorrectToCorrect()
M: 0 C: 147
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 33
100%
M: 0 C: 1
100%
testIsStructureChangedKeyNotPresentAndValueDMRChanged()
M: 0 C: 135
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 31
100%
M: 0 C: 1
100%
testIsStructureChangedKeyPresentAndValueDMRChanged()
M: 0 C: 135
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 31
100%
M: 0 C: 1
100%
testIsStructureChangedNoRelevantChange()
M: 0 C: 135
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 31
100%
M: 0 C: 1
100%
testIsStructureChangedNullEObject()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testIsStructureChangedNullNotification()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testIsStructureChangedNullReference()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.core.services.structuralchange.keyattribute;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.junit.Assert.assertFalse;
18: import static org.junit.Assert.assertTrue;
19: import static org.mockito.Mockito.mock;
20: import static org.mockito.Mockito.when;
21:
22: import org.eclipse.emf.common.notify.Notification;
23: import org.eclipse.emf.ecore.EObject;
24: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
25: import org.eclipse.emf.ecore.InternalEObject;
26: import org.eclipse.emf.ecp.view.spi.keyattributedmr.model.VKeyAttributeDomainModelReference;
27: import org.eclipse.emf.ecp.view.spi.keyattributedmr.model.VKeyattributedmrFactory;
28: import org.eclipse.emf.ecp.view.spi.model.ModelChangeNotification;
29: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
30: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
31: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
32: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.A;
33: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.B;
34: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.C;
35: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.D;
36: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.TestFactory;
37: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.TestPackage;
38: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
39: import org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF;
40: import org.eclipse.emfforms.spi.core.services.structuralchange.EMFFormsStructuralChangeTester;
41: import org.eclipse.emfforms.spi.core.services.structuralchange.StructuralChangeTesterInternal;
42: import org.junit.Before;
43: import org.junit.Test;
44:
45: /**
46: * JUnit test cases for {@link StructuralChangeTesterKeyAttribute}.
47: *
48: * @author Lucas Koehler
49: *
50: */
51: public class StructuralChangeTesterKeyAttribute_Test {
52:
53:         private static final String WRONG_TEST_KEY2 = "WRONG_TEST_KEY2"; //$NON-NLS-1$
54:         private static final String WRONG_TEST_KEY = "WRONG_TEST_KEY"; //$NON-NLS-1$
55:         private static final String CORRECT_TEST_KEY = "CORRECT_TEST_KEY"; //$NON-NLS-1$
56:         private StructuralChangeTesterKeyAttribute tester;
57:
58:         @Before
59:         public void setUp() {
60:                 tester = new StructuralChangeTesterKeyAttribute();
61:         }
62:
63:         @Test
64:         public void testIsApplicableCorrectReferenceType() {
65:                 assertEquals(5d, tester.isApplicable(mock(VKeyAttributeDomainModelReference.class)), 0d);
66:         }
67:
68:         @Test
69:         public void testIsStructureChangedKeyPresentAndValueDMRChanged() throws DatabindingFailedException {
70:
71:                 // Create and configure DMRs
72:                 final VFeaturePathDomainModelReference keyDMR = createKeyDMR();
73:                 final VFeaturePathDomainModelReference valueDMR = createValueDMR();
74:                 final VKeyAttributeDomainModelReference keyAttributeDMR = createKeyAttributeDMR(keyDMR, valueDMR);
75:
76:                 // Create domain model
77:                 final A a = TestFactory.eINSTANCE.createA();
78:                 final B b = TestFactory.eINSTANCE.createB();
79:                 final C c = TestFactory.eINSTANCE.createC();
80:                 final A aOfC = TestFactory.eINSTANCE.createA();
81:                 final B bOfC = TestFactory.eINSTANCE.createB();
82:                 final D dWithKey = TestFactory.eINSTANCE.createD();
83:                 dWithKey.setX(CORRECT_TEST_KEY);
84:
85:                 a.setB(b);
86:                 b.getCList().add(c);
87:                 c.setD(dWithKey);
88:                 c.setA(aOfC);
89:                 aOfC.setB(bOfC);
90:
91:                 // Mocking
92:                 final EMFFormsDatabindingEMF databinding = mock(EMFFormsDatabindingEMF.class);
93:                 final EMFFormsStructuralChangeTester changeTester = mock(EMFFormsStructuralChangeTester.class);
94:                 final ModelChangeNotification notification = mock(ModelChangeNotification.class);
95:                 final Notification rawNotification = mock(Notification.class);
96:
97:                 when(rawNotification.isTouch()).thenReturn(false);
98:                 when(notification.getNotifier()).thenReturn(aOfC);
99:                 when(notification.getRawNotification()).thenReturn(rawNotification);
100:                 when(notification.getStructuralFeature()).thenReturn(TestPackage.eINSTANCE.getA_B());
101:
102:                 final Setting keySetting = ((InternalEObject) dWithKey).eSetting(TestPackage.eINSTANCE.getD_X());
103:                 when(databinding.getSetting(keyDMR, c)).thenReturn(keySetting);
104:
105:                 // In this case bOfC is changed => the structure of the value dmr is changed
106:                 when(changeTester.isStructureChanged(valueDMR, c, notification)).thenReturn(true);
107:
108:                 tester.setEMFFormsDatabindingEMF(databinding);
109:                 tester.setEMFFormsStructuralChangeTester(changeTester);
110:
111:                 final boolean result = tester.isStructureChanged(keyAttributeDMR, a, notification);
112:
113:                 assertTrue(result);
114:         }
115:
116:         @Test
117:         public void testIsStructureChangedKeyNotPresentAndValueDMRChanged() throws DatabindingFailedException {
118:
119:                 // Create and configure DMRs
120:                 final VFeaturePathDomainModelReference keyDMR = createKeyDMR();
121:                 final VFeaturePathDomainModelReference valueDMR = createValueDMR();
122:                 final VKeyAttributeDomainModelReference keyAttributeDMR = createKeyAttributeDMR(keyDMR, valueDMR);
123:
124:                 // Create domain model
125:                 final A a = TestFactory.eINSTANCE.createA();
126:                 final B b = TestFactory.eINSTANCE.createB();
127:                 final C c = TestFactory.eINSTANCE.createC();
128:                 final A aOfC = TestFactory.eINSTANCE.createA();
129:                 final B bOfC = TestFactory.eINSTANCE.createB();
130:                 final D dWithoutKey = TestFactory.eINSTANCE.createD();
131:                 dWithoutKey.setX(WRONG_TEST_KEY);
132:
133:                 a.setB(b);
134:                 b.getCList().add(c);
135:                 c.setD(dWithoutKey);
136:                 c.setA(aOfC);
137:                 aOfC.setB(bOfC);
138:
139:                 // Mocking
140:                 final EMFFormsDatabindingEMF databinding = mock(EMFFormsDatabindingEMF.class);
141:                 final EMFFormsStructuralChangeTester changeTester = mock(EMFFormsStructuralChangeTester.class);
142:                 final ModelChangeNotification notification = mock(ModelChangeNotification.class);
143:                 final Notification rawNotification = mock(Notification.class);
144:
145:                 when(rawNotification.isTouch()).thenReturn(false);
146:                 when(notification.getNotifier()).thenReturn(aOfC);
147:                 when(notification.getRawNotification()).thenReturn(rawNotification);
148:                 when(notification.getStructuralFeature()).thenReturn(TestPackage.eINSTANCE.getA_B());
149:
150:                 final Setting keySetting = ((InternalEObject) dWithoutKey).eSetting(TestPackage.eINSTANCE.getD_X());
151:                 when(databinding.getSetting(keyDMR, c)).thenReturn(keySetting);
152:
153:                 // In this case bOfC is changed => the structure of the value dmr is changed
154:                 when(changeTester.isStructureChanged(valueDMR, c, notification)).thenReturn(true);
155:
156:                 tester.setEMFFormsDatabindingEMF(databinding);
157:                 tester.setEMFFormsStructuralChangeTester(changeTester);
158:
159:                 final boolean result = tester.isStructureChanged(keyAttributeDMR, a, notification);
160:
161:                 assertFalse(result);
162:         }
163:
164:         @Test
165:         public void testIsStructureChangedNoRelevantChange() throws DatabindingFailedException {
166:
167:                 // Create and configure DMRs
168:                 final VFeaturePathDomainModelReference keyDMR = createKeyDMR();
169:                 final VFeaturePathDomainModelReference valueDMR = createValueDMR();
170:                 final VKeyAttributeDomainModelReference keyAttributeDMR = createKeyAttributeDMR(keyDMR, valueDMR);
171:
172:                 // Create domain model
173:                 final A a = TestFactory.eINSTANCE.createA();
174:                 final B b = TestFactory.eINSTANCE.createB();
175:                 final C c = TestFactory.eINSTANCE.createC();
176:                 final A aOfC = TestFactory.eINSTANCE.createA();
177:                 final B bOfC = TestFactory.eINSTANCE.createB();
178:                 final D d = TestFactory.eINSTANCE.createD();
179:                 d.setX(CORRECT_TEST_KEY);
180:
181:                 a.setB(b);
182:                 b.getCList().add(c);
183:                 c.setD(d);
184:                 c.setA(aOfC);
185:                 aOfC.setB(bOfC);
186:
187:                 // Mocking
188:                 final EMFFormsDatabindingEMF databinding = mock(EMFFormsDatabindingEMF.class);
189:                 final EMFFormsStructuralChangeTester changeTester = mock(EMFFormsStructuralChangeTester.class);
190:                 final ModelChangeNotification notification = mock(ModelChangeNotification.class);
191:                 final Notification rawNotification = mock(Notification.class);
192:
193:                 when(rawNotification.isTouch()).thenReturn(false);
194:                 when(notification.getNotifier()).thenReturn(b);
195:                 when(notification.getRawNotification()).thenReturn(rawNotification);
196:                 when(notification.getStructuralFeature()).thenReturn(TestPackage.eINSTANCE.getB_C());
197:
198:                 final Setting keySetting = ((InternalEObject) d).eSetting(TestPackage.eINSTANCE.getD_X());
199:                 when(databinding.getSetting(keyDMR, c)).thenReturn(keySetting);
200:
201:                 // In this case bOfC is not changed => the structure of the value dmr is not changed
202:                 when(changeTester.isStructureChanged(valueDMR, c, notification)).thenReturn(false);
203:
204:                 tester.setEMFFormsDatabindingEMF(databinding);
205:                 tester.setEMFFormsStructuralChangeTester(changeTester);
206:
207:                 final boolean result = tester.isStructureChanged(keyAttributeDMR, a, notification);
208:
209:                 assertFalse(result);
210:         }
211:
212:         @Test
213:         public void testIsStructureChangedKeyFromCorrectToIncorrect() throws DatabindingFailedException {
214:
215:                 // Create and configure DMRs
216:                 final VFeaturePathDomainModelReference keyDMR = createKeyDMR();
217:                 final VFeaturePathDomainModelReference valueDMR = createValueDMR();
218:                 final VKeyAttributeDomainModelReference keyAttributeDMR = createKeyAttributeDMR(keyDMR, valueDMR);
219:
220:                 // Create domain model
221:                 final A a = TestFactory.eINSTANCE.createA();
222:                 final B b = TestFactory.eINSTANCE.createB();
223:                 final C c = TestFactory.eINSTANCE.createC();
224:                 final A aOfC = TestFactory.eINSTANCE.createA();
225:                 final B bOfC = TestFactory.eINSTANCE.createB();
226:                 final D d = TestFactory.eINSTANCE.createD();
227:                 d.setX(WRONG_TEST_KEY);
228:
229:                 a.setB(b);
230:                 b.getCList().add(c);
231:                 c.setD(d);
232:                 c.setA(aOfC);
233:                 aOfC.setB(bOfC);
234:
235:                 // Mocking
236:                 final EMFFormsDatabindingEMF databinding = mock(EMFFormsDatabindingEMF.class);
237:                 final EMFFormsStructuralChangeTester changeTester = mock(EMFFormsStructuralChangeTester.class);
238:                 final ModelChangeNotification notification = mock(ModelChangeNotification.class);
239:                 final Notification rawNotification = mock(Notification.class);
240:
241:                 when(rawNotification.isTouch()).thenReturn(false);
242:                 when(rawNotification.getOldValue()).thenReturn(CORRECT_TEST_KEY);
243:                 when(rawNotification.getNewValue()).thenReturn(WRONG_TEST_KEY);
244:                 when(notification.getNotifier()).thenReturn(d);
245:                 when(notification.getRawNotification()).thenReturn(rawNotification);
246:                 when(notification.getStructuralFeature()).thenReturn(TestPackage.eINSTANCE.getD_X());
247:
248:                 final Setting keySetting = ((InternalEObject) d).eSetting(TestPackage.eINSTANCE.getD_X());
249:                 when(databinding.getSetting(keyDMR, c)).thenReturn(keySetting);
250:
251:                 // In this case bOfC is not changed => the structure of the value dmr is not changed
252:                 when(changeTester.isStructureChanged(valueDMR, c, notification)).thenReturn(false);
253:
254:                 tester.setEMFFormsDatabindingEMF(databinding);
255:                 tester.setEMFFormsStructuralChangeTester(changeTester);
256:
257:                 final boolean result = tester.isStructureChanged(keyAttributeDMR, a, notification);
258:
259:                 assertTrue(result);
260:         }
261:
262:         @Test
263:         public void testIsStructureChangedKeyFromIncorrectToCorrect() throws DatabindingFailedException {
264:
265:                 // Create and configure DMRs
266:                 final VFeaturePathDomainModelReference keyDMR = createKeyDMR();
267:                 final VFeaturePathDomainModelReference valueDMR = createValueDMR();
268:                 final VKeyAttributeDomainModelReference keyAttributeDMR = createKeyAttributeDMR(keyDMR, valueDMR);
269:
270:                 // Create domain model
271:                 final A a = TestFactory.eINSTANCE.createA();
272:                 final B b = TestFactory.eINSTANCE.createB();
273:                 final C c = TestFactory.eINSTANCE.createC();
274:                 final A aOfC = TestFactory.eINSTANCE.createA();
275:                 final B bOfC = TestFactory.eINSTANCE.createB();
276:                 final D d = TestFactory.eINSTANCE.createD();
277:                 d.setX(WRONG_TEST_KEY);
278:
279:                 a.setB(b);
280:                 b.getCList().add(c);
281:                 c.setD(d);
282:                 c.setA(aOfC);
283:                 aOfC.setB(bOfC);
284:
285:                 // Mocking
286:                 final EMFFormsDatabindingEMF databinding = mock(EMFFormsDatabindingEMF.class);
287:                 final EMFFormsStructuralChangeTester changeTester = mock(EMFFormsStructuralChangeTester.class);
288:                 final ModelChangeNotification notification = mock(ModelChangeNotification.class);
289:                 final Notification rawNotification = mock(Notification.class);
290:
291:                 when(rawNotification.isTouch()).thenReturn(false);
292:                 when(rawNotification.getOldValue()).thenReturn(WRONG_TEST_KEY);
293:                 when(rawNotification.getNewValue()).thenReturn(CORRECT_TEST_KEY);
294:                 when(notification.getNotifier()).thenReturn(d);
295:                 when(notification.getRawNotification()).thenReturn(rawNotification);
296:                 when(notification.getStructuralFeature()).thenReturn(TestPackage.eINSTANCE.getD_X());
297:
298:                 final Setting keySetting = ((InternalEObject) d).eSetting(TestPackage.eINSTANCE.getD_X());
299:                 when(databinding.getSetting(keyDMR, c)).thenReturn(keySetting);
300:
301:                 // In this case bOfC is not changed => the structure of the value dmr is not changed
302:                 when(changeTester.isStructureChanged(valueDMR, c, notification)).thenReturn(false);
303:
304:                 tester.setEMFFormsDatabindingEMF(databinding);
305:                 tester.setEMFFormsStructuralChangeTester(changeTester);
306:
307:                 final boolean result = tester.isStructureChanged(keyAttributeDMR, a, notification);
308:
309:                 assertTrue(result);
310:         }
311:
312:         @Test
313:         public void testIsStructureChangedKeyChangeIrrelevant() throws DatabindingFailedException {
314:
315:                 // Create and configure DMRs
316:                 final VFeaturePathDomainModelReference keyDMR = createKeyDMR();
317:                 final VFeaturePathDomainModelReference valueDMR = createValueDMR();
318:                 final VKeyAttributeDomainModelReference keyAttributeDMR = createKeyAttributeDMR(keyDMR, valueDMR);
319:
320:                 // Create domain model
321:                 final A a = TestFactory.eINSTANCE.createA();
322:                 final B b = TestFactory.eINSTANCE.createB();
323:                 final C c = TestFactory.eINSTANCE.createC();
324:                 final A aOfC = TestFactory.eINSTANCE.createA();
325:                 final B bOfC = TestFactory.eINSTANCE.createB();
326:                 final D d = TestFactory.eINSTANCE.createD();
327:                 d.setX(WRONG_TEST_KEY);
328:
329:                 a.setB(b);
330:                 b.getCList().add(c);
331:                 c.setD(d);
332:                 c.setA(aOfC);
333:                 aOfC.setB(bOfC);
334:
335:                 // Mocking
336:                 final EMFFormsDatabindingEMF databinding = mock(EMFFormsDatabindingEMF.class);
337:                 final EMFFormsStructuralChangeTester changeTester = mock(EMFFormsStructuralChangeTester.class);
338:                 final ModelChangeNotification notification = mock(ModelChangeNotification.class);
339:                 final Notification rawNotification = mock(Notification.class);
340:
341:                 when(rawNotification.isTouch()).thenReturn(false);
342:                 when(rawNotification.getOldValue()).thenReturn(WRONG_TEST_KEY);
343:                 when(rawNotification.getNewValue()).thenReturn(WRONG_TEST_KEY2);
344:                 when(notification.getNotifier()).thenReturn(d);
345:                 when(notification.getRawNotification()).thenReturn(rawNotification);
346:                 when(notification.getStructuralFeature()).thenReturn(TestPackage.eINSTANCE.getD_X());
347:
348:                 final Setting keySetting = ((InternalEObject) d).eSetting(TestPackage.eINSTANCE.getD_X());
349:                 when(databinding.getSetting(keyDMR, c)).thenReturn(keySetting);
350:
351:                 // In this case bOfC is not changed => the structure of the value dmr is not changed
352:                 when(changeTester.isStructureChanged(valueDMR, c, notification)).thenReturn(false);
353:
354:                 tester.setEMFFormsDatabindingEMF(databinding);
355:                 tester.setEMFFormsStructuralChangeTester(changeTester);
356:
357:                 final boolean result = tester.isStructureChanged(keyAttributeDMR, a, notification);
358:
359:                 assertFalse(result);
360:         }
361:
362:         @Test
363:         public void testIsStructureChangedFeaturePathChanged() throws DatabindingFailedException {
364:
365:                 // Create and configure DMRs
366:                 final VFeaturePathDomainModelReference keyDMR = createKeyDMR();
367:                 final VFeaturePathDomainModelReference valueDMR = createValueDMR();
368:                 final VKeyAttributeDomainModelReference keyAttributeDMR = createKeyAttributeDMR(keyDMR, valueDMR);
369:
370:                 // Create domain model
371:                 final A a = TestFactory.eINSTANCE.createA();
372:                 final B b = TestFactory.eINSTANCE.createB();
373:                 final B bNew = TestFactory.eINSTANCE.createB();
374:
375:                 a.setB(bNew);
376:
377:                 // Mocking
378:                 final EMFFormsDatabindingEMF databinding = mock(EMFFormsDatabindingEMF.class);
379:                 final EMFFormsStructuralChangeTester changeTester = mock(EMFFormsStructuralChangeTester.class);
380:                 final ModelChangeNotification notification = mock(ModelChangeNotification.class);
381:                 final Notification rawNotification = mock(Notification.class);
382:
383:                 when(rawNotification.isTouch()).thenReturn(false);
384:                 when(rawNotification.getOldValue()).thenReturn(b);
385:                 when(rawNotification.getNewValue()).thenReturn(bNew);
386:                 when(notification.getNotifier()).thenReturn(a);
387:                 when(notification.getRawNotification()).thenReturn(rawNotification);
388:                 when(notification.getStructuralFeature()).thenReturn(TestPackage.eINSTANCE.getA_B());
389:
390:                 tester.setEMFFormsDatabindingEMF(databinding);
391:                 tester.setEMFFormsStructuralChangeTester(changeTester);
392:
393:                 final boolean result = tester.isStructureChanged(keyAttributeDMR, a, notification);
394:
395:                 assertTrue(result);
396:         }
397:
398:         /**
399:          * @param keyDMR
400:          * @param valueDMR
401:          * @return
402:          */
403:         private VKeyAttributeDomainModelReference createKeyAttributeDMR(final VFeaturePathDomainModelReference keyDMR,
404:                 final VFeaturePathDomainModelReference valueDMR) {
405:                 final VKeyAttributeDomainModelReference keyAttributeDMR = VKeyattributedmrFactory.eINSTANCE
406:                         .createKeyAttributeDomainModelReference();
407:
408:                 keyAttributeDMR.setKeyValue(CORRECT_TEST_KEY);
409:                 keyAttributeDMR.getDomainModelEReferencePath().add(TestPackage.eINSTANCE.getA_B());
410:                 keyAttributeDMR.setDomainModelEFeature(TestPackage.eINSTANCE.getB_CList());
411:
412:                 keyAttributeDMR.setKeyDMR(keyDMR);
413:                 keyAttributeDMR.setValueDMR(valueDMR);
414:                 return keyAttributeDMR;
415:         }
416:
417:         /**
418:          * @return
419:          */
420:         private VFeaturePathDomainModelReference createValueDMR() {
421:                 final VFeaturePathDomainModelReference valueDMR = VViewFactory.eINSTANCE
422:                         .createFeaturePathDomainModelReference();
423:                 valueDMR.getDomainModelEReferencePath().add(TestPackage.eINSTANCE.getC_A());
424:                 valueDMR.setDomainModelEFeature(TestPackage.eINSTANCE.getA_B());
425:                 return valueDMR;
426:         }
427:
428:         /**
429:          * @return
430:          */
431:         private VFeaturePathDomainModelReference createKeyDMR() {
432:                 final VFeaturePathDomainModelReference keyDMR = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
433:                 keyDMR.getDomainModelEReferencePath().add(TestPackage.eINSTANCE.getC_D());
434:                 keyDMR.setDomainModelEFeature(TestPackage.eINSTANCE.getD_X());
435:                 return keyDMR;
436:         }
437:
438:         @Test
439:         public void testIsApplicableWrongReferenceType() {
440:                 assertEquals(StructuralChangeTesterInternal.NOT_APPLICABLE,
441:                         tester.isApplicable(mock(VFeaturePathDomainModelReference.class)), 0d);
442:         }
443:
444:         @Test(expected = IllegalArgumentException.class)
445:         public void testIsApplicableNullReference() {
446:                 tester.isApplicable(null);
447:         }
448:
449:         @Test(expected = IllegalArgumentException.class)
450:         public void testIsStructureChangedNullReference() {
451:                 tester.isStructureChanged(null, mock(EObject.class), mock(ModelChangeNotification.class));
452:         }
453:
454:         @Test(expected = IllegalArgumentException.class)
455:         public void testIsStructureChangedNullEObject() {
456:                 tester.isStructureChanged(mock(VDomainModelReference.class), null, mock(ModelChangeNotification.class));
457:         }
458:
459:         @Test(expected = IllegalArgumentException.class)
460:         public void testIsStructureChangedNullNotification() {
461:                 tester.isStructureChanged(mock(VDomainModelReference.class), mock(EObject.class), null);
462:         }
463: }