use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.
the class SplitSystemIntoSubsystemsTest method canSplitTierIfNewSystemNamesAlreadyExist.
@ParameterizedTest
@ValueSource(strings = { "split-system-tier-test-3" })
public void canSplitTierIfNewSystemNamesAlreadyExist(String testBasefileName) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML(testBasefileName + "-input.cml");
SplitSystemIntoSubsystems ar = new SplitSystemIntoSubsystems("TestBackend", "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);
}
use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.
the class SplitSystemIntoSubsystemsTest method canRenameContextInRelationships.
@Test
public void canRenameContextInRelationships() throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML("split-system-tier-test-7-input.cml");
SplitSystemIntoSubsystems ar = new SplitSystemIntoSubsystems("TestBackend", "TestBackendLogic", "TestBackendDatabase");
// when
ar.refactor(input);
ar.persistChanges(serializer);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
assertEquals(3, model.getBoundedContexts().size());
assertTrue(getBoundedContextNames(model.getBoundedContexts()).contains("TestBackendLogic"));
assertFalse(getBoundedContextNames(model.getBoundedContexts()).contains("TestBackend"));
Set<String> namesOnContextMap = getBoundedContextNames(model.getMap().getBoundedContexts());
assertTrue(namesOnContextMap.contains("TestBackendLogic"));
assertFalse(namesOnContextMap.contains("TestBackend"));
UpstreamDownstreamRelationship upDownRel1 = model.getMap().getRelationships().stream().filter(r -> r.getName().equals("upDownTestRel1")).map(r -> (UpstreamDownstreamRelationship) r).findFirst().get();
UpstreamDownstreamRelationship upDownRel2 = model.getMap().getRelationships().stream().filter(r -> r.getName().equals("upDownTestRel2")).map(r -> (UpstreamDownstreamRelationship) r).findFirst().get();
SymmetricRelationship symRel1 = model.getMap().getRelationships().stream().filter(r -> r.getName().equals("symTestRel1")).map(r -> (SymmetricRelationship) r).findFirst().get();
SymmetricRelationship symRel2 = model.getMap().getRelationships().stream().filter(r -> r.getName().equals("symTestRel2")).map(r -> (SymmetricRelationship) r).findFirst().get();
assertEquals("TestBackendLogic", upDownRel1.getUpstream().getName());
assertEquals("TestBackendLogic", upDownRel2.getDownstream().getName());
assertEquals("TestBackendLogic", symRel1.getParticipant1().getName());
assertEquals("TestBackendLogic", symRel2.getParticipant2().getName());
}
use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.
the class SplitSystemIntoSubsystemsTest method canCheckIfBoundedContextNameExists.
@ParameterizedTest
@ValueSource(strings = { "SomeContextThatDoesNotExist" })
@NullSource
public void canCheckIfBoundedContextNameExists(String inputBoundedContextName) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML("split-system-tier-test-1-input.cml");
SplitSystemIntoSubsystems ar = new SplitSystemIntoSubsystems(inputBoundedContextName, "NewName4ExistingTier", "NewTierName");
// when, then
assertThrows(RefactoringInputException.class, () -> {
ar.refactor(input);
});
}
use of org.contextmapper.dsl.cml.CMLResource 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);
});
}
use of org.contextmapper.dsl.cml.CMLResource 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);
});
}
Aggregations