Skip to content

Package: FeatureDmrToRootEClassConverter_Test

FeatureDmrToRootEClassConverter_Test

nameinstructionbranchcomplexitylinemethod
FeatureDmrToRootEClassConverter_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%
getRootEClass_noDomainModelEFeature()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getRootEClass_noEReferencePath()
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getRootEClass_withEReferencePath()
M: 0 C: 26
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
isApplicable_featureDmr()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
isApplicable_noFeatureDmr()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
setUp()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
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 - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.core.services.segments.featurepath;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.junit.Assert.assertSame;
18: import static org.mockito.Mockito.mock;
19:
20: import org.eclipse.emf.ecore.EClass;
21: import org.eclipse.emf.ecore.EcorePackage;
22: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
23: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
24: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
25: import org.eclipse.emfforms.spi.core.services.segments.DmrToRootEClassConverter;
26: import org.junit.Before;
27: import org.junit.Test;
28:
29: /**
30: * Unit tests for {@link FeatureDmrToRootEClassConverter}.
31: *
32: * @author Lucas Koehler
33: *
34: */
35: public class FeatureDmrToRootEClassConverter_Test {
36:
37:         private FeatureDmrToRootEClassConverter converter;
38:         private VFeaturePathDomainModelReference featureDmr;
39:
40:         @Before
41:         public void setUp() {
42:                 converter = new FeatureDmrToRootEClassConverter();
43:                 featureDmr = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
44:         }
45:
46:         @Test
47:         public void getRootEClass_withEReferencePath() {
48:                 featureDmr.getDomainModelEReferencePath().add(EcorePackage.Literals.EREFERENCE__EREFERENCE_TYPE);
49:                 featureDmr.getDomainModelEReferencePath().add(EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES);
50:                 featureDmr.setDomainModelEFeature(EcorePackage.Literals.ESTRUCTURAL_FEATURE__CHANGEABLE);
51:                 final EClass result = converter.getRootEClass(featureDmr);
52:                 assertSame(EcorePackage.Literals.EREFERENCE, result);
53:         }
54:
55:         @Test(expected = IllegalArgumentException.class)
56:         public void getRootEClass_noDomainModelEFeature() {
57:                 converter.getRootEClass(featureDmr);
58:         }
59:
60:         @Test
61:         public void getRootEClass_noEReferencePath() {
62:                 featureDmr.setDomainModelEFeature(EcorePackage.Literals.ESTRUCTURAL_FEATURE__CHANGEABLE);
63:                 final EClass result = converter.getRootEClass(featureDmr);
64:                 assertSame(EcorePackage.Literals.ESTRUCTURAL_FEATURE, result);
65:         }
66:
67:         @Test
68:         public void isApplicable_featureDmr() {
69:                 assertEquals(1d, converter.isApplicable(featureDmr), 0d);
70:         }
71:
72:         @Test
73:         public void isApplicable_noFeatureDmr() {
74:                 assertEquals(DmrToRootEClassConverter.NOT_APPLICABLE, converter.isApplicable(mock(VDomainModelReference.class)),
75:                         0d);
76:         }
77: }