use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByOwnerTest method canSplitByOwner.
@Test
void canSplitByOwner() throws IOException {
// given
String inputModelName = "split-bc-by-owner-test-1-input.cml";
CMLResource input = getResourceCopyOfTestCML(inputModelName);
// when
SplitBoundedContextByOwner ar = new SplitBoundedContextByOwner("CustomerManagement");
ar.refactor(input);
// then
ContextMappingModel model = input.getContextMappingModel();
assertEquals(4, model.getBoundedContexts().size());
List<String> boundedContextNames = model.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toList());
assertTrue(boundedContextNames.contains("CustomerManagement"));
assertTrue(boundedContextNames.contains("NewBoundedContext1"));
}
use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByUseCasesTest method canSplitIfThereIsNothingToSplit.
@Test
void canSplitIfThereIsNothingToSplit() throws IOException {
// given
String inputModelName = "split-bc-by-use-cases-test-3-input.cml";
CMLResource input = getResourceCopyOfTestCML(inputModelName);
// when
SplitBoundedContextByFeatures ar = new SplitBoundedContextByFeatures("CustomerManagement");
ar.refactor(input);
// then
assertEquals(1, input.getContextMappingModel().getBoundedContexts().size());
}
use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByUseCasesTest method canSplitWithSingleUseCases.
@Test
void canSplitWithSingleUseCases() throws IOException {
// given
String inputModelName = "split-bc-by-use-cases-test-1-input.cml";
CMLResource input = getResourceCopyOfTestCML(inputModelName);
// when
SplitBoundedContextByFeatures ar = new SplitBoundedContextByFeatures("CustomerManagement");
ar.refactor(input);
// then
ContextMappingModel model = input.getContextMappingModel();
assertEquals(2, model.getBoundedContexts().size());
List<String> boundedContextNames = model.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toList());
assertTrue(boundedContextNames.contains("CustomerManagement"));
assertTrue(boundedContextNames.contains("NewBoundedContext1"));
}
use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByUseCasesTest method canSplitAndFixExposedAggregatesInContextMapRelationships.
@Test
void canSplitAndFixExposedAggregatesInContextMapRelationships() throws IOException {
// given
String inputModelName = "split-bc-by-use-cases-test-4-input.cml";
CMLResource input = getResourceCopyOfTestCML(inputModelName);
// when
SplitBoundedContextByFeatures ar = new SplitBoundedContextByFeatures("CustomerManagement");
ar.refactor(input);
// then
ContextMappingModel model = input.getContextMappingModel();
assertEquals(3, model.getBoundedContexts().size());
List<String> boundedContextNames = model.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toList());
assertTrue(boundedContextNames.contains("CustomerManagement"));
assertTrue(boundedContextNames.contains("NewBoundedContext1"));
List<UpstreamDownstreamRelationship> relationships = model.getMap().getRelationships().stream().filter(rel -> rel instanceof UpstreamDownstreamRelationship).map(rel -> (UpstreamDownstreamRelationship) rel).collect(Collectors.toList());
assertEquals(2, relationships.size());
assertEquals(1, relationships.get(0).getUpstreamExposedAggregates().size());
assertEquals(1, relationships.get(1).getUpstreamExposedAggregates().size());
}
use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.
the class SplitSystemIntoSubsystemsTest method canSplitTierIfNewSystemNamesAndContextMapAlreadyExist.
@ParameterizedTest
@ValueSource(strings = { "split-system-tier-test-4" })
public void canSplitTierIfNewSystemNamesAndContextMapAlreadyExist(String testBasefileName) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML(testBasefileName + "-input.cml");
SplitSystemIntoSubsystems ar = new SplitSystemIntoSubsystems("TestBackendLogic", "TestBackendLogic", "TestBackendDatabase");
// when
ar.refactor(input);
ar.persistChanges(serializer);
// then
String dslText = FileUtils.readFileToString(new File(input.getURI().toFileString()), "UTF-8");
String expectedResult = FileUtils.readFileToString(new File(Paths.get("").toAbsolutePath().toString(), "/integ-test-files/refactorings/" + testBasefileName + "-output.cml"), Charset.forName("UTF-8"));
assertEquals(expectedResult, dslText);
}
Aggregations