use of org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring in project context-mapper-dsl by ContextMapper.
the class SwitchFromSharedKernelToPartnershipRefactoringTest method canCheck4MultipleSKRelationships.
@Test
void canCheck4MultipleSKRelationships() throws IOException {
// given
String boundedContext1 = "CustomerManagement";
String boundedContext2 = "AnotherContext";
CMLResource input = getResourceCopyOfTestCML("switch-from-sharedkernel-to-partnership-precondition-checks-multiple-rels-input.cml");
// when, then
Assertions.assertThrows(RefactoringInputException.class, () -> {
new SwitchFromSharedKernelToPartnershipRefactoring(boundedContext1, boundedContext2).refactor(input);
});
}
use of org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring 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.refactoring.SwitchFromSharedKernelToPartnershipRefactoring in project context-mapper-dsl by ContextMapper.
the class SwitchFromSharedKernelToPartnershipRefactoringHandler method executeRefactoring.
@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
SharedKernel sk = (SharedKernel) getSelectedElement();
SemanticCMLRefactoring ar = new SwitchFromSharedKernelToPartnershipRefactoring(sk.getParticipant1().getName(), sk.getParticipant2().getName());
ar.refactor(resource);
ar.persistChanges(serializer);
}
use of org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring in project context-mapper-dsl by ContextMapper.
the class SwitchFromSharedKernelToPartnershipRefactoringTest method canCheck4NullBoundedContext1.
@Test
void canCheck4NullBoundedContext1() throws IOException {
// given
String boundedContext1 = "TestContext";
String boundedContext2 = null;
CMLResource input = getResourceCopyOfTestCML("switch-from-sharedkernel-to-partnership-precondition-checks-input.cml");
// when, then
Assertions.assertThrows(RefactoringInputException.class, () -> {
new SwitchFromSharedKernelToPartnershipRefactoring(boundedContext1, boundedContext2).refactor(input);
});
}
use of org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring in project context-mapper-dsl by ContextMapper.
the class SwitchFromSharedKernelToPartnershipRefactoringTest method canCheck4NullBoundedContext2.
@Test
void canCheck4NullBoundedContext2() throws IOException {
// given
String boundedContext1 = null;
String boundedContext2 = "TestContext";
CMLResource input = getResourceCopyOfTestCML("switch-from-sharedkernel-to-partnership-precondition-checks-input.cml");
// when, then
Assertions.assertThrows(RefactoringInputException.class, () -> {
new SwitchFromSharedKernelToPartnershipRefactoring(boundedContext1, boundedContext2).refactor(input);
});
}
Aggregations