Skip to content

Package: EMFFormsKeyAttributeDMRExpander_Test

EMFFormsKeyAttributeDMRExpander_Test

nameinstructionbranchcomplexitylinemethod
EMFFormsKeyAttributeDMRExpander_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%
setUp()
M: 0 C: 36
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
tearDown()
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
testIsApplicable()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
testIsApplicableNull()
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
testIsApplicableWrongReferenceType()
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
testPrepareDomainObjectBothNull()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testPrepareDomainObjectObjectNull()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testPrepareDomainObjectReferenceNull()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testPrepareDomainObjectWrongReferenceType()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 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.domainexpander.keyattribute;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.mockito.Matchers.any;
18: import static org.mockito.Mockito.mock;
19: import static org.mockito.Mockito.verify;
20:
21: import org.eclipse.emf.ecore.EObject;
22: import org.eclipse.emf.ecp.view.spi.keyattributedmr.model.VKeyAttributeDomainModelReference;
23: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
24: import org.eclipse.emfforms.spi.common.report.AbstractReport;
25: import org.eclipse.emfforms.spi.common.report.ReportService;
26: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
27: import org.eclipse.emfforms.spi.core.services.domainexpander.EMFFormsDMRExpander;
28: import org.eclipse.emfforms.spi.core.services.domainexpander.EMFFormsDomainExpander;
29: import org.eclipse.emfforms.spi.core.services.domainexpander.EMFFormsExpandingFailedException;
30: import org.junit.After;
31: import org.junit.Before;
32: import org.junit.Test;
33:
34: /**
35: * JUnit test cases for {@link EMFFormsKeyAttributeDMRExpander}.
36: *
37: * @author Lucas Koehler
38: *
39: */
40: public class EMFFormsKeyAttributeDMRExpander_Test {
41:
42:         private EMFFormsKeyAttributeDMRExpander keyAttributeDMRExpander;
43:         private ReportService reportService;
44:         private EMFFormsDomainExpander domainExpander;
45:         private EMFFormsDatabinding databindingService;
46:
47:         /**
48:          * Creates a new {@link EMFFormsKeyAttributeDMRExpander} and mocks its required services for every test case.
49:          */
50:         @Before
51:         public void setUp() {
52:                 keyAttributeDMRExpander = new EMFFormsKeyAttributeDMRExpander();
53:                 reportService = mock(ReportService.class);
54:                 domainExpander = mock(EMFFormsDomainExpander.class);
55:                 databindingService = mock(EMFFormsDatabinding.class);
56:                 keyAttributeDMRExpander.setReportService(reportService);
57:                 keyAttributeDMRExpander.setEMFFormsDomainExpander(domainExpander);
58:                 keyAttributeDMRExpander.setEMFFormsDatabinding(databindingService);
59:         }
60:
61:         /**
62:          * @throws java.lang.Exception
63:          */
64:         @After
65:         public void tearDown() throws Exception {
66:                 // TODO remove?
67:         }
68:
69:         /**
70:          * Test method for
71:          * {@link org.eclipse.emfforms.internal.core.services.domainexpander.keyattribute.EMFFormsKeyAttributeDMRExpander#isApplicable(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference)}
72:          * .
73:          */
74:         @Test
75:         public void testIsApplicable() {
76:                 assertEquals(5d, keyAttributeDMRExpander.isApplicable(mock(VKeyAttributeDomainModelReference.class)), 0d);
77:         }
78:
79:         /**
80:          * Test method for
81:          * {@link org.eclipse.emfforms.internal.core.services.domainexpander.keyattribute.EMFFormsKeyAttributeDMRExpander#isApplicable(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference)}
82:          * .
83:          */
84:         @Test
85:         public void testIsApplicableNull() {
86:                 assertEquals(EMFFormsDMRExpander.NOT_APPLICABLE, keyAttributeDMRExpander.isApplicable(null), 0d);
87:                 verify(reportService).report(any(AbstractReport.class));
88:         }
89:
90:         /**
91:          * Test method for
92:          * {@link org.eclipse.emfforms.internal.core.services.domainexpander.keyattribute.EMFFormsKeyAttributeDMRExpander#isApplicable(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference)}
93:          * .
94:          */
95:         @Test()
96:         public void testIsApplicableWrongReferenceType() {
97:                 assertEquals(EMFFormsDMRExpander.NOT_APPLICABLE,
98:                         keyAttributeDMRExpander.isApplicable(mock(VFeaturePathDomainModelReference.class)), 0d);
99:         }
100:
101:         /**
102:          * Test method for
103:          * {@link org.eclipse.emfforms.internal.core.services.domainexpander.keyattribute.EMFFormsKeyAttributeDMRExpander#prepareDomainObject(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
104:          * .
105:          *
106:          * @throws EMFFormsExpandingFailedException
107:          */
108:         @Test(expected = IllegalArgumentException.class)
109:         public void testPrepareDomainObjectReferenceNull() throws EMFFormsExpandingFailedException {
110:                 keyAttributeDMRExpander.prepareDomainObject(null, mock(EObject.class));
111:         }
112:
113:         /**
114:          * Test method for
115:          * {@link org.eclipse.emfforms.internal.core.services.domainexpander.keyattribute.EMFFormsKeyAttributeDMRExpander#prepareDomainObject(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
116:          * .
117:          *
118:          * @throws EMFFormsExpandingFailedException
119:          */
120:         @Test(expected = IllegalArgumentException.class)
121:         public void testPrepareDomainObjectObjectNull() throws EMFFormsExpandingFailedException {
122:                 keyAttributeDMRExpander.prepareDomainObject(mock(VKeyAttributeDomainModelReference.class), null);
123:         }
124:
125:         /**
126:          * Test method for
127:          * {@link org.eclipse.emfforms.internal.core.services.domainexpander.keyattribute.EMFFormsKeyAttributeDMRExpander#prepareDomainObject(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
128:          * .
129:          *
130:          * @throws EMFFormsExpandingFailedException
131:          */
132:         @Test(expected = IllegalArgumentException.class)
133:         public void testPrepareDomainObjectBothNull() throws EMFFormsExpandingFailedException {
134:                 keyAttributeDMRExpander.prepareDomainObject(null, null);
135:         }
136:
137:         /**
138:          * Test method for
139:          * {@link org.eclipse.emfforms.internal.core.services.domainexpander.keyattribute.EMFFormsKeyAttributeDMRExpander#prepareDomainObject(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
140:          * .
141:          *
142:          * @throws EMFFormsExpandingFailedException
143:          */
144:         @Test(expected = IllegalArgumentException.class)
145:         public void testPrepareDomainObjectWrongReferenceType() throws EMFFormsExpandingFailedException {
146:                 keyAttributeDMRExpander.prepareDomainObject(mock(VFeaturePathDomainModelReference.class), mock(EObject.class));
147:         }
148: }