Skip to content

Package: EMFFormsLegacyServicesFactory_ITest

EMFFormsLegacyServicesFactory_ITest

nameinstructionbranchcomplexitylinemethod
EMFFormsLegacyServicesFactory_ITest()
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: 26
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
setUpBeforeClass()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
tearDown()
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%
testExtensionPointParsing()
M: 0 C: 95
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 27
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: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.core.services.legacy;
15:
16: import static org.junit.Assert.assertTrue;
17: import static org.mockito.Mockito.mock;
18: import static org.mockito.Mockito.times;
19: import static org.mockito.Mockito.verify;
20:
21: import org.eclipse.emf.ecp.view.spi.context.EMFFormsLegacyServicesManager;
22: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
23: import org.eclipse.emfforms.common.Optional;
24: import org.eclipse.emfforms.spi.core.services.view.EMFFormsViewServiceManager;
25: import org.junit.After;
26: import org.junit.Before;
27: import org.junit.BeforeClass;
28: import org.junit.Test;
29: import org.osgi.framework.BundleContext;
30: import org.osgi.framework.FrameworkUtil;
31: import org.osgi.framework.ServiceReference;
32:
33: public class EMFFormsLegacyServicesFactory_ITest {
34:
35:         private static BundleContext bundleContext;
36:         private ServiceReference<EMFFormsLegacyServicesManager> serviceReference;
37:
38:         private EMFFormsViewServiceManager serviceFactory;
39:         private ServiceReference<EMFFormsViewServiceManager> serviceFactoryReference;
40:
41:         @BeforeClass
42:         public static void setUpBeforeClass() {
43:                 bundleContext = FrameworkUtil.getBundle(EMFFormsLegacyServicesFactory_ITest.class)
44:                         .getBundleContext();
45:         }
46:
47:         @Before
48:         public void setUp() {
49:                 serviceReference = bundleContext.getServiceReference(EMFFormsLegacyServicesManager.class);
50:                 final EMFFormsLegacyServicesManager legacyService = bundleContext.getService(serviceReference);
51:                 legacyService.instantiate();
52:
53:                 serviceFactoryReference = bundleContext.getServiceReference(EMFFormsViewServiceManager.class);
54:                 serviceFactory = bundleContext.getService(serviceFactoryReference);
55:         }
56:
57:         @After
58:         public void tearDown() {
59:                 bundleContext.ungetService(serviceReference);
60:                 bundleContext.ungetService(serviceFactoryReference);
61:         }
62:
63:         @Test
64:         public void testExtensionPointParsing() {
65:                 final ViewModelContext viewModelContext = mock(ViewModelContext.class);
66:
67:                 final Optional<TestGlobalViewModelService> globalImmediateService = serviceFactory
68:                         .createGlobalImmediateService(TestGlobalViewModelService.class, viewModelContext);
69:                 assertTrue(globalImmediateService.isPresent());
70:
71:                 final Optional<TestLocalViewModelService> localImmediateService = serviceFactory
72:                         .createLocalImmediateService(TestLocalViewModelService.class, viewModelContext);
73:                 assertTrue(localImmediateService.isPresent());
74:
75:                 final Optional<ITestGlobalViewModelService> globalImmediateService2 = serviceFactory
76:                         .createGlobalImmediateService(ITestGlobalViewModelService.class, viewModelContext);
77:                 assertTrue(globalImmediateService2.isPresent());
78:
79:                 final Optional<ITestViewModelService> localImmediateService2 = serviceFactory
80:                         .createLocalImmediateService(ITestViewModelService.class, viewModelContext);
81:                 assertTrue(localImmediateService2.isPresent());
82:
83:                 final Optional<ITestViewModelService2> localImmediateService3 = serviceFactory
84:                         .createLocalImmediateService(ITestViewModelService2.class, viewModelContext);
85:                 assertTrue(localImmediateService3.isPresent());
86:
87:                 verify(viewModelContext, times(1)).putContextValue(TestGlobalViewModelService.class.getSimpleName(),
88:                         TestGlobalViewModelService.class);
89:                 verify(viewModelContext, times(1)).putContextValue(TestGlobalViewModelService2.class.getSimpleName(),
90:                         TestGlobalViewModelService2.class);
91:                 verify(viewModelContext, times(1)).putContextValue(TestLocalViewModelService.class.getSimpleName(),
92:                         TestLocalViewModelService.class);
93:                 verify(viewModelContext, times(1)).putContextValue(TestLocalViewModelService2.class.getSimpleName(),
94:                         TestLocalViewModelService2.class);
95:
96:                 verify(viewModelContext, times(1)).putContextValue(TestViewModelService2.class.getSimpleName(),
97:                         TestViewModelService2.class);
98:         }
99:
100: }