Search in sources :

Example 1 with SwitchFromPartnershipToSharedKernelRefactoring

use of org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.

the class SwitchFromPartnershipToSharedKernelRefactoringTest method canCheck4MultipleSKRelationships.

@Test
void canCheck4MultipleSKRelationships() throws IOException {
    // given
    String boundedContext1 = "CustomerManagement";
    String boundedContext2 = "AnotherContext";
    CMLResource input = getResourceCopyOfTestCML("switch-from-partnership-to-sharedkernel-precondition-checks-multiple-rels-input.cml");
    // when, then
    Assertions.assertThrows(RefactoringInputException.class, () -> {
        new SwitchFromPartnershipToSharedKernelRefactoring(boundedContext1, boundedContext2).refactor(input);
    });
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) SwitchFromPartnershipToSharedKernelRefactoring(org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring) Test(org.junit.jupiter.api.Test)

Example 2 with SwitchFromPartnershipToSharedKernelRefactoring

use of org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.

the class SwitchFromPartnershipToSharedKernelRefactoringTest method canCheck4NullBoundedContext2.

@Test
void canCheck4NullBoundedContext2() throws IOException {
    // given
    String boundedContext1 = null;
    String boundedContext2 = "TestContext";
    CMLResource input = getResourceCopyOfTestCML("switch-from-partnership-to-sharedkernel-precondition-checks-input.cml");
    // when, then
    Assertions.assertThrows(RefactoringInputException.class, () -> {
        new SwitchFromPartnershipToSharedKernelRefactoring(boundedContext1, boundedContext2).refactor(input);
    });
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) SwitchFromPartnershipToSharedKernelRefactoring(org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring) Test(org.junit.jupiter.api.Test)

Example 3 with SwitchFromPartnershipToSharedKernelRefactoring

use of org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.

the class SwitchFromPartnershipToSharedKernelRefactoringTest method canCheck4NoRelationshipAvailable.

@Test
void canCheck4NoRelationshipAvailable() throws IOException {
    // given
    String boundedContext1 = "TestContext1";
    String boundedContext2 = "TestContext2";
    CMLResource input = getResourceCopyOfTestCML("switch-from-partnership-to-sharedkernel-precondition-checks-no-rel-input.cml");
    // when, then
    Assertions.assertThrows(RefactoringInputException.class, () -> {
        new SwitchFromPartnershipToSharedKernelRefactoring(boundedContext1, boundedContext2).refactor(input);
    });
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) SwitchFromPartnershipToSharedKernelRefactoring(org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring) Test(org.junit.jupiter.api.Test)

Example 4 with SwitchFromPartnershipToSharedKernelRefactoring

use of org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.

the class SwitchFromPartnershipToSharedKernelRefactoringTest method canCheck4NullBoundedContext1.

@Test
void canCheck4NullBoundedContext1() throws IOException {
    // given
    String boundedContext1 = "TestContext";
    String boundedContext2 = null;
    CMLResource input = getResourceCopyOfTestCML("switch-from-partnership-to-sharedkernel-precondition-checks-input.cml");
    // when, then
    Assertions.assertThrows(RefactoringInputException.class, () -> {
        new SwitchFromPartnershipToSharedKernelRefactoring(boundedContext1, boundedContext2).refactor(input);
    });
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) SwitchFromPartnershipToSharedKernelRefactoring(org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring) Test(org.junit.jupiter.api.Test)

Example 5 with SwitchFromPartnershipToSharedKernelRefactoring

use of org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring 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)

Aggregations

SwitchFromPartnershipToSharedKernelRefactoring (org.contextmapper.dsl.refactoring.SwitchFromPartnershipToSharedKernelRefactoring)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