Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/creation/ConnectorReadOnlyTestBug465899.java')
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/creation/ConnectorReadOnlyTestBug465899.java112
1 files changed, 70 insertions, 42 deletions
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/creation/ConnectorReadOnlyTestBug465899.java b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/creation/ConnectorReadOnlyTestBug465899.java
index 12acfd56b93..3ba9ee450f8 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/creation/ConnectorReadOnlyTestBug465899.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/creation/ConnectorReadOnlyTestBug465899.java
@@ -18,7 +18,10 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.services.edit.context.TypeContext;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
@@ -53,67 +56,92 @@ public class ConnectorReadOnlyTestBug465899 extends AbstractPapyrusTest {
@Test
public void createConnectorSourceReadOnly() throws Exception {
- Class composite = (Class) model.getModel().getOwnedType("Composite");
- Port port = Iterables.filter(composite.getAllAttributes(), Port.class).iterator().next();
- Property part = composite.getOwnedAttribute("part", null);
-
- IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.PROPERTY_PART);
- ICommand command = service.getEditCommand(new CreateRelationshipRequest(composite, port, part, UMLElementTypes.CONNECTOR));
-
- assertThat("No command provided", command, notNullValue());
- assertThat("Command not executable", command.canExecute(), is(true));
+ try {
+ Class composite = (Class) model.getModel().getOwnedType("Composite");
+ Port port = Iterables.filter(composite.getAllAttributes(), Port.class).iterator().next();
+ Property part = composite.getOwnedAttribute("part", null);
+
+ IClientContext context = TypeContext.getContext(model.getResourceSet());
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.PROPERTY_PART, context);
+ ICommand command = service.getEditCommand(new CreateRelationshipRequest(composite, port, part, UMLElementTypes.CONNECTOR));
+
+ assertThat("No command provided", command, notNullValue());
+ assertThat("Command not executable", command.canExecute(), is(true));
+ } catch (ServiceException e) {
+ System.out.println(e);
+ }
}
@Test
public void createConnectorTargetReadOnly() throws Exception {
- Class composite = (Class) model.getModel().getOwnedType("Composite");
- Port port = Iterables.filter(composite.getAllAttributes(), Port.class).iterator().next();
- Property part = composite.getOwnedAttribute("part", null);
-
- IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.PORT);
- ICommand command = service.getEditCommand(new CreateRelationshipRequest(composite, part, port, UMLElementTypes.CONNECTOR));
-
- assertThat("No command provided", command, notNullValue());
- assertThat("Command not executable", command.canExecute(), is(true));
+ try {
+ Class composite = (Class) model.getModel().getOwnedType("Composite");
+ Port port = Iterables.filter(composite.getAllAttributes(), Port.class).iterator().next();
+ Property part = composite.getOwnedAttribute("part", null);
+
+ IClientContext context = TypeContext.getContext(model.getResourceSet());
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.PORT, context);
+ ICommand command = service.getEditCommand(new CreateRelationshipRequest(composite, part, port, UMLElementTypes.CONNECTOR));
+
+ assertThat("No command provided", command, notNullValue());
+ assertThat("Command not executable", command.canExecute(), is(true));
+ } catch (ServiceException e) {
+ System.out.println(e);
+ }
}
// Association between classes, the classes owns both member ends, so they are altered.
@Test
public void createAssociationWritable() throws Exception {
- Class class1 = (Class) model.getModel().getOwnedMember("Class1");
- Class class2 = (Class) model.getModel().getOwnedMember("Class2");
-
- IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.CLASS);
- ICommand command = service.getEditCommand(new CreateRelationshipRequest(model.getModel(), class1, class2, UMLElementTypes.ASSOCIATION));
-
- assertThat("No command provided", command, notNullValue());
- assertThat("Command is executable", command.canExecute(), is(false));
+ try {
+ Class class1 = (Class) model.getModel().getOwnedMember("Class1");
+ Class class2 = (Class) model.getModel().getOwnedMember("Class2");
+
+ IClientContext context = TypeContext.getContext(model.getResourceSet());
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.CLASS, context);
+ ICommand command = service.getEditCommand(new CreateRelationshipRequest(model.getModel(), class1, class2, UMLElementTypes.ASSOCIATION));
+
+ assertThat("No command provided", command, notNullValue());
+ assertThat("Command is executable", command.canExecute(), is(false));
+ } catch (ServiceException e) {
+ System.out.println(e);
+ }
}
// Association between classes, the classes owns both member ends, so they are altered.
@Test
public void createAssociationReadOnly() throws Exception {
- Class class1 = (Class) model.getModel().getImportedMember("LibraryClass1");
- Class class2 = (Class) model.getModel().getImportedMember("LibraryClass2");
-
- IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.CLASS);
- ICommand command = service.getEditCommand(new CreateRelationshipRequest(model.getModel(), class1, class2, UMLElementTypes.ASSOCIATION));
-
- assertThat("No command provided", command, notNullValue());
- assertThat("Command is executable", command.canExecute(), is(false));
+ try {
+ Class class1 = (Class) model.getModel().getImportedMember("LibraryClass1");
+ Class class2 = (Class) model.getModel().getImportedMember("LibraryClass2");
+
+ IClientContext context = TypeContext.getContext(model.getResourceSet());
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.CLASS, context);
+ ICommand command = service.getEditCommand(new CreateRelationshipRequest(model.getModel(), class1, class2, UMLElementTypes.ASSOCIATION));
+
+ assertThat("No command provided", command, notNullValue());
+ assertThat("Command is executable", command.canExecute(), is(false));
+ } catch (ServiceException e) {
+ System.out.println(e);
+ }
}
// Association between usecase and actor owns both member ends, so does not alter the
// end types.
@Test
public void createAssociationReadOnly_usecase() throws Exception {
- UseCase usecase = (UseCase) model.getModel().getImportedMember("UseCase1");
- Actor actor = (Actor) model.getModel().getImportedMember("Actor1");
-
- IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.USE_CASE);
- ICommand command = service.getEditCommand(new CreateRelationshipRequest(model.getModel(), usecase, actor, UMLElementTypes.ASSOCIATION));
-
- assertThat("No command provided", command, notNullValue());
- assertThat("Command is not executable", command.canExecute(), is(true));
+ try {
+ UseCase usecase = (UseCase) model.getModel().getImportedMember("UseCase1");
+ Actor actor = (Actor) model.getModel().getImportedMember("Actor1");
+
+ IClientContext context = TypeContext.getContext(model.getResourceSet());
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(UMLElementTypes.USE_CASE, context);
+ ICommand command = service.getEditCommand(new CreateRelationshipRequest(model.getModel(), usecase, actor, UMLElementTypes.ASSOCIATION));
+
+ assertThat("No command provided", command, notNullValue());
+ assertThat("Command is not executable", command.canExecute(), is(true));
+ } catch (ServiceException e) {
+ System.out.println(e);
+ }
}
}

Back to the top