Search in sources :

Example 1 with Partnership

use of org.contextmapper.dsl.contextMappingDSL.Partnership in project context-mapper-dsl by ContextMapper.

the class SwitchFromSharedKernelToPartnershipRefactoringTest method canSwitchFromSharedKernelToPartnership.

@Test
public void canSwitchFromSharedKernelToPartnership() throws IOException {
    // given
    CMLResource input = getResourceCopyOfTestCML("switch-from-sharedkernel-to-partnership-test-1-input.cml");
    // when
    new SwitchFromSharedKernelToPartnershipRefactoring("CustomerManagement", "AnotherContext").refactor(input);
    // then
    ContextMappingModel model = input.getContextMappingModel();
    ContextMap map = model.getMap();
    assertEquals(2, model.getBoundedContexts().size());
    assertEquals(2, map.getBoundedContexts().size());
    assertEquals(1, map.getRelationships().size());
    assertTrue(map.getRelationships().get(0) instanceof Partnership);
    Partnership partnership = (Partnership) map.getRelationships().get(0);
    assertEquals("CustomerManagement", partnership.getParticipant1().getName());
    assertEquals("AnotherContext", partnership.getParticipant2().getName());
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Partnership(org.contextmapper.dsl.contextMappingDSL.Partnership) CMLResource(org.contextmapper.dsl.cml.CMLResource) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) SwitchFromSharedKernelToPartnershipRefactoring(org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring) Test(org.junit.jupiter.api.Test)

Example 2 with Partnership

use of org.contextmapper.dsl.contextMappingDSL.Partnership in project context-mapper-dsl by ContextMapper.

the class SuspendPartnershipRefactoringHandler method executeRefactoring.

@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
    Partnership partnership = (Partnership) getSelectedElement();
    SuspendPartnershipContext refactoringContext = new SuspendPartnershipContext(partnership.getParticipant1().getName(), partnership.getParticipant2().getName());
    new WizardDialog(HandlerUtil.getActiveShell(event), new SuspendPartnershipRefactoringWizard(refactoringContext, executionContext -> {
        if (refactoringContext.getMode() == SuspendPartnershipMode.MERGE_BOUNDED_CONTEXTS) {
            // just use the 'Merge Bounded Contexts' AR in this case ...
            return finishRefactoring(new MergeBoundedContextsRefactoring(executionContext.getMergeModeSelectedBoundedContext1(), executionContext.getMergeModeSelectedBoundedContext2(), executionContext.isMergeModeTakeAttributesFromSecondBoundedContext()), resource, event);
        } else if (refactoringContext.getMode() == SuspendPartnershipMode.EXTRACT_NEW_BOUNDED_CONTEXT) {
            return finishRefactoring(new ExtractPartnershipRefactoring(refactoringContext.getBoundedContext1(), refactoringContext.getBoundedContext2()), resource, event);
        } else {
            String upstream = refactoringContext.getBoundedContext1();
            String downstream = refactoringContext.getBoundedContext2();
            if (refactoringContext.getReplaceModeUpstreamBoundedContext().equals(refactoringContext.getBoundedContext2())) {
                upstream = refactoringContext.getBoundedContext2();
                downstream = refactoringContext.getBoundedContext1();
            }
            return finishRefactoring(new ChangePartnershipToUpstreamDownstreamRefactoring(upstream, downstream), resource, event);
        }
    })).open();
}
Also used : ChangePartnershipToUpstreamDownstreamRefactoring(org.contextmapper.dsl.refactoring.ChangePartnershipToUpstreamDownstreamRefactoring) Partnership(org.contextmapper.dsl.contextMappingDSL.Partnership) SuspendPartnershipRefactoringWizard(org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipRefactoringWizard) SuspendPartnershipContext(org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipContext) WizardDialog(org.eclipse.jface.wizard.WizardDialog) MergeBoundedContextsRefactoring(org.contextmapper.dsl.refactoring.MergeBoundedContextsRefactoring) ExtractPartnershipRefactoring(org.contextmapper.dsl.refactoring.ExtractPartnershipRefactoring)

Example 3 with Partnership

use of org.contextmapper.dsl.contextMappingDSL.Partnership in project context-mapper-dsl by ContextMapper.

the class SwitchFromPartnershipToSharedKernelRefactoringHandler method executeRefactoring.

@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
    Partnership partnership = (Partnership) getSelectedElement();
    SemanticCMLRefactoring ar = new SwitchFromPartnershipToSharedKernelRefactoring(partnership.getParticipant1().getName(), partnership.getParticipant2().getName());
    ar.refactor(resource);
    ar.persistChanges(serializer);
}
Also used : Partnership(org.contextmapper.dsl.contextMappingDSL.Partnership) SemanticCMLRefactoring(org.contextmapper.dsl.refactoring.SemanticCMLRefactoring) SwitchFromPartnershipToSharedKernelRefactoring(org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring)

