Skip to content

Package: RuleConditionDmrUtil_Test

RuleConditionDmrUtil_Test

nameinstructionbranchcomplexitylinemethod
RuleConditionDmrUtil_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%
getDmrRootEClass_iterateCondition_databindingFailed()
M: 0 C: 65
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 15
100%
M: 0 C: 1
100%
getDmrRootEClass_iterateCondition_noEReference()
M: 0 C: 69
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 16
100%
M: 0 C: 1
100%
getDmrRootEClass_nestedIterateConditions()
M: 0 C: 104
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 25
100%
M: 0 C: 1
100%
getDmrRootEClass_noIterateConditions()
M: 0 C: 42
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
getDmrRootEClass_noView()
M: 0 C: 27
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
getDmrRootEClass_oneIterateCondition()
M: 0 C: 73
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 17
100%
M: 0 C: 1
100%
getDmrRootEClass_ownerIsIterateCondition()
M: 0 C: 43
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 11
100%
M: 0 C: 1
100%
getDmrRootObject_nestedIterateConditions()
M: 0 C: 153
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 38
100%
M: 0 C: 1
100%
getDmrRootObject_oneIterateCondition_attribute()
M: 0 C: 79
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 20
100%
M: 0 C: 1
100%
getDmrRootObject_oneIterateCondition_databindingFailed()
M: 0 C: 74
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 17
100%
M: 0 C: 1
100%
getDmrRootObject_oneIterateCondition_multiRef()
M: 0 C: 84
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 22
100%
M: 0 C: 1
100%
getDmrRootObject_oneIterateCondition_singleRef()
M: 0 C: 74
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 20
100%
M: 0 C: 1
100%
getDmrRootObject_simple()
M: 0 C: 43
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 12
100%
M: 0 C: 1
100%
getDmrRootObject_simple_noView()
M: 0 C: 32
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
setUp()
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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 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.emf.ecp.view.spi.rule;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.junit.Assert.assertFalse;
18: import static org.junit.Assert.assertNotNull;
19: import static org.junit.Assert.assertSame;
20: import static org.junit.Assert.assertTrue;
21: import static org.junit.Assume.assumeTrue;
22: import static org.mockito.Matchers.any;
23: import static org.mockito.Matchers.notNull;
24: import static org.mockito.Mockito.mock;
25: import static org.mockito.Mockito.never;
26: import static org.mockito.Mockito.times;
27: import static org.mockito.Mockito.verify;
28: import static org.mockito.Mockito.when;
29:
30: import java.util.List;
31: import java.util.Optional;
32:
33: import org.eclipse.emf.databinding.IEMFValueProperty;
34: import org.eclipse.emf.ecore.EAttribute;
35: import org.eclipse.emf.ecore.EClass;
36: import org.eclipse.emf.ecore.EObject;
37: import org.eclipse.emf.ecore.EReference;
38: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
39: import org.eclipse.emf.ecore.EcoreFactory;
40: import org.eclipse.emf.ecore.EcorePackage;
41: import org.eclipse.emf.ecore.InternalEObject;
42: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
43: import org.eclipse.emf.ecp.view.spi.model.VView;
44: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
45: import org.eclipse.emf.ecp.view.spi.rule.model.Condition;
46: import org.eclipse.emf.ecp.view.spi.rule.model.EnableRule;
47: import org.eclipse.emf.ecp.view.spi.rule.model.IterateCondition;
48: import org.eclipse.emf.ecp.view.spi.rule.model.RuleFactory;
49: import org.eclipse.emfforms.spi.common.report.AbstractReport;
50: import org.eclipse.emfforms.spi.common.report.ReportService;
51: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
52: import org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF;
53: import org.junit.Before;
54: import org.junit.Test;
55:
56: /**
57: * Unit tests for {@link RuleConditionDmrUtil}.
58: *
59: * @author Lucas Koehler
60: *
61: */
62: public class RuleConditionDmrUtil_Test {
63:
64:         private EMFFormsDatabindingEMF databinding;
65:         private ReportService reportService;
66:         private Condition condition;
67:
68:         @Before
69:         public void setUp() {
70:                 databinding = mock(EMFFormsDatabindingEMF.class);
71:                 reportService = mock(ReportService.class);
72:                 condition = RuleFactory.eINSTANCE.createLeafCondition();
73:         }
74:
75:         @Test
76:         public void getDmrRootEClass_noView() {
77:                 final IterateCondition iterateCondition = RuleFactory.eINSTANCE.createIterateCondition();
78:                 iterateCondition.setItemCondition(condition);
79:
80:                 final Optional<EClass> result = RuleConditionDmrUtil.getDmrRootEClass(databinding, reportService, condition);
81:                 assertFalse(result.isPresent());
82:                 verify(reportService, never()).report(any());
83:         }
84:
85:         @Test
86:         public void getDmrRootEClass_noIterateConditions() {
87:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
88:                 rule.setCondition(condition);
89:                 final VView view = VViewFactory.eINSTANCE.createView();
90:                 view.getAttachments().add(rule);
91:                 view.setRootEClass(EcorePackage.Literals.EATTRIBUTE);
92:
93:                 final Optional<EClass> result = RuleConditionDmrUtil.getDmrRootEClass(databinding, reportService, condition);
94:                 assumeTrue(result.isPresent());
95:                 assertSame(EcorePackage.Literals.EATTRIBUTE, result.get());
96:                 verify(reportService, never()).report(any());
97:         }
98:
99:         @Test
100:         public void getDmrRootEClass_oneIterateCondition() throws DatabindingFailedException {
101:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
102:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
103:                 iterate.setItemReference(iterateDmr);
104:                 iterate.setItemCondition(condition);
105:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
106:                 rule.setCondition(iterate);
107:                 final VView view = VViewFactory.eINSTANCE.createView();
108:                 view.getAttachments().add(rule);
109:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
110:
111:                 final IEMFValueProperty valueProperty = mock(IEMFValueProperty.class);
112:                 when(valueProperty.getValueType()).thenReturn(EcorePackage.Literals.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS);
113:                 when(databinding.getValueProperty(iterateDmr, EcorePackage.Literals.EREFERENCE)).thenReturn(valueProperty);
114:
115:                 final Optional<EClass> result = RuleConditionDmrUtil.getDmrRootEClass(databinding, reportService, condition);
116:                 assertTrue(result.isPresent());
117:                 assertSame(EcorePackage.Literals.ECLASS, result.get());
118:                 verify(reportService, never()).report(any());
119:         }
120:
121:         @Test
122:         public void getDmrRootEClass_nestedIterateConditions() throws DatabindingFailedException {
123:                 // Hierarchy: View -> Rule -> iterate -> iterateNested -> condition
124:
125:                 // deeper nested
126:                 final IterateCondition iterateNested = RuleFactory.eINSTANCE.createIterateCondition();
127:                 final VDomainModelReference iterateNestedDmr = VViewFactory.eINSTANCE.createDomainModelReference();
128:                 iterateNested.setItemReference(iterateNestedDmr);
129:                 iterateNested.setItemCondition(condition);
130:
131:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
132:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
133:                 iterate.setItemReference(iterateDmr);
134:                 iterate.setItemCondition(iterateNested);
135:
136:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
137:                 rule.setCondition(iterate);
138:                 final VView view = VViewFactory.eINSTANCE.createView();
139:                 view.getAttachments().add(rule);
140:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
141:
142:                 final IEMFValueProperty valueProperty = mock(IEMFValueProperty.class);
143:                 when(valueProperty.getValueType()).thenReturn(EcorePackage.Literals.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS);
144:                 when(databinding.getValueProperty(iterateDmr, EcorePackage.Literals.EREFERENCE)).thenReturn(valueProperty);
145:
146:                 final IEMFValueProperty valuePropertyNested = mock(IEMFValueProperty.class);
147:                 when(valuePropertyNested.getValueType()).thenReturn(EcorePackage.Literals.EMODEL_ELEMENT__EANNOTATIONS);
148:                 when(databinding.getValueProperty(iterateNestedDmr, EcorePackage.Literals.ECLASS))
149:                         .thenReturn(valuePropertyNested);
150:
151:                 final Optional<EClass> result = RuleConditionDmrUtil.getDmrRootEClass(databinding, reportService, condition);
152:                 assertTrue(result.isPresent());
153:                 assertSame(EcorePackage.Literals.EANNOTATION, result.get());
154:                 verify(reportService, never()).report(any());
155:         }
156:
157:         @SuppressWarnings("unchecked")
158:         @Test
159:         public void getDmrRootEClass_iterateCondition_databindingFailed() throws DatabindingFailedException {
160:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
161:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
162:                 iterate.setItemReference(iterateDmr);
163:                 iterate.setItemCondition(condition);
164:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
165:                 rule.setCondition(iterate);
166:                 final VView view = VViewFactory.eINSTANCE.createView();
167:                 view.getAttachments().add(rule);
168:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
169:
170:                 when(databinding.getValueProperty(iterateDmr, EcorePackage.Literals.EREFERENCE))
171:                         .thenThrow(DatabindingFailedException.class);
172:
173:                 final Optional<EClass> result = RuleConditionDmrUtil.getDmrRootEClass(databinding, reportService, condition);
174:                 assertFalse(result.isPresent());
175:                 verify(reportService, times(1)).report(any());
176:         }
177:
178:         @Test
179:         public void getDmrRootEClass_iterateCondition_noEReference() throws DatabindingFailedException {
180:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
181:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
182:                 iterate.setItemReference(iterateDmr);
183:                 iterate.setItemCondition(condition);
184:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
185:                 rule.setCondition(iterate);
186:                 final VView view = VViewFactory.eINSTANCE.createView();
187:                 view.getAttachments().add(rule);
188:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
189:
190:                 final IEMFValueProperty valueProperty = mock(IEMFValueProperty.class);
191:                 when(valueProperty.getValueType()).thenReturn(EcorePackage.Literals.ESTRUCTURAL_FEATURE__VOLATILE);
192:                 when(databinding.getValueProperty(iterateDmr, EcorePackage.Literals.EREFERENCE)).thenReturn(valueProperty);
193:
194:                 final Optional<EClass> result = RuleConditionDmrUtil.getDmrRootEClass(databinding, reportService, condition);
195:                 assertFalse(result.isPresent());
196:                 verify(reportService, never()).report(any());
197:         }
198:
199:         /**
200:          * Tests correct resolvement when the condition that will contain the new/edited dmr is an iterate condition. It
201:          * must be ensured that it is not tried to resolve this direct parent iterate condition.
202:          */
203:         @Test
204:         public void getDmrRootEClass_ownerIsIterateCondition() {
205:                 final IterateCondition owner = RuleFactory.eINSTANCE.createIterateCondition();
206:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
207:                 rule.setCondition(owner);
208:                 final VView view = VViewFactory.eINSTANCE.createView();
209:                 view.getAttachments().add(rule);
210:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
211:
212:                 final Optional<EClass> result = RuleConditionDmrUtil.getDmrRootEClass(databinding, reportService, owner);
213:                 assertTrue(result.isPresent());
214:                 assertSame(EcorePackage.Literals.EREFERENCE, result.get());
215:                 verify(reportService, never()).report(any());
216:         }
217:
218:         /** Trivial non-nested case. */
219:         @Test
220:         public void getDmrRootObject_simple() {
221:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
222:                 rule.setCondition(condition);
223:                 final VView view = VViewFactory.eINSTANCE.createView();
224:                 view.getAttachments().add(rule);
225:                 view.setRootEClass(EcorePackage.Literals.EATTRIBUTE);
226:
227:                 final EAttribute domain = EcoreFactory.eINSTANCE.createEAttribute();
228:
229:                 final List<EObject> result = RuleConditionDmrUtil.getDmrRootObject(databinding, reportService, domain,
230:                         condition);
231:                 assertNotNull(result);
232:                 assertEquals(1, result.size());
233:                 assertSame(domain, result.get(0));
234:         }
235:
236:         /** Trivial non-nested case but without a VView. This should not affect the method. */
237:         @Test
238:         public void getDmrRootObject_simple_noView() {
239:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
240:                 rule.setCondition(condition);
241:
242:                 final EAttribute domain = EcoreFactory.eINSTANCE.createEAttribute();
243:
244:                 final List<EObject> result = RuleConditionDmrUtil.getDmrRootObject(databinding, reportService, domain,
245:                         condition);
246:                 assertNotNull(result);
247:                 assertEquals(1, result.size());
248:                 assertSame(domain, result.get(0));
249:         }
250:
251:         @Test
252:         public void getDmrRootObject_oneIterateCondition_singleRef() throws DatabindingFailedException {
253:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
254:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
255:                 iterate.setItemReference(iterateDmr);
256:                 iterate.setItemCondition(condition);
257:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
258:                 rule.setCondition(iterate);
259:                 final VView view = VViewFactory.eINSTANCE.createView();
260:                 view.getAttachments().add(rule);
261:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
262:
263:                 final EReference domain = EcoreFactory.eINSTANCE.createEReference();
264:                 domain.setEType(EcorePackage.Literals.EANNOTATION);
265:
266:                 // iterate dmr points to single ref
267:                 final Setting setting = InternalEObject.class.cast(domain)
268:                         .eSetting(EcorePackage.Literals.EREFERENCE__EREFERENCE_TYPE);
269:                 when(databinding.getSetting(iterateDmr, domain)).thenReturn(setting);
270:
271:                 final List<EObject> result = RuleConditionDmrUtil.getDmrRootObject(databinding, reportService, domain,
272:                         condition);
273:
274:                 assertNotNull(result);
275:                 assertEquals(1, result.size());
276:                 assertSame(EcorePackage.Literals.EANNOTATION, result.get(0));
277:         }
278:
279:         @Test
280:         public void getDmrRootObject_oneIterateCondition_multiRef() throws DatabindingFailedException {
281:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
282:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
283:                 iterate.setItemReference(iterateDmr);
284:                 iterate.setItemCondition(condition);
285:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
286:                 rule.setCondition(iterate);
287:                 final VView view = VViewFactory.eINSTANCE.createView();
288:                 view.getAttachments().add(rule);
289:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
290:
291:                 final EReference domain = EcoreFactory.eINSTANCE.createEReference();
292:                 // set multi ref objects
293:                 domain.getEKeys().add(EcorePackage.Literals.ECLASS__ABSTRACT);
294:                 domain.getEKeys().add(EcorePackage.Literals.ENAMED_ELEMENT__NAME);
295:
296:                 // iterate dmr points to multiref
297:                 final Setting setting = InternalEObject.class.cast(domain)
298:                         .eSetting(EcorePackage.Literals.EREFERENCE__EKEYS);
299:                 when(databinding.getSetting(iterateDmr, domain)).thenReturn(setting);
300:
301:                 final List<EObject> result = RuleConditionDmrUtil.getDmrRootObject(databinding, reportService, domain,
302:                         condition);
303:
304:                 assertNotNull(result);
305:                 assertEquals(2, result.size());
306:                 assertTrue(result.contains(EcorePackage.Literals.ECLASS__ABSTRACT));
307:                 assertTrue(result.contains(EcorePackage.Literals.ENAMED_ELEMENT__NAME));
308:         }
309:
310:         @Test
311:         public void getDmrRootObject_oneIterateCondition_attribute() throws DatabindingFailedException {
312:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
313:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
314:                 iterate.setItemReference(iterateDmr);
315:                 iterate.setItemCondition(condition);
316:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
317:                 rule.setCondition(iterate);
318:                 final VView view = VViewFactory.eINSTANCE.createView();
319:                 view.getAttachments().add(rule);
320:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
321:
322:                 final EReference domain = EcoreFactory.eINSTANCE.createEReference();
323:                 domain.setEType(EcorePackage.Literals.EANNOTATION);
324:
325:                 // iterate dmr points to attribute
326:                 final Setting setting = InternalEObject.class.cast(domain)
327:                         .eSetting(EcorePackage.Literals.EREFERENCE__CONTAINMENT);
328:                 when(databinding.getSetting(iterateDmr, domain)).thenReturn(setting);
329:
330:                 final List<EObject> result = RuleConditionDmrUtil.getDmrRootObject(databinding, reportService, domain,
331:                         condition);
332:
333:                 assertNotNull(result);
334:                 assertEquals(0, result.size());
335:                 verify(reportService, times(1)).report(notNull(AbstractReport.class));
336:         }
337:
338:         @SuppressWarnings("unchecked")
339:         @Test
340:         public void getDmrRootObject_oneIterateCondition_databindingFailed() throws DatabindingFailedException {
341:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
342:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
343:                 iterate.setItemReference(iterateDmr);
344:                 iterate.setItemCondition(condition);
345:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
346:                 rule.setCondition(iterate);
347:                 final VView view = VViewFactory.eINSTANCE.createView();
348:                 view.getAttachments().add(rule);
349:                 view.setRootEClass(EcorePackage.Literals.EREFERENCE);
350:
351:                 final EReference domain = EcoreFactory.eINSTANCE.createEReference();
352:
353:                 when(databinding.getSetting(iterateDmr, domain)).thenThrow(DatabindingFailedException.class);
354:
355:                 final List<EObject> result = RuleConditionDmrUtil.getDmrRootObject(databinding, reportService, domain,
356:                         condition);
357:
358:                 assertNotNull(result);
359:                 assertEquals(0, result.size());
360:                 verify(reportService, times(1)).report(notNull(AbstractReport.class));
361:         }
362:
363:         @Test
364:         public void getDmrRootObject_nestedIterateConditions() throws DatabindingFailedException {
365:                 // Hierarchy: View -> Rule -> iterate -> iterateNested -> condition
366:
367:                 // deeper nested
368:                 final IterateCondition iterateNested = RuleFactory.eINSTANCE.createIterateCondition();
369:                 final VDomainModelReference iterateNestedDmr = VViewFactory.eINSTANCE.createDomainModelReference();
370:                 iterateNested.setItemReference(iterateNestedDmr);
371:                 iterateNested.setItemCondition(condition);
372:
373:                 final IterateCondition iterate = RuleFactory.eINSTANCE.createIterateCondition();
374:                 final VDomainModelReference iterateDmr = VViewFactory.eINSTANCE.createDomainModelReference();
375:                 iterate.setItemReference(iterateDmr);
376:                 iterate.setItemCondition(iterateNested);
377:
378:                 final EnableRule rule = RuleFactory.eINSTANCE.createEnableRule();
379:                 rule.setCondition(iterate);
380:                 final VView view = VViewFactory.eINSTANCE.createView();
381:                 view.getAttachments().add(rule);
382:                 view.setRootEClass(EcorePackage.Literals.ECLASS);
383:
384:                 // nested objects
385:                 final EReference ref1 = EcoreFactory.eINSTANCE.createEReference();
386:                 ref1.getEKeys().add(EcorePackage.Literals.ECLASS__ABSTRACT);
387:                 ref1.getEKeys().add(EcorePackage.Literals.ECLASS__INTERFACE);
388:                 final EReference ref2 = EcoreFactory.eINSTANCE.createEReference();
389:                 ref2.getEKeys().add(EcorePackage.Literals.EANNOTATION__SOURCE);
390:
391:                 // domain
392:                 final EClass domain = EcoreFactory.eINSTANCE.createEClass();
393:                 domain.getEStructuralFeatures().add(ref1);
394:                 domain.getEStructuralFeatures().add(ref2);
395:
396:                 // iterate dmr points to multiref
397:                 final Setting setting = InternalEObject.class.cast(domain)
398:                         .eSetting(EcorePackage.Literals.ECLASS__EREFERENCES);
399:                 when(databinding.getSetting(iterateDmr, domain)).thenReturn(setting);
400:
401:                 final Setting nestedSetting1 = InternalEObject.class.cast(ref1)
402:                         .eSetting(EcorePackage.Literals.EREFERENCE__EKEYS);
403:                 when(databinding.getSetting(iterateNestedDmr, ref1)).thenReturn(nestedSetting1);
404:
405:                 final Setting nestedSetting2 = InternalEObject.class.cast(ref2)
406:                         .eSetting(EcorePackage.Literals.EREFERENCE__EKEYS);
407:                 when(databinding.getSetting(iterateNestedDmr, ref2)).thenReturn(nestedSetting2);
408:
409:                 final List<EObject> result = RuleConditionDmrUtil.getDmrRootObject(databinding, reportService, domain,
410:                         condition);
411:
412:                 assertNotNull(result);
413:                 assertEquals(3, result.size());
414:                 assertTrue(result.contains(EcorePackage.Literals.ECLASS__ABSTRACT));
415:                 assertTrue(result.contains(EcorePackage.Literals.ECLASS__INTERFACE));
416:                 assertTrue(result.contains(EcorePackage.Literals.EANNOTATION__SOURCE));
417:         }
418: }