Skip to content

Package: VTAndSelectorImpl_Test

VTAndSelectorImpl_Test

nameinstructionbranchcomplexitylinemethod
VTAndSelectorImpl_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%
allMatching()
M: 0 C: 40
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
before()
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%
createAnnotation(VElement, String, String)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
noSelectors()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
notAllMatching()
M: 0 C: 32
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
selector(String, String)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
selector(VTStyleSelector[])
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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2018 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: * Johannes Faltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.template.selector.bool.model.impl;
15:
16: import static org.junit.Assert.assertEquals;
17:
18: import java.util.Arrays;
19:
20: import org.eclipse.emf.ecp.view.spi.model.VControl;
21: import org.eclipse.emf.ecp.view.spi.model.VElement;
22: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
23: import org.eclipse.emf.ecp.view.template.model.VTStyleSelector;
24: import org.eclipse.emf.ecp.view.template.selector.annotation.model.VTAnnotationFactory;
25: import org.eclipse.emf.ecp.view.template.selector.annotation.model.VTAnnotationSelector;
26: import org.eclipse.emf.ecp.view.template.selector.bool.model.VTAndSelector;
27: import org.eclipse.emf.ecp.view.template.selector.bool.model.VTBoolFactory;
28: import org.eclipse.emf.emfforms.spi.view.annotation.model.VAnnotation;
29: import org.eclipse.emf.emfforms.spi.view.annotation.model.VAnnotationFactory;
30: import org.junit.Before;
31: import org.junit.Test;
32:
33: public class VTAndSelectorImpl_Test {
34:
35:         private static final String FOO = "FOO"; //$NON-NLS-1$
36:         private static final String BAR = "BAR"; //$NON-NLS-1$
37:
38:         private VControl control;
39:
40:         private static void createAnnotation(VElement parent, String key, String value) {
41:                 final VAnnotation annotation = VAnnotationFactory.eINSTANCE.createAnnotation();
42:                 annotation.setKey(key);
43:                 annotation.setValue(value);
44:                 parent.getAttachments().add(annotation);
45:         }
46:
47:         private static VTAnnotationSelector selector(String key, String value) {
48:                 final VTAnnotationSelector selector = VTAnnotationFactory.eINSTANCE
49:                         .createAnnotationSelector();
50:                 selector.setKey(key);
51:                 selector.setValue(value);
52:                 return selector;
53:         }
54:
55:         private static VTAndSelector selector(VTStyleSelector... selectors) {
56:                 final VTAndSelector andSelector = VTBoolFactory.eINSTANCE.createAndSelector();
57:                 andSelector.getSelectors().addAll(Arrays.asList(selectors));
58:                 return andSelector;
59:         }
60:
61:         @Before
62:         public void before() {
63:                 control = VViewFactory.eINSTANCE.createControl();
64:         }
65:
66:         @Test
67:         public void noSelectors() {
68:                 /* setup */
69:                 final VTAndSelector selector = selector();
70:
71:                 /* act */
72:                 final Double applicable = selector.isApplicable(control, null);
73:
74:                 /* assert */
75:                 assertEquals(VTStyleSelector.NOT_APPLICABLE, applicable);
76:         }
77:
78:         @Test
79:         public void notAllMatching() {
80:                 /* setup */
81:                 createAnnotation(control, FOO, BAR);
82:                 final VTAndSelector selector = selector(
83:                         selector(FOO, BAR),
84:                         selector(BAR, FOO));
85:
86:                 /* act */
87:                 final Double applicable = selector.isApplicable(control, null);
88:
89:                 /* assert */
90:                 assertEquals(VTStyleSelector.NOT_APPLICABLE, applicable);
91:         }
92:
93:         @Test
94:         public void allMatching() {
95:                 /* setup */
96:                 createAnnotation(control, FOO, BAR);
97:                 createAnnotation(control, BAR, FOO);
98:                 final VTAndSelector selector = selector(
99:                         selector(FOO, BAR),
100:                         selector(BAR, FOO));
101:
102:                 /* act */
103:                 final Double applicable = selector.isApplicable(control, null);
104:
105:                 /* assert */
106:                 assertEquals(new Double(30d), applicable);
107:         }
108:
109: }