Skip to content

Package: TableValidation_PTest$2

TableValidation_PTest$2

nameinstructionbranchcomplexitylinemethod
featureValueOf(Diagnostic)
M: 2 C: 16
89%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 1 C: 3
75%
M: 0 C: 1
100%
{...}
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
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: * Eugen - initial API and implementation
13: * Christian W. Damus - bug 543190
14: ******************************************************************************/
15: package org.eclipse.emf.ecp.view.validation.test;
16:
17: import static org.hamcrest.CoreMatchers.hasItem;
18: import static org.hamcrest.CoreMatchers.hasItems;
19: import static org.hamcrest.CoreMatchers.is;
20: import static org.hamcrest.MatcherAssert.assertThat;
21: import static org.junit.Assert.assertEquals;
22:
23: import java.util.Collections;
24: import java.util.LinkedHashSet;
25: import java.util.List;
26: import java.util.Set;
27:
28: import org.eclipse.emf.common.util.BasicDiagnostic;
29: import org.eclipse.emf.common.util.Diagnostic;
30: import org.eclipse.emf.ecore.EAttribute;
31: import org.eclipse.emf.ecore.EClass;
32: import org.eclipse.emf.ecore.EObject;
33: import org.eclipse.emf.ecore.EReference;
34: import org.eclipse.emf.ecore.EStructuralFeature;
35: import org.eclipse.emf.ecp.test.common.DefaultRealm;
36: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
37: import org.eclipse.emf.ecp.view.spi.context.ViewModelContextFactory;
38: import org.eclipse.emf.ecp.view.spi.model.VControl;
39: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
40: import org.eclipse.emf.ecp.view.spi.model.VView;
41: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
42: import org.eclipse.emf.ecp.view.spi.table.model.DetailEditing;
43: import org.eclipse.emf.ecp.view.spi.table.model.VTableControl;
44: import org.eclipse.emf.ecp.view.spi.table.model.VTableDomainModelReference;
45: import org.eclipse.emf.ecp.view.spi.table.model.VTableFactory;
46: import org.eclipse.emf.ecp.view.spi.validation.ValidationService;
47: import org.eclipse.emf.ecp.view.validation.test.model.Library;
48: import org.eclipse.emf.ecp.view.validation.test.model.TableContentWithInnerChild;
49: import org.eclipse.emf.ecp.view.validation.test.model.TableContentWithInnerChild2;
50: import org.eclipse.emf.ecp.view.validation.test.model.TableContentWithValidation;
51: import org.eclipse.emf.ecp.view.validation.test.model.TableContentWithoutValidation;
52: import org.eclipse.emf.ecp.view.validation.test.model.TableObject;
53: import org.eclipse.emf.ecp.view.validation.test.model.TableWithMultiplicity;
54: import org.eclipse.emf.ecp.view.validation.test.model.TableWithUnique;
55: import org.eclipse.emf.ecp.view.validation.test.model.TableWithoutMultiplicity;
56: import org.eclipse.emf.ecp.view.validation.test.model.TableWithoutMultiplicityConcrete;
57: import org.eclipse.emf.ecp.view.validation.test.model.TestFactory;
58: import org.eclipse.emf.ecp.view.validation.test.model.TestPackage;
59: import org.eclipse.emf.ecp.view.validation.test.model.Writer;
60: import org.eclipse.emf.ecp.view.validation.test.model.util.TestSwitch;
61: import org.hamcrest.FeatureMatcher;
62: import org.hamcrest.Matcher;
63: import org.junit.After;
64: import org.junit.Before;
65: import org.junit.Test;
66:
67: /**
68: * This class contains only tests for validation errors on Tables. This test also doesn't check whether the table
69: * updates correctly on diagnostic change. It is only checked, that the Diagnostic is correctly set.
70: *
71: * Tests:
72: * - test table with only reference multiplicity (init empty/not empty, dynamic add/ remove)
73: * - test table without reference multiplicity, but with independent validation on children
74: *
75: * @author Eugen Neufeld
76: *
77: */
78: public class TableValidation_PTest {
79:
80:         private DefaultRealm defaultRealm;
81:
82:         @Before
83:         public void setup() {
84:                 defaultRealm = new DefaultRealm();
85:         }
86:
87:         @After
88:         public void tearDown() {
89:                 defaultRealm.dispose();
90:         }
91:
92:         private VView createViewWithTableControl(EClass rootClass, EReference tableReference,
93:                 EAttribute... columnAttributes) {
94:                 final VView view = VViewFactory.eINSTANCE.createView();
95:                 view.setRootEClass(rootClass);
96:                 final VTableControl tableControl = VTableFactory.eINSTANCE.createTableControl();
97:                 view.getChildren().add(tableControl);
98:                 final VTableDomainModelReference domainModelReference = VTableFactory.eINSTANCE
99:                         .createTableDomainModelReference();
100:                 tableControl.setDomainModelReference(domainModelReference);
101:                 domainModelReference.setDomainModelEFeature(tableReference);
102:
103:                 for (final EAttribute attribute : columnAttributes) {
104:                         final VFeaturePathDomainModelReference column = VViewFactory.eINSTANCE
105:                                 .createFeaturePathDomainModelReference();
106:                         column.setDomainModelEFeature(attribute);
107:
108:                         VTableDomainModelReference.class.cast(tableControl.getDomainModelReference())
109:                                 .getColumnDomainModelReferences().add(column);
110:                 }
111:                 return view;
112:         }
113:
114:         @Test
115:         public void testReferenceMultiplicityInitEmpty() {
116:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithMultiplicity(),
117:                         TestPackage.eINSTANCE.getTableWithMultiplicity_Content(),
118:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
119:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
120:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
121:                 final TableWithMultiplicity domain = TestFactory.eINSTANCE.createTableWithMultiplicity();
122:
123:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
124:
125:                 assertEquals(Diagnostic.ERROR, table.getDiagnostic().getHighestSeverity());
126:         }
127:
128:         @Test
129:         public void testReferenceMultiplicityInitNotEmpty() {
130:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithMultiplicity(),
131:                         TestPackage.eINSTANCE.getTableWithMultiplicity_Content(),
132:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
133:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
134:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
135:                 final TableWithMultiplicity domain = TestFactory.eINSTANCE.createTableWithMultiplicity();
136:                 domain.getContent().add(TestFactory.eINSTANCE.createTableContentWithoutValidation());
137:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
138:
139:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
140:         }
141:
142:         @Test
143:         public void testReferenceMultiplicityDynamicEmptyToNotEmpty() {
144:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithMultiplicity(),
145:                         TestPackage.eINSTANCE.getTableWithMultiplicity_Content(),
146:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
147:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
148:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
149:                 final TableWithMultiplicity domain = TestFactory.eINSTANCE.createTableWithMultiplicity();
150:
151:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
152:
153:                 domain.getContent().add(TestFactory.eINSTANCE.createTableContentWithoutValidation());
154:
155:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
156:
157:         }
158:
159:         @Test
160:         public void testReferenceMultiplicityDynamicNotEmptyToEmpty() {
161:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithMultiplicity(),
162:                         TestPackage.eINSTANCE.getTableWithMultiplicity_Content(),
163:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
164:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
165:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
166:                 final TableWithMultiplicity domain = TestFactory.eINSTANCE.createTableWithMultiplicity();
167:                 domain.getContent().add(TestFactory.eINSTANCE.createTableContentWithoutValidation());
168:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
169:
170:                 domain.getContent().clear();
171:                 assertEquals(Diagnostic.ERROR, table.getDiagnostic().getHighestSeverity());
172:         }
173:
174:         @Test
175:         public void testError0ChildInit() {
176:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
177:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
178:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
179:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
180:
181:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
182:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
183:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
184:
185:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
186:         }
187:
188:         @Test
189:         public void testError1ChildInit() {
190:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
191:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
192:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
193:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
194:
195:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
196:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
197:                 final TableContentWithValidation content = TestFactory.eINSTANCE.createTableContentWithValidation();
198:                 domain.getContent().add(content);
199:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
200:
201:                 assertEquals(Diagnostic.ERROR, table.getDiagnostic().getHighestSeverity());
202:         }
203:
204:         @Test
205:         public void testError1ChildDynamicDelete() {
206:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
207:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
208:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
209:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
210:
211:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
212:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
213:                 final TableContentWithValidation content = TestFactory.eINSTANCE.createTableContentWithValidation();
214:                 domain.getContent().add(content);
215:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
216:                 domain.getContent().clear();
217:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
218:         }
219:
220:         @Test
221:         public void testError1ChildDynamicSetValue() {
222:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
223:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
224:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
225:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
226:
227:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
228:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
229:                 final TableContentWithValidation content = TestFactory.eINSTANCE.createTableContentWithValidation();
230:                 domain.getContent().add(content);
231:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
232:                 content.setName("test");
233:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
234:         }
235:
236:         @Test
237:         public void test1Error1OkChildInit() {
238:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
239:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
240:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
241:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
242:
243:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
244:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
245:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
246:                 domain.getContent().add(content1);
247:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
248:                 domain.getContent().add(content2);
249:                 content2.setName("test");
250:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
251:
252:                 assertEquals(Diagnostic.ERROR, table.getDiagnostic().getHighestSeverity());
253:         }
254:
255:         @Test
256:         public void test1Ok1ErrorChildInit() {
257:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
258:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
259:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
260:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
261:
262:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
263:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
264:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
265:                 domain.getContent().add(content1);
266:                 content1.setName("test");
267:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
268:                 domain.getContent().add(content2);
269:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
270:
271:                 assertEquals(Diagnostic.ERROR, table.getDiagnostic().getHighestSeverity());
272:         }
273:
274:         @Test
275:         public void test1Error1OkChildDynamicDeleteError() {
276:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
277:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
278:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
279:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
280:
281:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
282:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
283:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
284:                 domain.getContent().add(content1);
285:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
286:                 domain.getContent().add(content2);
287:                 content2.setName("test");
288:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
289:                 domain.getContent().remove(0);
290:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
291:         }
292:
293:         @Test
294:         public void test1Ok1ErrorChildDynamicDeleteError() {
295:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
296:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
297:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
298:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
299:
300:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
301:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
302:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
303:                 domain.getContent().add(content1);
304:                 content1.setName("test");
305:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
306:                 domain.getContent().add(content2);
307:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
308:                 domain.getContent().remove(1);
309:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
310:         }
311:
312:         @Test
313:         public void test1Error1OkChildDynamicSetValueToError() {
314:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
315:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
316:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
317:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
318:
319:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
320:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
321:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
322:                 domain.getContent().add(content1);
323:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
324:                 domain.getContent().add(content2);
325:                 content2.setName("test");
326:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
327:                 content1.setName("test");
328:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
329:         }
330:
331:         @Test
332:         public void test1Ok1ErrorChildDynamicSetValueToError() {
333:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithoutMultiplicity(),
334:                         TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content(),
335:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
336:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
337:
338:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
339:                 final TableWithoutMultiplicity domain = TestFactory.eINSTANCE.createTableWithoutMultiplicity();
340:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
341:                 domain.getContent().add(content1);
342:                 content1.setName("test");
343:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
344:                 domain.getContent().add(content2);
345:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
346:                 content2.setName("test");
347:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
348:         }
349:
350:         @Test
351:         public void testUniqueInitNoError() {
352:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
353:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
354:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
355:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
356:
357:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
358:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
359:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
360:                 domain.getContent().add(content1);
361:                 content1.setName("a");
362:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
363:                 domain.getContent().add(content2);
364:                 content2.setName("b");
365:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
366:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
367:         }
368:
369:         @Test
370:         public void testUniqueInitError() {
371:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
372:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
373:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
374:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
375:
376:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
377:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
378:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
379:                 domain.getContent().add(content1);
380:                 content1.setName("a");
381:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
382:                 domain.getContent().add(content2);
383:                 content2.setName("a");
384:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
385:                 assertEquals(Diagnostic.WARNING, table.getDiagnostic().getHighestSeverity());
386:         }
387:
388:         @Test
389:         public void testUniqueDynamicAddToError() {
390:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
391:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
392:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
393:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
394:
395:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
396:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
397:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
398:                 domain.getContent().add(content1);
399:                 content1.setName("a");
400:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
401:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
402:                 domain.getContent().add(content2);
403:                 content2.setName("a");
404:                 assertEquals(Diagnostic.WARNING, table.getDiagnostic().getHighestSeverity());
405:         }
406:
407:         @Test
408:         public void testUniqueDynamicRemoveToOk() {
409:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
410:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
411:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
412:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
413:
414:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
415:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
416:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
417:                 domain.getContent().add(content1);
418:                 content1.setName("a");
419:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
420:                 domain.getContent().add(content2);
421:                 content2.setName("a");
422:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
423:                 domain.getContent().remove(content1);
424:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
425:         }
426:
427:         @Test
428:         public void testUniqueDynamicChange1ToError() {
429:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
430:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
431:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
432:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
433:
434:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
435:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
436:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
437:                 domain.getContent().add(content1);
438:                 content1.setName("a");
439:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
440:                 domain.getContent().add(content2);
441:                 content2.setName("b");
442:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
443:                 content1.setName("b");
444:                 assertEquals(Diagnostic.WARNING, table.getDiagnostic().getHighestSeverity());
445:         }
446:
447:         @Test
448:         public void testUniqueDynamicChange2ToError() {
449:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
450:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
451:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
452:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
453:
454:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
455:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
456:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
457:                 domain.getContent().add(content1);
458:                 content1.setName("a");
459:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
460:                 domain.getContent().add(content2);
461:                 content2.setName("b");
462:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
463:                 content2.setName("a");
464:                 assertEquals(Diagnostic.WARNING, table.getDiagnostic().getHighestSeverity());
465:         }
466:
467:         @Test
468:         public void testUniqueDynamicChange1ToOK() {
469:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
470:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
471:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
472:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
473:
474:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
475:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
476:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
477:                 domain.getContent().add(content1);
478:                 content1.setName("a");
479:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
480:                 domain.getContent().add(content2);
481:                 content2.setName("a");
482:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
483:                 content1.setName("b");
484:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
485:         }
486:
487:         @Test
488:         public void testUniqueDynamicChange2ToOK() {
489:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
490:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
491:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
492:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
493:
494:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
495:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
496:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
497:                 domain.getContent().add(content1);
498:                 content1.setName("a");
499:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
500:                 domain.getContent().add(content2);
501:                 content2.setName("a");
502:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
503:                 content2.setName("b");
504:                 assertEquals(Diagnostic.OK, table.getDiagnostic().getHighestSeverity());
505:         }
506:
507:         @Test
508:         public void testUniqueDynamicChange3Elements1ToError() {
509:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
510:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
511:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Name(),
512:                         TestPackage.eINSTANCE.getTableContentWithoutValidation_Weight());
513:
514:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
515:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
516:                 final TableContentWithoutValidation content1 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
517:                 domain.getContent().add(content1);
518:                 content1.setName("a");
519:                 final TableContentWithoutValidation content2 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
520:                 domain.getContent().add(content2);
521:                 content2.setName("b");
522:                 final TableContentWithoutValidation content3 = TestFactory.eINSTANCE.createTableContentWithoutValidation();
523:                 domain.getContent().add(content3);
524:                 content3.setName("b");
525:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
526:                 assertEquals(Diagnostic.WARNING, table.getDiagnostic().getHighestSeverity());
527:                 content2.setName("a");
528:                 assertEquals(Diagnostic.WARNING, table.getDiagnostic().getHighestSeverity());
529:         }
530:
531:         @Test
532:         public void testUniqueWithContentValidationInitError() {
533:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
534:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
535:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
536:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
537:
538:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
539:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
540:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
541:                 domain.getContent().add(content1);
542:                 content1.setName("a");
543:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
544:                 domain.getContent().add(content2);
545:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
546:                 assertEquals(Diagnostic.ERROR, table.getDiagnostic().getHighestSeverity());
547:         }
548:
549:         @Test
550:         public void testUniqueWithContentValidationDynamicErrorToWarning() {
551:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
552:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
553:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
554:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
555:
556:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
557:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
558:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
559:                 domain.getContent().add(content1);
560:                 content1.setName("a");
561:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
562:                 domain.getContent().add(content2);
563:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
564:                 content2.setName("a");
565:                 assertEquals(Diagnostic.WARNING, table.getDiagnostic().getHighestSeverity());
566:         }
567:
568:         @Test
569:         public void testUniqueWithContentValidationDynamicAddError() {
570:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getTableWithUnique(),
571:                         TestPackage.eINSTANCE.getTableWithUnique_Content(),
572:                         TestPackage.eINSTANCE.getTableContentWithValidation_Name(),
573:                         TestPackage.eINSTANCE.getTableContentWithValidation_Weight());
574:
575:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
576:                 final TableWithUnique domain = TestFactory.eINSTANCE.createTableWithUnique();
577:                 final TableContentWithValidation content1 = TestFactory.eINSTANCE.createTableContentWithValidation();
578:                 domain.getContent().add(content1);
579:                 content1.setName("a");
580:                 final TableContentWithValidation content2 = TestFactory.eINSTANCE.createTableContentWithValidation();
581:                 domain.getContent().add(content2);
582:                 content2.setName("b");
583:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, domain);
584:                 final TableContentWithValidation content3 = TestFactory.eINSTANCE.createTableContentWithValidation();
585:                 domain.getContent().add(content3);
586:                 content3.setName("b");
587:                 assertEquals(Diagnostic.WARNING, table.getDiagnostic().getHighestSeverity());
588:         }
589:
590:         @Test
591:         public void testChangeOfSingleContentElement() {
592:                 final VView view = createViewWithTableControl(TestPackage.eINSTANCE.getLibrary(),
593:                         TestPackage.eINSTANCE.getLibrary_Writers(), TestPackage.eINSTANCE.getWriter_FirstName());
594:                 final VTableControl table = (VTableControl) view.getChildren().get(0);
595:
596:                 final Library library = TestFactory.eINSTANCE.createLibrary();
597:                 final Writer writer1 = TestFactory.eINSTANCE.createWriter();
598:                 final Writer writer2 = TestFactory.eINSTANCE.createWriter();
599:                 library.getWriters().add(writer1);
600:                 library.getWriters().add(writer2);
601:
602:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, library);
603:
604:                 assertEquals(2, table.getDiagnostic().getDiagnostics().size());
605:
606:                 writer1.setFirstName("test");
607:
608:                 assertEquals(1, table.getDiagnostic().getDiagnostics().size());
609:         }
610:
611:         @Test
612:         public void testTableValidationWithIndirectChildren() {
613:                 final VView view = VViewFactory.eINSTANCE.createView();
614:                 view.setRootEClass(TestPackage.eINSTANCE.getTableWithoutMultiplicity());
615:                 final VTableControl tableControl = VTableFactory.eINSTANCE.createTableControl();
616:                 view.getChildren().add(tableControl);
617:                 final VTableDomainModelReference domainModelReference = VTableFactory.eINSTANCE
618:                         .createTableDomainModelReference();
619:                 tableControl.setDomainModelReference(domainModelReference);
620:                 final VFeaturePathDomainModelReference tableDMR = VViewFactory.eINSTANCE
621:                         .createFeaturePathDomainModelReference();
622:                 tableDMR.setDomainModelEFeature(TestPackage.eINSTANCE.getTableWithoutMultiplicity_Content());
623:                 domainModelReference.setDomainModelReference(tableDMR);
624:                 final VFeaturePathDomainModelReference column = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
625:
626:                 domainModelReference.getColumnDomainModelReferences().add(column);
627:                 column.getDomainModelEReferencePath().add(TestPackage.eINSTANCE.getTableContentWithInnerChild_InnerChild());
628:                 column.getDomainModelEReferencePath().add(TestPackage.eINSTANCE.getTableContentWithInnerChild2_InnerChild());
629:                 column.setDomainModelEFeature(TestPackage.eINSTANCE.getTableContentWithValidation_Name());
630:
631:                 final TableWithoutMultiplicity tableWithoutMultiplicity = TestFactory.eINSTANCE
632:                         .createTableWithoutMultiplicity();
633:                 final TableContentWithInnerChild child = TestFactory.eINSTANCE.createTableContentWithInnerChild();
634:                 tableWithoutMultiplicity.getContent().add(child);
635:                 final TableContentWithInnerChild2 innerChild = TestFactory.eINSTANCE.createTableContentWithInnerChild2();
636:                 child.setInnerChild(innerChild);
637:                 final TableContentWithValidation innerInnerChild = TestFactory.eINSTANCE.createTableContentWithValidation();
638:                 innerChild.setInnerChild(innerInnerChild);
639:
640:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, tableWithoutMultiplicity);
641:
642:                 assertEquals(1, tableControl.getDiagnostic().getDiagnostics().size());
643:                 assertEquals(Diagnostic.ERROR, tableControl.getDiagnostic().getHighestSeverity());
644:                 innerInnerChild.setName("a");
645:                 assertEquals(0, tableControl.getDiagnostic().getDiagnostics().size());
646:                 assertEquals(Diagnostic.OK, tableControl.getDiagnostic().getHighestSeverity());
647:         }
648:
649:         @Test
650:         public void testTableWithDetailValidationOnDetail() {
651:                 final VView view = VViewFactory.eINSTANCE.createView();
652:                 view.setRootEClass(TestPackage.eINSTANCE.getTableWithoutMultiplicityConcrete());
653:                 final VTableControl tableControl = VTableFactory.eINSTANCE.createTableControl();
654:                 tableControl.setDetailEditing(DetailEditing.WITH_PANEL);
655:                 view.getChildren().add(tableControl);
656:                 final VTableDomainModelReference domainModelReference = VTableFactory.eINSTANCE
657:                         .createTableDomainModelReference();
658:                 tableControl.setDomainModelReference(domainModelReference);
659:                 final VFeaturePathDomainModelReference tableDMR = VViewFactory.eINSTANCE
660:                         .createFeaturePathDomainModelReference();
661:                 tableDMR.setDomainModelEFeature(TestPackage.eINSTANCE.getTableWithoutMultiplicityConcrete_Content());
662:                 domainModelReference.setDomainModelReference(tableDMR);
663:                 final VFeaturePathDomainModelReference column = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
664:
665:                 domainModelReference.getColumnDomainModelReferences().add(column);
666:                 column.setDomainModelEFeature(TestPackage.eINSTANCE.getTableContentWithInnerChild_Stuff());
667:
668:                 final TableWithoutMultiplicityConcrete tableWithoutMultiplicity = TestFactory.eINSTANCE
669:                         .createTableWithoutMultiplicityConcrete();
670:                 final TableContentWithInnerChild child = TestFactory.eINSTANCE.createTableContentWithInnerChild();
671:                 tableWithoutMultiplicity.getContent().add(child);
672:                 final TableContentWithInnerChild2 innerChild = TestFactory.eINSTANCE.createTableContentWithInnerChild2();
673:                 child.setInnerChild(innerChild);
674:                 final TableContentWithValidation innerInnerChild = TestFactory.eINSTANCE.createTableContentWithValidation();
675:                 innerChild.setInnerChild(innerInnerChild);
676:
677:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, tableWithoutMultiplicity);
678:
679:                 // TODO the table must be rendered in order to show diagnostic, bug?
680:
681:                 assertEquals(1, tableControl.getDiagnostic().getDiagnostics().size());
682:                 assertEquals(Diagnostic.ERROR, tableControl.getDiagnostic().getHighestSeverity());
683:
684:                 // assertEquals(1, control.getDiagnostic().getDiagnostics().size());
685:                 // assertEquals(Diagnostic.ERROR, control.getDiagnostic().getHighestSeverity());
686:
687:                 innerInnerChild.setName("a");
688:                 assertEquals(0, tableControl.getDiagnostic().getDiagnostics().size());
689:                 assertEquals(Diagnostic.OK, tableControl.getDiagnostic().getHighestSeverity());
690:                 // assertEquals(0, control.getDiagnostic().getDiagnostics().size());
691:                 // assertEquals(Diagnostic.OK, control.getDiagnostic().getHighestSeverity());
692:         }
693:
694:         /**
695:          * Test that creation of a child context (as for master-detail selection)
696:          * validates only the objects presented in the child context and the chain of
697:          * parent-context views.
698:          *
699:          * @see <a href="http://eclip.se/543190">bug 543190</a>
700:          */
701:         @SuppressWarnings("unchecked")
702:         @Test
703:         public void testChildContextValidation() {
704:                 final VView view = VViewFactory.eINSTANCE.createView();
705:                 view.setRootEClass(TestPackage.Literals.TABLE_WITHOUT_MULTIPLICITY);
706:                 final VControl labelControl = VViewFactory.eINSTANCE.createControl();
707:                 labelControl.setDomainModelReference(TestPackage.Literals.TABLE_OBJECT__LABEL);
708:                 view.getChildren().add(labelControl);
709:                 final VTableControl tableControl = VTableFactory.eINSTANCE.createTableControl();
710:                 view.getChildren().add(tableControl);
711:                 final VTableDomainModelReference domainModelReference = VTableFactory.eINSTANCE
712:                         .createTableDomainModelReference();
713:                 tableControl.setDomainModelReference(domainModelReference);
714:                 final VFeaturePathDomainModelReference tableDMR = VViewFactory.eINSTANCE
715:                         .createFeaturePathDomainModelReference();
716:                 tableDMR.setDomainModelEFeature(TestPackage.Literals.TABLE_WITHOUT_MULTIPLICITY__CONTENT);
717:                 domainModelReference.setDomainModelReference(tableDMR);
718:
719:                 //
720:                 // Add a column for each object in the levels of nesting
721:                 //
722:
723:                 // The first level of nesting
724:                 VFeaturePathDomainModelReference column = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
725:                 domainModelReference.getColumnDomainModelReferences().add(column);
726:                 column.setDomainModelEFeature(TestPackage.Literals.TABLE_CONTENT_WITH_INNER_CHILD__STUFF);
727:
728:                 // The next level
729:                 column = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
730:                 domainModelReference.getColumnDomainModelReferences().add(column);
731:                 column.getDomainModelEReferencePath().add(TestPackage.Literals.TABLE_CONTENT_WITH_INNER_CHILD__INNER_CHILD);
732:                 column.setDomainModelEFeature(TestPackage.Literals.TABLE_CONTENT_WITH_INNER_CHILD__STUFF);
733:
734:                 // The deepest object
735:                 column = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
736:                 domainModelReference.getColumnDomainModelReferences().add(column);
737:                 column.getDomainModelEReferencePath().add(TestPackage.Literals.TABLE_CONTENT_WITH_INNER_CHILD__INNER_CHILD);
738:                 column.getDomainModelEReferencePath().add(TestPackage.Literals.TABLE_CONTENT_WITH_INNER_CHILD__INNER_CHILD);
739:                 column.setDomainModelEFeature(TestPackage.Literals.TABLE_CONTENT_WITH_INNER_CHILD__STUFF);
740:
741:                 final TableWithoutMultiplicity tableWithoutMultiplicity = TestFactory.eINSTANCE
742:                         .createTableWithoutMultiplicity();
743:                 tableWithoutMultiplicity.setLabel("table");
744:                 final TableContentWithInnerChild child = TestFactory.eINSTANCE.createTableContentWithInnerChild();
745:                 child.setStuff("nested 1");
746:                 tableWithoutMultiplicity.getContent().add(child);
747:                 final TableContentWithInnerChild innerChild = TestFactory.eINSTANCE.createTableContentWithInnerChild();
748:                 innerChild.setStuff("nested 2");
749:                 child.setInnerChild(innerChild);
750:                 final TableContentWithInnerChild innerInnerChild = TestFactory.eINSTANCE
751:                         .createTableContentWithInnerChild();
752:                 innerInnerChild.setStuff("deepest");
753:                 innerChild.setInnerChild(innerInnerChild);
754:
755:                 final Object user = new Object();
756:                 final ViewModelContext rootCtx = ViewModelContextFactory.INSTANCE.createViewModelContext(view,
757:                         tableWithoutMultiplicity);
758:                 rootCtx.addContextUser(user);
759:
760:                 // Add a validation provider that complains about everything in our test data
761:                 final Set<Diagnostic> validations = new LinkedHashSet<>();
762:                 final ValidationService validationService = rootCtx.getService(ValidationService.class);
763:                 validationService.addValidationProvider(new TestSwitch<List<Diagnostic>>() {
764:                         @Override
765:                         public List<Diagnostic> caseTableObject(TableObject object) {
766:                                 return Collections
767:                                         .singletonList(error(object, TestPackage.Literals.TABLE_OBJECT__LABEL, object.getLabel()));
768:                         }
769:
770:                         @Override
771:                         public List<Diagnostic> caseTableContentWithInnerChild(TableContentWithInnerChild object) {
772:                                 return Collections
773:                                         .singletonList(
774:                                                 error(object, TestPackage.Literals.TABLE_CONTENT_WITH_INNER_CHILD__STUFF, object.getStuff()));
775:                         }
776:
777:                         @Override
778:                         public List<Diagnostic> doSwitch(EObject eObject) {
779:                                 List<Diagnostic> result = super.doSwitch(eObject);
780:                                 if (result == null) {
781:                                         result = Collections.emptyList();
782:                                 } else {
783:                                         validations.addAll(result);
784:                                 }
785:                                 return result;
786:                         }
787:                 }::doSwitch);
788:
789:                 assertThat("Should have one problem for each level of the data nesting",
790:                         validations.size(), is(4));
791:                 assertThat("Wrong subject of diagnostic", validations,
792:                         hasItems(isAbout(tableWithoutMultiplicity), isAbout(child), isAbout(innerChild), isAbout(innerInnerChild)));
793:
794:                 final VView childView = VViewFactory.eINSTANCE.createView();
795:                 childView.setRootEClass(TestPackage.Literals.TABLE_CONTENT_WITHOUT_VALIDATION);
796:                 final VControl nameControl = VViewFactory.eINSTANCE.createControl();
797:                 nameControl.setDomainModelReference(TestPackage.Literals.TABLE_CONTENT_WITH_INNER_CHILD__STUFF);
798:                 childView.getChildren().add(nameControl);
799:
800:                 // Reset the validation tracking
801:                 validations.clear();
802:
803:                 final ViewModelContext childContext = rootCtx.getChildContext(innerInnerChild, view, childView);
804:                 childContext.addContextUser(user);
805:
806:                 // What did we re-validate?
807:                 assertThat("Wrong number of objects validated for child context", validations.size(), is(2));
808:                 assertThat("Child context element not validated", validations, hasItem(isAbout(innerInnerChild)));
809:                 assertThat("Parent context element not validated", validations, hasItem(isAbout(tableWithoutMultiplicity)));
810:
811:                 childContext.removeContextUser(user);
812:                 rootCtx.removeContextUser(user);
813:         }
814:
815:         static Matcher<Diagnostic> isAbout(Matcher<? super EObject> subjectMatcher) {
816:                 return new FeatureMatcher<Diagnostic, EObject>(subjectMatcher, "data[0] as EObject", "subject") {
817:                         @Override
818:                         protected EObject featureValueOf(Diagnostic actual) {
819:                                 final List<?> data = actual.getData();
820:•                                return data.isEmpty() || !(data.get(0) instanceof EObject)
821:                                         ? null
822:                                         : (EObject) data.get(0);
823:                         }
824:                 };
825:         }
826:
827:         static Matcher<Diagnostic> isAbout(EObject subject) {
828:                 return isAbout(is(subject));
829:         }
830:
831:         static Diagnostic error(EObject subject, EStructuralFeature feature, String message) {
832:                 return new BasicDiagnostic(Diagnostic.ERROR, "test", 0, message, new Object[] { subject, feature });
833:         }
834:
835: }