Search in sources :

Example 21 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource 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 22 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource 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 23 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource 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 24 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource 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 25 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.

the class StandaloneAPITest method canGenerateIntoCustomDirectory.

@Test
public void canGenerateIntoCustomDirectory() {
    // given
    StandaloneContextMapperAPI contextMapper = ContextMapperStandaloneSetup.getStandaloneAPI();
    CMLResource cml = contextMapper.loadCML("./integ-test-files/standalone/simple-context-map.cml");
    File expectedOutput = new File("./out/simple-context-map_ContextMap.png");
    ensureFileDoesNotExist(expectedOutput);
    // when
    ContextMapGenerator generator = new ContextMapGenerator();
    generator.setContextMapFormats(ContextMapFormat.PNG);
    contextMapper.callGenerator(cml, generator, "./out");
    // then
    assertTrue(expectedOutput.exists());
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) File(java.io.File) ContextMapGenerator(org.contextmapper.dsl.generator.ContextMapGenerator) Test(org.junit.jupiter.api.Test)

Aggregations

CMLResource (org.contextmapper.dsl.cml.CMLResource)192 Test (org.junit.jupiter.api.Test)155 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)87 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)73 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)59 UpstreamDownstreamRelationship (org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship)48 Collectors (java.util.stream.Collectors)44 IOException (java.io.IOException)43 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)43 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)41 List (java.util.List)40 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)35 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)32 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)29 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)28 Optional (java.util.Optional)27 File (java.io.File)26 SculptorModule (org.contextmapper.dsl.contextMappingDSL.SculptorModule)22 ValueSource (org.junit.jupiter.params.provider.ValueSource)22 MergeBoundedContextsRefactoring (org.contextmapper.dsl.refactoring.MergeBoundedContextsRefactoring)14