Example 4 with Partnership

use of org.contextmapper.dsl.contextMappingDSL.Partnership in project context-mapper-dsl by ContextMapper.

the class PlantUMLComponentDiagramCreatorTest method canCreatePartnershipRelationship.

@Test
public void canCreatePartnershipRelationship() {
    // given
    ContextMap contextMap = ContextMappingDSLFactory.eINSTANCE.createContextMap();
    BoundedContext boundedContext1 = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
    boundedContext1.setName("myContext1");
    BoundedContext boundedContext2 = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
    boundedContext2.setName("myContext2");
    contextMap.getBoundedContexts().add(boundedContext1);
    contextMap.getBoundedContexts().add(boundedContext2);
    Partnership partnership = ContextMappingDSLFactory.eINSTANCE.createPartnership();
    partnership.setParticipant1(boundedContext1);
    partnership.setParticipant2(boundedContext2);
    partnership.setImplementationTechnology("ourTechnology");
    contextMap.getRelationships().add(partnership);
    // when
    String plantUML = this.creator.createDiagram(contextMap);
    // then
    assertTrue(plantUML.contains("component [myContext1]" + System.lineSeparator()));
    assertTrue(plantUML.contains("component [myContext2]" + System.lineSeparator()));
    assertTrue(plantUML.contains("[myContext1]<-->[myContext2] : Partnership (ourTechnology)" + System.lineSeparator()));
}
Also used : Partnership(org.contextmapper.dsl.contextMappingDSL.Partnership) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) Test(org.junit.jupiter.api.Test)

Example 5 with Partnership

use of org.contextmapper.dsl.contextMappingDSL.Partnership in project context-mapper-dsl by ContextMapper.

the class PlantUMLComponentDiagramCreatorTest method canCreatePartnershipRelationshipWithName.

@Test
public void canCreatePartnershipRelationshipWithName() {
    // given
    ContextMap contextMap = ContextMappingDSLFactory.eINSTANCE.createContextMap();
    BoundedContext boundedContext1 = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
    boundedContext1.setName("myContext1");
    BoundedContext boundedContext2 = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
    boundedContext2.setName("myContext2");
    contextMap.getBoundedContexts().add(boundedContext1);
    contextMap.getBoundedContexts().add(boundedContext2);
    Partnership partnership = ContextMappingDSLFactory.eINSTANCE.createPartnership();
    partnership.setParticipant1(boundedContext1);
    partnership.setParticipant2(boundedContext2);
    partnership.setImplementationTechnology("ourTechnology");
    partnership.setName("myPartnershipTest");
    contextMap.getRelationships().add(partnership);
    // when
    String plantUML = this.creator.createDiagram(contextMap);
    // then
    assertTrue(plantUML.contains("component [myContext1]" + System.lineSeparator()));
    assertTrue(plantUML.contains("component [myContext2]" + System.lineSeparator()));
    assertTrue(plantUML.contains("[myContext1]<-->[myContext2] : myPartnershipTest (Partnership implemented with ourTechnology)" + System.lineSeparator()));
}
Also used : Partnership(org.contextmapper.dsl.contextMappingDSL.Partnership) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) Test(org.junit.jupiter.api.Test)

Aggregations

Partnership (org.contextmapper.dsl.contextMappingDSL.Partnership)7 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)3 Test (org.junit.jupiter.api.Test)3 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)2 EObject (org.eclipse.emf.ecore.EObject)2 Command (org.eclipse.lsp4j.Command)2 CMLResource (org.contextmapper.dsl.cml.CMLResource)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 ChangePartnershipToUpstreamDownstreamRefactoring (org.contextmapper.dsl.refactoring.ChangePartnershipToUpstreamDownstreamRefactoring)1 ExtractPartnershipRefactoring (org.contextmapper.dsl.refactoring.ExtractPartnershipRefactoring)1 MergeBoundedContextsRefactoring (org.contextmapper.dsl.refactoring.MergeBoundedContextsRefactoring)1 SemanticCMLRefactoring (org.contextmapper.dsl.refactoring.SemanticCMLRefactoring)1 SwitchFromPartnershipToSharedKernelRefactoring (org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring)1 SwitchFromSharedKernelToPartnershipRefactoring (org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring)1 SuspendPartnershipContext (org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipContext)1 SuspendPartnershipRefactoringWizard (org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipRefactoringWizard)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1