Skip to content

Package: ResourceSetHelpers_Test

ResourceSetHelpers_Test

nameinstructionbranchcomplexitylinemethod
ResourceSetHelpers_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%
lambda$1(Map, Map, URI)
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
not(Predicate)
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: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
testCreateResourceSet()
M: 0 C: 68
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 17
100%
M: 0 C: 1
100%

Coverage

1: package org.eclipse.emfforms.spi.editor.helpers;
2:
3: import static org.junit.Assert.assertEquals;
4: import static org.junit.Assert.assertTrue;
5:
6: import java.util.List;
7: import java.util.Map;
8: import java.util.function.Predicate;
9: import java.util.stream.Collectors;
10:
11: import org.eclipse.emf.common.command.BasicCommandStack;
12: import org.eclipse.emf.common.util.URI;
13: import org.eclipse.emf.ecore.plugin.EcorePlugin;
14: import org.eclipse.emf.ecore.resource.ResourceSet;
15: import org.eclipse.emf.ecore.xmi.XMLResource;
16: import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
17: import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
18: import org.junit.Before;
19: import org.junit.Test;
20:
21: public class ResourceSetHelpers_Test {
22:
23:         @Before
24:         public void setUp() throws Exception {
25:         }
26:
27:         public static <T> Predicate<T> not(Predicate<T> t) {
28:                 return t.negate();
29:         }
30:
31:         @Test
32:         public void testCreateResourceSet() {
33:                 ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
34:                         ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
35:                 AdapterFactoryEditingDomain editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
36:                         new BasicCommandStack());
37:                 ResourceSet rs = ResourceSetHelpers.createResourceSet(editingDomain);
38:
39:                 Map<URI, URI> uriMap = rs.getURIConverter().getURIMap();
40:                 Map<URI, URI> platformURIMap = EcorePlugin.computePlatformURIMap(true);
41:                 List<URI> listNotFoundKeys = platformURIMap.keySet().stream().filter(not(uriMap::containsKey))
42:                         .collect(Collectors.toList());
43:                 assertTrue(listNotFoundKeys.isEmpty());
44:
45:                 List<URI> listNotFoundValues = platformURIMap.keySet().stream()
46:•                        .filter(u -> uriMap.get(u) != platformURIMap.get(u)).collect(Collectors.toList());
47:                 assertTrue(listNotFoundValues.isEmpty());
48:
49:                 assertTrue(rs.getLoadOptions().containsKey(XMLResource.OPTION_DEFER_IDREF_RESOLUTION));
50:                 assertEquals(rs.getLoadOptions().get(XMLResource.OPTION_DEFER_IDREF_RESOLUTION), Boolean.TRUE);
51:
52:                 adapterFactory.dispose();
53:         }
54:
55: }