Search in sources :

Example 1 with SwitchFromSharedKernelToPartnershipRefactoring

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);
    });
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) SwitchFromSharedKernelToPartnershipRefactoring(org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring) Test(org.junit.jupiter.api.Test)

Example 2 with SwitchFromSharedKernelToPartnershipRefactoring

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());
}
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 3 with SwitchFromSharedKernelToPartnershipRefactoring

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);
}
Also used : SemanticCMLRefactoring(org.contextmapper.dsl.refactoring.SemanticCMLRefactoring) SharedKernel(org.contextmapper.dsl.contextMappingDSL.SharedKernel) SwitchFromSharedKernelToPartnershipRefactoring(org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring)

Example 4 with SwitchFromSharedKernelToPartnershipRefactoring

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);
    });
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) SwitchFromSharedKernelToPartnershipRefactoring(org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring) Test(org.junit.jupiter.api.Test)

Example 5 with SwitchFromSharedKernelToPartnershipRefactoring

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);
    });
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) SwitchFromSharedKernelToPartnershipRefactoring(org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring) Test(org.junit.jupiter.api.Test)

Aggregations

SwitchFromSharedKernelToPartnershipRefactoring (org.contextmapper.dsl.refactoring.SwitchFromSharedKernelToPartnershipRefactoring)8 CMLResource (org.contextmapper.dsl.cml.CMLResource)6 Test (org.junit.jupiter.api.Test)6 JsonPrimitive (com.google.gson.JsonPrimitive)1 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 Partnership (org.contextmapper.dsl.contextMappingDSL.Partnership)1 SharedKernel (org.contextmapper.dsl.contextMappingDSL.SharedKernel)1 SemanticCMLRefactoring (org.contextmapper.dsl.refactoring.SemanticCMLRefactoring)1