Skip to content

Package: CategorizationCorrectTester_PTest

CategorizationCorrectTester_PTest

nameinstructionbranchcomplexitylinemethod
CategorizationCorrectTester_PTest()
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: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
testCorrectTesterForCategorizationWithDepth0()
M: 0 C: 39
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
testCorrectTesterForCategorizationWithDepth1()
M: 0 C: 39
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
testCorrectTesterForCategorizationWithDepth2()
M: 0 C: 39
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
testCorrectTesterForCompositeCategoryWithDepth0()
M: 0 C: 173
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 38
100%
M: 0 C: 1
100%
testCorrectTesterForCompositeCategoryWithDepth1()
M: 0 C: 173
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 38
100%
M: 0 C: 1
100%
testCorrectTesterForCompositeCategoryWithDepth2()
M: 0 C: 173
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 38
100%
M: 0 C: 1
100%
testCorrectTesterForCompositeCategoryWithDepth3()
M: 0 C: 173
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 38
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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: * Eugen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.categorization.swt.test;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.mockito.Mockito.mock;
18: import static org.mockito.Mockito.when;
19:
20: import org.eclipse.emf.ecp.view.internal.categorization.swt.CategorizationElementTabbedRendererService;
21: import org.eclipse.emf.ecp.view.internal.categorization.swt.CompositeCategoryJFaceTreeRendererService;
22: import org.eclipse.emf.ecp.view.internal.categorization.swt.CompositeCategorySWTTabRendererService;
23: import org.eclipse.emf.ecp.view.internal.categorization.swt.SWTCategorizationElementRendererService;
24: import org.eclipse.emf.ecp.view.internal.categorization.swt.SWTCategorizationRendererService;
25: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorization;
26: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizationElement;
27: import org.eclipse.emfforms.spi.swt.core.EMFFormsRendererService;
28: import org.junit.Before;
29: import org.junit.Test;
30:
31: /**
32: * @author Eugen
33: *
34: */
35: public class CategorizationCorrectTester_PTest {
36:
37:         /**
38:          * @throws java.lang.Exception
39:          */
40:         @Before
41:         public void setUp() throws Exception {
42:
43:         }
44:
45:         @Test
46:         public void testCorrectTesterForCategorizationWithDepth0() {
47:                 final VCategorizationElement categorizationElement = mock(VCategorizationElement.class);
48:                 when(categorizationElement.getMainCategoryDepth()).thenReturn(0);
49:                 final CategorizationElementTabbedRendererService tabTester = new CategorizationElementTabbedRendererService();
50:                 final double applicable = tabTester.isApplicable(categorizationElement, null);
51:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicable, 0d);
52:
53:                 final SWTCategorizationElementRendererService treeTester = new SWTCategorizationElementRendererService();
54:                 final double applicableTree = treeTester.isApplicable(categorizationElement, null);
55:                 assertEquals(1, applicableTree, 0d);
56:         }
57:
58:         @Test
59:         public void testCorrectTesterForCategorizationWithDepth1() {
60:                 final VCategorizationElement categorizationElement = mock(VCategorizationElement.class);
61:                 when(categorizationElement.getMainCategoryDepth()).thenReturn(1);
62:                 final CategorizationElementTabbedRendererService tabTester = new CategorizationElementTabbedRendererService();
63:                 final double applicable = tabTester.isApplicable(categorizationElement, null);
64:                 assertEquals(1, applicable, 0d);
65:
66:                 final SWTCategorizationElementRendererService treeTester = new SWTCategorizationElementRendererService();
67:                 final double applicableTree = treeTester.isApplicable(categorizationElement, null);
68:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree, 0d);
69:         }
70:
71:         @Test
72:         public void testCorrectTesterForCategorizationWithDepth2() {
73:                 final VCategorizationElement categorizationElement = mock(VCategorizationElement.class);
74:                 when(categorizationElement.getMainCategoryDepth()).thenReturn(2);
75:                 final CategorizationElementTabbedRendererService tabTester = new CategorizationElementTabbedRendererService();
76:                 final double applicable = tabTester.isApplicable(categorizationElement, null);
77:                 assertEquals(1, applicable, 0d);
78:
79:                 final SWTCategorizationElementRendererService treeTester = new SWTCategorizationElementRendererService();
80:                 final double applicableTree = treeTester.isApplicable(categorizationElement, null);
81:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree, 0d);
82:         }
83:
84:         @Test
85:         public void testCorrectTesterForCompositeCategoryWithDepth0() {
86:                 final VCategorizationElement categorizationElement = mock(VCategorizationElement.class);
87:                 when(categorizationElement.getMainCategoryDepth()).thenReturn(0);
88:                 final VCategorization categorization0 = mock(VCategorization.class);
89:                 when(categorization0.eContainer()).thenReturn(categorizationElement);
90:                 final VCategorization categorization1 = mock(VCategorization.class);
91:                 when(categorization1.eContainer()).thenReturn(categorization0);
92:                 final VCategorization categorization2 = mock(VCategorization.class);
93:                 when(categorization2.eContainer()).thenReturn(categorization1);
94:                 final VCategorization categorization3 = mock(VCategorization.class);
95:                 when(categorization3.eContainer()).thenReturn(categorization2);
96:
97:                 final SWTCategorizationRendererService defaultTester = new SWTCategorizationRendererService();
98:                 final CompositeCategorySWTTabRendererService tabTester = new CompositeCategorySWTTabRendererService();
99:                 final CompositeCategoryJFaceTreeRendererService treeTester = new CompositeCategoryJFaceTreeRendererService();
100:
101:                 final double applicable0 = defaultTester.isApplicable(categorization0, null);
102:                 assertEquals(1, applicable0, 0d);
103:
104:                 final double applicableTab0 = tabTester.isApplicable(categorization0, null);
105:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab0, 0d);
106:
107:                 final double applicableTree0 = treeTester.isApplicable(categorization0, null);
108:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree0, 0d);
109:
110:                 final double applicable1 = defaultTester.isApplicable(categorization1, null);
111:                 assertEquals(1, applicable1, 0d);
112:
113:                 final double applicableTab1 = tabTester.isApplicable(categorization1, null);
114:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab1, 0d);
115:
116:                 final double applicableTree1 = treeTester.isApplicable(categorization1, null);
117:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree1, 0d);
118:
119:                 final double applicable2 = defaultTester.isApplicable(categorization2, null);
120:                 assertEquals(1, applicable2, 0d);
121:
122:                 final double applicableTab2 = tabTester.isApplicable(categorization2, null);
123:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab2, 0d);
124:
125:                 final double applicableTree2 = treeTester.isApplicable(categorization2, null);
126:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree2, 0d);
127:
128:                 final double applicable3 = defaultTester.isApplicable(categorization3, null);
129:                 assertEquals(1, applicable3, 0d);
130:
131:                 final double applicableTab3 = tabTester.isApplicable(categorization3, null);
132:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab3, 0d);
133:
134:                 final double applicableTree3 = treeTester.isApplicable(categorization3, null);
135:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree3, 0d);
136:         }
137:
138:         @Test
139:         public void testCorrectTesterForCompositeCategoryWithDepth1() {
140:                 final VCategorizationElement categorizationElement = mock(VCategorizationElement.class);
141:                 when(categorizationElement.getMainCategoryDepth()).thenReturn(1);
142:                 final VCategorization categorization0 = mock(VCategorization.class);
143:                 when(categorization0.eContainer()).thenReturn(categorizationElement);
144:                 final VCategorization categorization1 = mock(VCategorization.class);
145:                 when(categorization1.eContainer()).thenReturn(categorization0);
146:                 final VCategorization categorization2 = mock(VCategorization.class);
147:                 when(categorization2.eContainer()).thenReturn(categorization1);
148:                 final VCategorization categorization3 = mock(VCategorization.class);
149:                 when(categorization3.eContainer()).thenReturn(categorization2);
150:
151:                 final SWTCategorizationRendererService defaultTester = new SWTCategorizationRendererService();
152:                 final CompositeCategorySWTTabRendererService tabTester = new CompositeCategorySWTTabRendererService();
153:                 final CompositeCategoryJFaceTreeRendererService treeTester = new CompositeCategoryJFaceTreeRendererService();
154:
155:                 final double applicable0 = defaultTester.isApplicable(categorization0, null);
156:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicable0, 0d);
157:
158:                 final double applicableTab0 = tabTester.isApplicable(categorization0, null);
159:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab0, 0d);
160:
161:                 final double applicableTree0 = treeTester.isApplicable(categorization0, null);
162:                 assertEquals(1, applicableTree0, 0d);
163:
164:                 final double applicable1 = defaultTester.isApplicable(categorization1, null);
165:                 assertEquals(1, applicable1, 0d);
166:
167:                 final double applicableTab1 = tabTester.isApplicable(categorization1, null);
168:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab1, 0d);
169:
170:                 final double applicableTree1 = treeTester.isApplicable(categorization1, null);
171:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree1, 0d);
172:
173:                 final double applicable2 = defaultTester.isApplicable(categorization2, null);
174:                 assertEquals(1, applicable2, 0d);
175:
176:                 final double applicableTab2 = tabTester.isApplicable(categorization2, null);
177:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab2, 0d);
178:
179:                 final double applicableTree2 = treeTester.isApplicable(categorization2, null);
180:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree2, 0d);
181:
182:                 final double applicable3 = defaultTester.isApplicable(categorization3, null);
183:                 assertEquals(1, applicable3, 0d);
184:
185:                 final double applicableTab3 = tabTester.isApplicable(categorization3, null);
186:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab3, 0d);
187:
188:                 final double applicableTree3 = treeTester.isApplicable(categorization3, null);
189:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree3, 0d);
190:         }
191:
192:         @Test
193:         public void testCorrectTesterForCompositeCategoryWithDepth2() {
194:                 final VCategorizationElement categorizationElement = mock(VCategorizationElement.class);
195:                 when(categorizationElement.getMainCategoryDepth()).thenReturn(2);
196:                 final VCategorization categorization0 = mock(VCategorization.class);
197:                 when(categorization0.eContainer()).thenReturn(categorizationElement);
198:                 final VCategorization categorization1 = mock(VCategorization.class);
199:                 when(categorization1.eContainer()).thenReturn(categorization0);
200:                 final VCategorization categorization2 = mock(VCategorization.class);
201:                 when(categorization2.eContainer()).thenReturn(categorization1);
202:                 final VCategorization categorization3 = mock(VCategorization.class);
203:                 when(categorization3.eContainer()).thenReturn(categorization2);
204:
205:                 final SWTCategorizationRendererService defaultTester = new SWTCategorizationRendererService();
206:                 final CompositeCategorySWTTabRendererService tabTester = new CompositeCategorySWTTabRendererService();
207:                 final CompositeCategoryJFaceTreeRendererService treeTester = new CompositeCategoryJFaceTreeRendererService();
208:
209:                 final double applicable0 = defaultTester.isApplicable(categorization0, null);
210:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicable0, 0d);
211:
212:                 final double applicableTab0 = tabTester.isApplicable(categorization0, null);
213:                 assertEquals(1, applicableTab0, 0d);
214:
215:                 final double applicableTree0 = treeTester.isApplicable(categorization0, null);
216:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree0, 0d);
217:
218:                 final double applicable1 = defaultTester.isApplicable(categorization1, null);
219:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicable1, 0d);
220:
221:                 final double applicableTab1 = tabTester.isApplicable(categorization1, null);
222:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab1, 0d);
223:
224:                 final double applicableTree1 = treeTester.isApplicable(categorization1, null);
225:                 assertEquals(1, applicableTree1, 0d);
226:
227:                 final double applicable2 = defaultTester.isApplicable(categorization2, null);
228:                 assertEquals(1, applicable2, 0d);
229:
230:                 final double applicableTab2 = tabTester.isApplicable(categorization2, null);
231:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab2, 0d);
232:
233:                 final double applicableTree2 = treeTester.isApplicable(categorization2, null);
234:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree2, 0d);
235:
236:                 final double applicable3 = defaultTester.isApplicable(categorization3, null);
237:                 assertEquals(1, applicable3, 0d);
238:
239:                 final double applicableTab3 = tabTester.isApplicable(categorization3, null);
240:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab3, 0d);
241:
242:                 final double applicableTree3 = treeTester.isApplicable(categorization3, null);
243:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree3, 0d);
244:         }
245:
246:         @Test
247:         public void testCorrectTesterForCompositeCategoryWithDepth3() {
248:                 final VCategorizationElement categorizationElement = mock(VCategorizationElement.class);
249:                 when(categorizationElement.getMainCategoryDepth()).thenReturn(3);
250:                 final VCategorization categorization0 = mock(VCategorization.class);
251:                 when(categorization0.eContainer()).thenReturn(categorizationElement);
252:                 final VCategorization categorization1 = mock(VCategorization.class);
253:                 when(categorization1.eContainer()).thenReturn(categorization0);
254:                 final VCategorization categorization2 = mock(VCategorization.class);
255:                 when(categorization2.eContainer()).thenReturn(categorization1);
256:                 final VCategorization categorization3 = mock(VCategorization.class);
257:                 when(categorization3.eContainer()).thenReturn(categorization2);
258:
259:                 final SWTCategorizationRendererService defaultTester = new SWTCategorizationRendererService();
260:                 final CompositeCategorySWTTabRendererService tabTester = new CompositeCategorySWTTabRendererService();
261:                 final CompositeCategoryJFaceTreeRendererService treeTester = new CompositeCategoryJFaceTreeRendererService();
262:
263:                 final double applicable0 = defaultTester.isApplicable(categorization0, null);
264:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicable0, 0d);
265:
266:                 final double applicableTab0 = tabTester.isApplicable(categorization0, null);
267:                 assertEquals(1, applicableTab0, 0d);
268:
269:                 final double applicableTree0 = treeTester.isApplicable(categorization0, null);
270:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree0, 0d);
271:
272:                 final double applicable1 = defaultTester.isApplicable(categorization1, null);
273:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicable1, 0d);
274:
275:                 final double applicableTab1 = tabTester.isApplicable(categorization1, null);
276:                 assertEquals(1, applicableTab1, 0d);
277:
278:                 final double applicableTree1 = treeTester.isApplicable(categorization1, null);
279:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree1, 0d);
280:
281:                 final double applicable2 = defaultTester.isApplicable(categorization2, null);
282:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicable2, 0d);
283:
284:                 final double applicableTab2 = tabTester.isApplicable(categorization2, null);
285:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab2, 0d);
286:
287:                 final double applicableTree2 = treeTester.isApplicable(categorization2, null);
288:                 assertEquals(1, applicableTree2, 0d);
289:
290:                 final double applicable3 = defaultTester.isApplicable(categorization3, null);
291:                 assertEquals(1, applicable3, 0d);
292:
293:                 final double applicableTab3 = tabTester.isApplicable(categorization3, null);
294:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTab3, 0d);
295:
296:                 final double applicableTree3 = treeTester.isApplicable(categorization3, null);
297:                 assertEquals(EMFFormsRendererService.NOT_APPLICABLE, applicableTree3, 0d);
298:         }
299: }