Skip to content

Package: EMFMappingValueProperty_Test

EMFMappingValueProperty_Test

nameinstructionbranchcomplexitylinemethod
EMFMappingValueProperty_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%
testDoGetValue()
M: 0 C: 29
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
testDoGetValueNoMapEntry()
M: 0 C: 19
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
testDoSetValueObjectAddEntry()
M: 0 C: 38
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 11
100%
M: 0 C: 1
100%
testDoSetValueObjectReplaceEntry()
M: 0 C: 56
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 15
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2018 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.segments.mapping;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.junit.Assert.assertNull;
18:
19: import org.eclipse.emf.common.command.BasicCommandStack;
20: import org.eclipse.emf.ecore.EClass;
21: import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
22: import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
23: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.A;
24: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.C;
25: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.TestFactory;
26: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.TestPackage;
27: import org.junit.Test;
28:
29: /**
30: * JUnit test cases for {@link EMFMappingValueProperty}.
31: *
32: * @author Lucas Koehler
33: *
34: */
35: public class EMFMappingValueProperty_Test {
36:
37:         @Test
38:         public void testDoGetValue() {
39:                 final C c = TestFactory.eINSTANCE.createC();
40:                 final EClass eClass1 = TestPackage.eINSTANCE.getB();
41:                 final A a1 = TestFactory.eINSTANCE.createA();
42:                 c.getEClassToA().put(eClass1, a1);
43:
44:                 final EMFMappingValueProperty mappingValueProperty = new EMFMappingValueProperty(null, eClass1,
45:                         TestPackage.eINSTANCE.getC_EClassToA());
46:                 assertEquals(a1, mappingValueProperty.doGetValue(c));
47:         }
48:
49:         @Test
50:         public void testDoGetValueNoMapEntry() {
51:                 final C c = TestFactory.eINSTANCE.createC();
52:                 final EClass eClass1 = TestPackage.eINSTANCE.getB();
53:
54:                 final EMFMappingValueProperty mappingValueProperty = new EMFMappingValueProperty(null, eClass1,
55:                         TestPackage.eINSTANCE.getC_EClassToA());
56:                 assertNull(mappingValueProperty.doGetValue(c));
57:         }
58:
59:         @Test
60:         public void testDoSetValueObjectReplaceEntry() {
61:                 final C c = TestFactory.eINSTANCE.createC();
62:                 final EClass eClass1 = TestPackage.eINSTANCE.getB();
63:                 final A a1 = TestFactory.eINSTANCE.createA();
64:                 final A a2 = TestFactory.eINSTANCE.createA();
65:                 a2.setB(TestFactory.eINSTANCE.createB());
66:                 c.getEClassToA().put(eClass1, a1);
67:
68:                 final AdapterFactoryEditingDomain domain = new AdapterFactoryEditingDomain(
69:                         new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE),
70:                         new BasicCommandStack());
71:
72:                 final EMFMappingValueProperty mappingValueProperty = new EMFMappingValueProperty(domain, eClass1,
73:                         TestPackage.eINSTANCE.getC_EClassToA());
74:                 assertEquals(a1, mappingValueProperty.doGetValue(c));
75:
76:                 mappingValueProperty.doSetValue(c, a2);
77:                 assertEquals(a2, mappingValueProperty.doGetValue(c));
78:         }
79:
80:         @Test
81:         public void testDoSetValueObjectAddEntry() {
82:                 final C c = TestFactory.eINSTANCE.createC();
83:                 final EClass eClass1 = TestPackage.eINSTANCE.getA();
84:                 final A a1 = TestFactory.eINSTANCE.createA();
85:                 final AdapterFactoryEditingDomain domain = new AdapterFactoryEditingDomain(
86:                         new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE),
87:                         new BasicCommandStack());
88:
89:                 final EMFMappingValueProperty mappingValueProperty = new EMFMappingValueProperty(domain, eClass1,
90:                         TestPackage.eINSTANCE.getC_EClassToA());
91:                 mappingValueProperty.doSetValue(c, a1);
92:
93:                 assertEquals(a1, mappingValueProperty.doGetValue(c));
94:         }
95: }