Skip to content

Package: ChildrenDescriptor_PTest

ChildrenDescriptor_PTest

nameinstructionbranchcomplexitylinemethod
ChildrenDescriptor_PTest()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getChildrenSize(EClass)
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%
testCompositeChildDescriptors()
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%
testCompositeCollectionDescriptors()
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%
testControlChildDescriptors()
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%
testRenderableDescriptors()
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%
testViewChildDescriptors()
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-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: * Jonas - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.model.edit.test;
15:
16: import static org.junit.Assert.assertEquals;
17:
18: import org.eclipse.emf.common.command.BasicCommandStack;
19: import org.eclipse.emf.ecore.EClass;
20: import org.eclipse.emf.ecore.EObject;
21: import org.eclipse.emf.ecore.util.EcoreUtil;
22: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
23: import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
24: import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
25: import org.junit.Test;
26:
27: public class ChildrenDescriptor_PTest {
28:
29:         /**
30:          * Needs to be adapted after refactoring
31:          * These are the counts for the core model only
32:          * If a model elements is moved out, the respective test can be removed here
33:          */
34:         private static final int DEAFULT_ATTACHMENTS = 1;
35:         private static final int RENDERABLE_CHILD_COUNT = 0 + DEAFULT_ATTACHMENTS;
36:         // control
37:         private static final int NUMBER_OF_COMPOSITES = 1;
38:
39:         private static final int VIEW_CHILD_COUNT = NUMBER_OF_COMPOSITES + RENDERABLE_CHILD_COUNT;
40:
41:         /*
42:          * Besides attachments, there is no element in the core model that should be creatable as a child because DMRs are
43:          * created via the detail view in the view model tooling.
44:          */
45:         private static final int CONTROL_CHILD_COUNT = RENDERABLE_CHILD_COUNT + 0;
46:
47:         private final AdapterFactoryEditingDomain domain = new AdapterFactoryEditingDomain(new ComposedAdapterFactory(
48:                 ComposedAdapterFactory.Descriptor.Registry.INSTANCE), new BasicCommandStack());
49:
50:         @Test
51:         public void testViewChildDescriptors() {
52:                 final int size = getChildrenSize(VViewPackage.eINSTANCE.getView());
53:                 assertEquals(VIEW_CHILD_COUNT, size);
54:         }
55:
56:         /**
57:          * Class is abstract, Exception expected
58:          */
59:         @Test(expected = IllegalArgumentException.class)
60:         public void testCompositeChildDescriptors() {
61:                 getChildrenSize(VViewPackage.eINSTANCE.getContainedElement());
62:         }
63:
64:         @Test
65:         public void testControlChildDescriptors() {
66:                 final int size = getChildrenSize(VViewPackage.eINSTANCE.getControl());
67:                 assertEquals(CONTROL_CHILD_COUNT, size);
68:         }
69:
70:         /**
71:          * Class is abstract, Exception expected
72:          */
73:         @Test(expected = IllegalArgumentException.class)
74:         public void testCompositeCollectionDescriptors() {
75:                 getChildrenSize(VViewPackage.eINSTANCE.getContainer());
76:         }
77:
78:         /**
79:          * Class is abstract, Exception expected
80:          */
81:         @Test(expected = IllegalArgumentException.class)
82:         public void testRenderableDescriptors() {
83:                 getChildrenSize(VViewPackage.eINSTANCE.getElement());
84:         }
85:
86:         /**
87:          * @param category
88:          * @return
89:          */
90:         private int getChildrenSize(EClass eClass) {
91:                 final EObject eObject = EcoreUtil.create(eClass);
92:                 return domain.getNewChildDescriptors(eObject, null).size();
93:         }
94:
95: }