Skip to content

Package: EMFFormsDatabindingImpl_ITest

EMFFormsDatabindingImpl_ITest

nameinstructionbranchcomplexitylinemethod
EMFFormsDatabindingImpl_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: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
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: 2
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: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
testServiceUsageList()
M: 0 C: 61
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 12
100%
M: 0 C: 1
100%
testServiceUsageValue()
M: 0 C: 61
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 12
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;
15:
16: import static org.junit.Assert.assertTrue;
17: import static org.mockito.Matchers.any;
18: import static org.mockito.Matchers.eq;
19: import static org.mockito.Mockito.mock;
20: import static org.mockito.Mockito.verify;
21: import static org.mockito.Mockito.when;
22:
23: import org.eclipse.emf.common.util.BasicEList;
24: import org.eclipse.emf.ecore.EObject;
25: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReferenceSegment;
26: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
27: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
28: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
29: import org.eclipse.emfforms.spi.core.services.databinding.emf.DomainModelReferenceConverterEMF;
30: import org.junit.After;
31: import org.junit.Before;
32: import org.junit.BeforeClass;
33: import org.junit.Test;
34: import org.osgi.framework.BundleContext;
35: import org.osgi.framework.FrameworkUtil;
36: import org.osgi.framework.ServiceReference;
37: import org.osgi.framework.ServiceRegistration;
38:
39: /**
40: * JUnit integration test for {@link EMFFormsDatabindingImpl}.
41: *
42: * @author Lucas Koehler
43: *
44: */
45: public class EMFFormsDatabindingImpl_ITest {
46:
47:         private static BundleContext bundleContext;
48:         private EMFFormsDatabinding service;
49:         private ServiceReference<EMFFormsDatabinding> serviceReference;
50:
51:         @BeforeClass
52:         public static void setUpBeforeClass() {
53:                 bundleContext = FrameworkUtil.getBundle(EMFFormsDatabindingImpl_ITest.class).getBundleContext();
54:         }
55:
56:         @Before
57:         public void setUp() {
58:                 serviceReference = bundleContext
59:                         .getServiceReference(EMFFormsDatabinding.class);
60:                 service = bundleContext.getService(serviceReference);
61:         }
62:
63:         @After
64:         public void tearDown() {
65:                 bundleContext.ungetService(serviceReference);
66:         }
67:
68:         @Test
69:         public void testServiceType() {
70:                 assertTrue(EMFFormsDatabindingImpl.class.isInstance(service));
71:
72:         }
73:
74:         @Test
75:         public void testServiceUsageValue() throws DatabindingFailedException {
76:                 final DomainModelReferenceConverterEMF converter = mock(DomainModelReferenceConverterEMF.class);
77:                 final VFeaturePathDomainModelReference reference = mock(VFeaturePathDomainModelReference.class);
78:                 final BasicEList<VDomainModelReferenceSegment> segments = new BasicEList<VDomainModelReferenceSegment>();
79:                 when(reference.getSegments()).thenReturn(segments);
80:                 when(converter.isApplicable(reference)).thenReturn(Double.MAX_VALUE);
81:                 final ServiceRegistration<DomainModelReferenceConverterEMF> converterService = bundleContext.registerService(
82:                         DomainModelReferenceConverterEMF.class, converter, null);
83:                 service.getValueProperty(reference, mock(EObject.class));
84:                 verify(converter).isApplicable(reference);
85:                 verify(converter).convertToValueProperty(eq(reference), any(EObject.class));
86:                 converterService.unregister();
87:         }
88:
89:         @Test
90:         public void testServiceUsageList() throws DatabindingFailedException {
91:                 final DomainModelReferenceConverterEMF converter = mock(DomainModelReferenceConverterEMF.class);
92:                 final VFeaturePathDomainModelReference reference = mock(VFeaturePathDomainModelReference.class);
93:                 final BasicEList<VDomainModelReferenceSegment> segments = new BasicEList<VDomainModelReferenceSegment>();
94:                 when(reference.getSegments()).thenReturn(segments);
95:                 when(converter.isApplicable(reference)).thenReturn(Double.MAX_VALUE);
96:                 final ServiceRegistration<DomainModelReferenceConverterEMF> converterService = bundleContext.registerService(
97:                         DomainModelReferenceConverterEMF.class, converter, null);
98:                 service.getListProperty(reference, mock(EObject.class));
99:                 verify(converter).isApplicable(reference);
100:                 verify(converter).convertToListProperty(eq(reference), any(EObject.class));
101:                 converterService.unregister();
102:         }
103: }