Skip to content

Package: WizardNewDataTemplateCreationPage_Test

WizardNewDataTemplateCreationPage_Test

nameinstructionbranchcomplexitylinemethod
WizardNewDataTemplateCreationPage_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%
prepareClass()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setUp()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
tearDown()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
testGetInitialContents()
M: 0 C: 37
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: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.datatemplate.tooling.wizard;
15:
16: import static org.hamcrest.CoreMatchers.is;
17: import static org.hamcrest.MatcherAssert.assertThat;
18: import static org.junit.Assert.assertTrue;
19:
20: import java.io.IOException;
21: import java.io.InputStream;
22:
23: import org.eclipse.emf.common.util.URI;
24: import org.eclipse.emf.ecore.EObject;
25: import org.eclipse.emf.ecore.resource.Resource;
26: import org.eclipse.emf.ecore.resource.ResourceSet;
27: import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
28: import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
29: import org.eclipse.emfforms.datatemplate.DataTemplatePackage;
30: import org.eclipse.emfforms.datatemplate.TemplateCollection;
31: import org.eclipse.jface.viewers.StructuredSelection;
32: import org.junit.After;
33: import org.junit.Before;
34: import org.junit.BeforeClass;
35: import org.junit.Test;
36:
37: public class WizardNewDataTemplateCreationPage_Test {
38:
39:         private WizardNewDataTemplateCreationPage page;
40:
41:         @BeforeClass
42:         public static void prepareClass() {
43:                 Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); //$NON-NLS-1$
44:         }
45:
46:         @Before
47:         public void setUp() throws Exception {
48:                 page = new WizardNewDataTemplateCreationPage("test", StructuredSelection.EMPTY); //$NON-NLS-1$
49:         }
50:
51:         @After
52:         public void tearDown() throws Exception {
53:                 page.dispose();
54:         }
55:
56:         @Test
57:         public void testGetInitialContents() throws IOException {
58:                 final InputStream is = page.getInitialContents();
59:                 final ResourceSet rs = new ResourceSetImpl();
60:                 final Resource r = rs.createResource(URI.createURI("VIRTUAL")); //$NON-NLS-1$
61:                 r.load(is, null);
62:                 final EObject eObject = r.getContents().get(0);
63:                 assertThat(eObject.eClass(), is(DataTemplatePackage.eINSTANCE.getTemplateCollection()));
64:                 final TemplateCollection collection = (TemplateCollection) eObject;
65:                 assertTrue(collection.getTemplates().isEmpty());
66:         }
67:
68: }