Search in sources :

Example 11 with CMLResource

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

the class SplitSystemIntoSubsystemsTest method canSplitTier.

@Test
public void canSplitTier() throws IOException {
    // given
    CMLResource input = getResourceCopyOfTestCML("split-system-tier-test-1-input.cml");
    SplitSystemIntoSubsystems ar = new SplitSystemIntoSubsystems("TestBackend", "TestBackendLogic", "TestBackendDatabase");
    // when
    ar.refactor(input);
    ar.persistChanges(serializer);
    // then
    ContextMappingModel model = reloadResource(input).getContextMappingModel();
    assertEquals(2, model.getBoundedContexts().size());
    Set<String> contextNames = model.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toSet());
    assertTrue(contextNames.contains("TestBackendLogic"));
    assertTrue(contextNames.contains("TestBackendDatabase"));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) SymmetricRelationship(org.contextmapper.dsl.contextMappingDSL.SymmetricRelationship) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) CsvSource(org.junit.jupiter.params.provider.CsvSource) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UpstreamRole(org.contextmapper.dsl.contextMappingDSL.UpstreamRole) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Charset(java.nio.charset.Charset) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ACL(org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.ACL) ValueSource(org.junit.jupiter.params.provider.ValueSource) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) File(java.io.File) Test(org.junit.jupiter.api.Test) RefactoringInputException(org.contextmapper.dsl.refactoring.exception.RefactoringInputException) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Paths(java.nio.file.Paths) DownstreamRole(org.contextmapper.dsl.contextMappingDSL.DownstreamRole) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SculptorModule(org.contextmapper.dsl.contextMappingDSL.SculptorModule) NullSource(org.junit.jupiter.params.provider.NullSource) SplitBoundedContextRelationshipType(org.contextmapper.dsl.refactoring.SplitSystemIntoSubsystems.SplitBoundedContextRelationshipType) CMLResource(org.contextmapper.dsl.cml.CMLResource) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) CMLResource(org.contextmapper.dsl.cml.CMLResource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with CMLResource

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

the class SplitSystemIntoSubsystemsTest method canSwitchIntegrationTypeToACL.

@Test
public void canSwitchIntegrationTypeToACL() throws IOException {
    // given
    CMLResource input = getResourceCopyOfTestCML("split-system-tier-test-5-input.cml");
    SplitSystemIntoSubsystems ar = new SplitSystemIntoSubsystems("TestBackend", "TestBackendLogic", "TestBackendDatabase");
    ar.setIntegrationType(ACL);
    // when
    ar.refactor(input);
    ar.persistChanges(serializer);
    // then
    ContextMappingModel model = reloadResource(input).getContextMappingModel();
    assertNotNull(model.getMap());
    assertEquals(1, model.getMap().getRelationships().size());
    UpstreamDownstreamRelationship relationship = (UpstreamDownstreamRelationship) model.getMap().getRelationships().get(0);
    assertEquals("TestBackendDatabase", relationship.getDownstream().getName());
    assertEquals("TestBackendLogic", relationship.getUpstream().getName());
    assertTrue(relationship.getUpstreamRoles().contains(UpstreamRole.PUBLISHED_LANGUAGE));
    assertTrue(relationship.getDownstreamRoles().contains(DownstreamRole.ANTICORRUPTION_LAYER));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) CMLResource(org.contextmapper.dsl.cml.CMLResource) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with CMLResource

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

the class StandaloneAPITest method canLoadCMLResourceViaFile.

@Test
public void canLoadCMLResourceViaFile() {
    // given
    StandaloneContextMapperAPI contextMapper = ContextMapperStandaloneSetup.getStandaloneAPI();
    File inputFile = new File("./integ-test-files/standalone/hello-world.cml");
    // when
    CMLResource cml = contextMapper.loadCML(inputFile);
    // then
    assertNotNull(cml);
    assertEquals(1, cml.getContextMappingModel().getBoundedContexts().size());
    assertEquals("HelloWorldContext", cml.getContextMappingModel().getBoundedContexts().get(0).getName());
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 14 with CMLResource

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

the class StandaloneAPITest method canCallGenerator.

@Test
public void canCallGenerator() {
    // given
    StandaloneContextMapperAPI contextMapper = ContextMapperStandaloneSetup.getStandaloneAPI();
    CMLResource cml = contextMapper.loadCML("./integ-test-files/standalone/simple-context-map.cml");
    File expectedOutput = new File("./src-gen/simple-context-map_ContextMap.png");
    ensureFileDoesNotExist(expectedOutput);
    // when
    ContextMapGenerator generator = new ContextMapGenerator();
    generator.setContextMapFormats(ContextMapFormat.PNG);
    contextMapper.callGenerator(cml, generator);
    // 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)

Example 15 with CMLResource

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

the class StandaloneAPITest method canApplyRefactoring.

@Test
public void canApplyRefactoring() throws IOException {
    // given
    File originalFile = new File("./integ-test-files/standalone/refactoring-test.cml");
    File cmlTestFile = new File("./out/refactoring-test.cml");
    ensureFileDoesNotExist(cmlTestFile);
    FileUtils.copyFile(originalFile, cmlTestFile);
    StandaloneContextMapperAPI contextMapper = ContextMapperStandaloneSetup.getStandaloneAPI();
    CMLResource cml = contextMapper.loadCML(cmlTestFile);
    // when
    contextMapper.applyRefactoring(cml, new SplitBoundedContextByOwner("PolicyManagementContext"));
    // then
    ContextMappingModel model = cml.getContextMappingModel();
    assertEquals(10, model.getBoundedContexts().size());
    assertNotNull(model.getBoundedContexts().stream().filter(bc -> bc.getName().equals("NewBoundedContext1")).findFirst().get());
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ContextMapGenerator(org.contextmapper.dsl.generator.ContextMapGenerator) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) SaveOptions(org.eclipse.xtext.resource.SaveOptions) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) File(java.io.File) Test(org.junit.jupiter.api.Test) Charset(java.nio.charset.Charset) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SplitBoundedContextByOwner(org.contextmapper.dsl.refactoring.SplitBoundedContextByOwner) ContextMapFormat(org.contextmapper.dsl.generator.contextmap.ContextMapFormat) ContextMappingDSLFactory(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) CMLResource(org.contextmapper.dsl.cml.CMLResource) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) SplitBoundedContextByOwner(org.contextmapper.dsl.refactoring.SplitBoundedContextByOwner) CMLResource(org.contextmapper.dsl.cml.CMLResource) File(java.io.File) 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