Skip to content

Package: MappingDomainModelReferenceConverter_ITest

MappingDomainModelReferenceConverter_ITest

nameinstructionbranchcomplexitylinemethod
MappingDomainModelReferenceConverter_ITest()
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%
setUp()
M: 0 C: 53
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
setUpBeforeClass()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
tearDown()
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%
testServiceType()
M: 0 C: 48
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 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.databinding.mapping;
15:
16: import static org.junit.Assert.assertTrue;
17: import static org.mockito.Matchers.any;
18: import static org.mockito.Matchers.same;
19: import static org.mockito.Mockito.mock;
20: import static org.mockito.Mockito.verify;
21: import static org.mockito.Mockito.when;
22:
23: import java.util.Dictionary;
24: import java.util.Hashtable;
25:
26: import org.eclipse.emf.databinding.IEMFValueProperty;
27: import org.eclipse.emf.ecore.EClass;
28: import org.eclipse.emf.ecore.EObject;
29: import org.eclipse.emf.ecp.view.spi.mappingdmr.model.VMappingDomainModelReference;
30: import org.eclipse.emf.ecp.view.spi.mappingdmr.model.VMappingdmrFactory;
31: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
32: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
33: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
34: import org.eclipse.emf.edit.domain.EditingDomain;
35: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.TestPackage;
36: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
37: import org.eclipse.emfforms.spi.core.services.databinding.DomainModelReferenceConverter;
38: import org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF;
39: import org.junit.After;
40: import org.junit.Before;
41: import org.junit.BeforeClass;
42: import org.junit.Test;
43: import org.osgi.framework.BundleContext;
44: import org.osgi.framework.FrameworkUtil;
45: import org.osgi.framework.ServiceReference;
46:
47: /**
48: * Integration test cases for {@link MappingDomainModelReferenceConverter}.
49: *
50: * @author Lucas Koehler
51: *
52: */
53: public class MappingDomainModelReferenceConverter_ITest {
54:
55:         private static BundleContext bundleContext;
56:         private DomainModelReferenceConverter service;
57:         private ServiceReference<DomainModelReferenceConverter> serviceReference;
58:         private EMFFormsDatabindingEMF emfFormsDatabinding;
59:
60:         @BeforeClass
61:         public static void setUpBeforeClass() {
62:                 bundleContext = FrameworkUtil.getBundle(MappingDomainModelReferenceConverter_ITest.class)
63:                         .getBundleContext();
64:         }
65:
66:         @Before
67:         public void setUp() throws DatabindingFailedException {
68:                 final Dictionary<String, Object> dictionary = new Hashtable<String, Object>();
69:                 dictionary.put("service.ranking", 50); //$NON-NLS-1$
70:                 emfFormsDatabinding = mock(EMFFormsDatabindingEMF.class);
71:                 when(emfFormsDatabinding.getValueProperty(any(VDomainModelReference.class), any(EClass.class),
72:                         any(EditingDomain.class))).thenReturn(mock(IEMFValueProperty.class));
73:                 bundleContext.registerService(EMFFormsDatabindingEMF.class, emfFormsDatabinding, dictionary);
74:                 serviceReference = bundleContext
75:                         .getServiceReference(DomainModelReferenceConverter.class);
76:                 service = bundleContext.getService(serviceReference);
77:         }
78:
79:         @After
80:         public void tearDown() {
81:                 bundleContext.ungetService(serviceReference);
82:         }
83:
84:         @Test
85:         public void testServiceType() throws DatabindingFailedException {
86:                 assertTrue(MappingDomainModelReferenceConverter.class.isInstance(service));
87:                 final MappingDomainModelReferenceConverter mappingConverter = (MappingDomainModelReferenceConverter) service;
88:
89:                 final VMappingDomainModelReference mappingReference = VMappingdmrFactory.eINSTANCE
90:                         .createMappingDomainModelReference();
91:                 mappingReference.setDomainModelEFeature(TestPackage.eINSTANCE.getC_EClassToA());
92:                 mappingReference.setMappedClass(TestPackage.Literals.B);
93:                 final VFeaturePathDomainModelReference targetReference = VViewFactory.eINSTANCE
94:                         .createFeaturePathDomainModelReference();
95:                 mappingReference.setDomainModelReference(targetReference);
96:
97:                 mappingConverter.convertToValueProperty(mappingReference, mock(EObject.class));
98:                 verify(emfFormsDatabinding).getValueProperty(same(targetReference), same(TestPackage.Literals.A),
99:                         any(EditingDomain.class));
100:
101:         }
102: }