From 2149a12c92e119461799bd04371c4e0419595b27 Mon Sep 17 00:00:00 2001 From: Philippe DUL Date: Tue, 2 Oct 2018 11:32:16 +0200 Subject: [PATCH] [2122] Add a non-regression test on adapter factory on descriptors Bug: 2122 Change-Id: Idb37c993781ff1ead499f49d8a215427318edac0 Signed-off-by: Philippe DUL --- ...epresentationDescriptorAdapterFactory.java | 43 +++++++++++++++++++ .../ju/testsuites/PlatformTestSuite.java | 2 + 2 files changed, 45 insertions(+) create mode 100644 tests/plugins/org.polarsys.capella.test.platform.ju/src/org/polarsys/capella/test/platform/ju/testcases/InvalidRepresentationDescriptorAdapterFactory.java diff --git a/tests/plugins/org.polarsys.capella.test.platform.ju/src/org/polarsys/capella/test/platform/ju/testcases/InvalidRepresentationDescriptorAdapterFactory.java b/tests/plugins/org.polarsys.capella.test.platform.ju/src/org/polarsys/capella/test/platform/ju/testcases/InvalidRepresentationDescriptorAdapterFactory.java new file mode 100644 index 0000000000..3989fc5c65 --- /dev/null +++ b/tests/plugins/org.polarsys.capella.test.platform.ju/src/org/polarsys/capella/test/platform/ju/testcases/InvalidRepresentationDescriptorAdapterFactory.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2018 THALES GLOBAL SERVICES. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Thales - initial API and implementation + *******************************************************************************/ +package org.polarsys.capella.test.platform.ju.testcases; + +import org.eclipse.core.runtime.Adapters; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; +import org.eclipse.sirius.viewpoint.ViewpointFactory; +import org.polarsys.capella.core.data.ctx.CtxFactory; +import org.polarsys.capella.core.data.ctx.SystemAnalysis; +import org.polarsys.capella.test.framework.api.BasicTestCase; +import org.polarsys.kitalpha.emde.model.Element; + +public class InvalidRepresentationDescriptorAdapterFactory extends BasicTestCase { + + @Override + public void test() throws Exception { + + //Create a descriptor + SystemAnalysis analysis = CtxFactory.eINSTANCE.createSystemAnalysis(); + DRepresentationDescriptor descriptor = ViewpointFactory.eINSTANCE.createDRepresentationDescriptor(); + descriptor.setTarget(analysis); + + //Find an adapter. If descriptor can be adapted to its target, there is an issue. + EObject obj = Adapters.adapt(descriptor, Element.class, true); + if (obj instanceof Element) { + assertFalse( + "An adapter from 'DRepresentationDescriptor' towards 'Element' exist. " + + "It breaks menus like 'Show in Semantic Browser, Show in Diagram' as they will now also appears on descriptors. " + + "Please ensure that adapter is really wanted and fix menus in that case.", + true); + } + } + +} diff --git a/tests/plugins/org.polarsys.capella.test.platform.ju/src/org/polarsys/capella/test/platform/ju/testsuites/PlatformTestSuite.java b/tests/plugins/org.polarsys.capella.test.platform.ju/src/org/polarsys/capella/test/platform/ju/testsuites/PlatformTestSuite.java index 2c23bf1be8..9fb9b485ac 100644 --- a/tests/plugins/org.polarsys.capella.test.platform.ju/src/org/polarsys/capella/test/platform/ju/testsuites/PlatformTestSuite.java +++ b/tests/plugins/org.polarsys.capella.test.platform.ju/src/org/polarsys/capella/test/platform/ju/testsuites/PlatformTestSuite.java @@ -19,6 +19,7 @@ import org.polarsys.capella.test.platform.ju.testcases.CapellaDefaultEditorEnabled; import org.polarsys.capella.test.platform.ju.testcases.CapellaPlatformVersionNotNull; import org.polarsys.capella.test.platform.ju.testcases.CapellaSiriusCustomisationEnabled; +import org.polarsys.capella.test.platform.ju.testcases.InvalidRepresentationDescriptorAdapterFactory; import junit.framework.Test; @@ -43,6 +44,7 @@ protected List getTests() { tests.add(new CapellaSiriusCustomisationEnabled()); tests.add(new CapellaPlatformVersionNotNull()); tests.add(new CapellaDefaultEditorEnabled()); + tests.add(new InvalidRepresentationDescriptorAdapterFactory()); tests.add(new CapellaCDOGenerationOfDerivedFeature()); return tests; }