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"));
}
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));
}
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());
}
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());
}
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());
}
Aggregations