Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Koehler2019-03-20 08:01:54 +0000
committerLucas Koehler2019-04-08 07:07:32 +0000
commit4b60b9ac42d744387037075191153f8b8b54504d (patch)
treec9462fe11a4920529fcdccb9ec05bbe41945a33e /bundles
parent7852b8ebc118b7cab639150f191b55bfa9ebb41e (diff)
downloadorg.eclipse.emf.ecp.core-4b60b9ac42d744387037075191153f8b8b54504d.tar.gz
org.eclipse.emf.ecp.core-4b60b9ac42d744387037075191153f8b8b54504d.tar.xz
org.eclipse.emf.ecp.core-4b60b9ac42d744387037075191153f8b8b54504d.zip
Bug 544953 - [Segments] Add tests for CreateSegmentDmrWizard
Add test cases for the CreateSegmentDmrWizard that test its simple and advanced mode with a given root EClass. Change-Id: I13a93959c197f356ca9a3b2013f7c51d4eda65b7 Signed-off-by: Lucas Koehler <lkoehler@eclipsesource.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.editor.controls/src/org/eclipse/emf/ecp/view/internal/editor/handler/CreateSegmentDmrWizard.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.editor.controls/src/org/eclipse/emf/ecp/view/internal/editor/handler/CreateSegmentDmrWizard.java b/bundles/org.eclipse.emf.ecp.ui.view.editor.controls/src/org/eclipse/emf/ecp/view/internal/editor/handler/CreateSegmentDmrWizard.java
index fd8cfe6ca3..3c146963d5 100644
--- a/bundles/org.eclipse.emf.ecp.ui.view.editor.controls/src/org/eclipse/emf/ecp/view/internal/editor/handler/CreateSegmentDmrWizard.java
+++ b/bundles/org.eclipse.emf.ecp.ui.view.editor.controls/src/org/eclipse/emf/ecp/view/internal/editor/handler/CreateSegmentDmrWizard.java
@@ -13,11 +13,14 @@ package org.eclipse.emf.ecp.view.internal.editor.handler;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
+import java.util.stream.Collectors;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.notify.Adapter;
@@ -150,22 +153,37 @@ public class CreateSegmentDmrWizard extends Wizard {
lastSegmentTypeInfo = ""; //$NON-NLS-1$
}
+ final Collection<SegmentIdeDescriptor> descriptors = collectSegmentIdeDescriptors(ignoreSegmentIdeRestriction);
+ for (final SegmentIdeDescriptor descriptor : descriptors) {
+ segmentToIdeDescriptorMap.put(descriptor.getSegmentType(), descriptor);
+ }
+ }
+
+ /**
+ * Collect all {@link SegmentIdeDescriptor SegmentIdeDescriptors} for the advanced mode.
+ *
+ * @param ignoreSegmentIdeRestriction Whether the descriptors' availability flag must be considered when collecting
+ * the descriptors
+ * @return The collection of {@link SegmentIdeDescriptor SegmentIdeDescriptors}; might be empty but never
+ * <code>null</code>
+ * @see SegmentIdeDescriptor#isAvailableInIde()
+ */
+ protected Collection<SegmentIdeDescriptor> collectSegmentIdeDescriptors(boolean ignoreSegmentIdeRestriction) {
try {
final BundleContext bundleContext = FrameworkUtil.getBundle(CreateSegmentDmrWizard.class)
.getBundleContext();
final Collection<ServiceReference<SegmentIdeDescriptor>> references = bundleContext
.getServiceReferences(SegmentIdeDescriptor.class, null);
- for (final ServiceReference<SegmentIdeDescriptor> serviceRef : references) {
- final SegmentIdeDescriptor service = bundleContext.getService(serviceRef);
- if (ignoreSegmentIdeRestriction || service.isAvailableInIde()) {
- segmentToIdeDescriptorMap.put(service.getSegmentType(), service);
- serviceReferences.add(serviceRef);
- }
- }
+ serviceReferences.addAll(references);
+ return references.stream()
+ .map(bundleContext::getService)
+ .filter(Objects::nonNull)
+ .filter(d -> ignoreSegmentIdeRestriction || d.isAvailableInIde())
+ .collect(Collectors.toSet());
} catch (final InvalidSyntaxException ex) {
// Should never happen because no filter is used
}
-
+ return Collections.emptySet();
}
/**

Back to the top