Skip to content

Commit

Permalink
[2122] Add a non-regression test on adapter factory on descriptors
Browse files Browse the repository at this point in the history
Bug: 2122
Change-Id: Idb37c993781ff1ead499f49d8a215427318edac0
Signed-off-by: Philippe DUL <philippe.dul@thalesgroup.com>
  • Loading branch information
pdulth committed Oct 2, 2018
1 parent bf0fdc8 commit 2149a12
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
@@ -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);
}
}

}
Expand Up @@ -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;

Expand All @@ -43,6 +44,7 @@ protected List<BasicTestArtefact> getTests() {
tests.add(new CapellaSiriusCustomisationEnabled());
tests.add(new CapellaPlatformVersionNotNull());
tests.add(new CapellaDefaultEditorEnabled());
tests.add(new InvalidRepresentationDescriptorAdapterFactory());
tests.add(new CapellaCDOGenerationOfDerivedFeature());
return tests;
}
Expand Down

0 comments on commit 2149a12

Please sign in to comment.