Skip to content

Package: TableColumnGenerator_Test

TableColumnGenerator_Test

nameinstructionbranchcomplexitylinemethod
TableColumnGenerator_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: 45
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
testGenerateColumns()
M: 0 C: 38
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
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: * Mat Hansen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.table.model.util;
15:
16: import static org.junit.Assert.assertEquals;
17:
18: import org.eclipse.emf.common.util.EList;
19: import org.eclipse.emf.ecore.EAttribute;
20: import org.eclipse.emf.ecore.EClass;
21: import org.eclipse.emf.ecore.EcoreFactory;
22: import org.eclipse.emf.ecore.EcorePackage;
23: import org.eclipse.emf.ecp.view.internal.table.generator.TableColumnGenerator;
24: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
25: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
26: import org.eclipse.emf.ecp.view.spi.table.model.VTableControl;
27: import org.eclipse.emf.ecp.view.spi.table.model.VTableDomainModelReference;
28: import org.eclipse.emf.ecp.view.spi.table.model.VTableFactory;
29: import org.junit.Before;
30: import org.junit.Test;
31:
32: /**
33: * @author Mat Hansen <mhansen@eclipsesource.com>
34: *
35: */
36: public class TableColumnGenerator_Test {
37:
38:         private EClass subClass;
39:         private EAttribute foo;
40:         private EAttribute bar;
41:
42:         @Before
43:         public void setUp() throws Exception {
44:                 final EClass baseClass = EcoreFactory.eINSTANCE.createEClass();
45:                 foo = EcoreFactory.eINSTANCE.createEAttribute();
46:                 foo.setEType(EcorePackage.eINSTANCE.getEString());
47:                 baseClass.getEStructuralFeatures().add(foo);
48:
49:                 subClass = EcoreFactory.eINSTANCE.createEClass();
50:                 bar = EcoreFactory.eINSTANCE.createEAttribute();
51:                 bar.setEType(EcorePackage.eINSTANCE.getEString());
52:                 subClass.getEStructuralFeatures().add(bar);
53:
54:                 subClass.getESuperTypes().add(baseClass);
55:         }
56:
57:         @Test
58:         public void testGenerateColumns() {
59:
60:                 final VTableControl control = VTableFactory.eINSTANCE.createTableControl();
61:                 final VTableDomainModelReference dmr = VTableFactory.eINSTANCE.createTableDomainModelReference();
62:                 control.setDomainModelReference(dmr);
63:                 TableColumnGenerator.generateColumns(subClass, control);
64:
65:                 final EList<VDomainModelReference> columns = dmr.getColumnDomainModelReferences();
66:
67:                 assertEquals(2, columns.size());
68:                 assertEquals(foo, ((VFeaturePathDomainModelReference) columns.get(0)).getDomainModelEFeature());
69:                 assertEquals(bar, ((VFeaturePathDomainModelReference) columns.get(1)).getDomainModelEFeature());
70:
71:         }
72:
73: }