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());
}
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();
}
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);
}
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()));
}
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()));
}
Aggregations