use of org.contextmapper.dsl.refactoring.ExtractSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.
the class ExtractSharedKernelRefactoringTest method canCreateAggregateInNewBoundedContext.
@Test
public void canCreateAggregateInNewBoundedContext() throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML("extract-shared-kernel-test-1-input.cml");
// when
new ExtractSharedKernelRefactoring("CustomerManagement", "AnotherContext").refactor(input);
// then
ContextMap map = input.getContextMappingModel().getMap();
BoundedContext newBC = map.getBoundedContexts().stream().filter(bc -> bc.getName().equals("CustomerManagement_AnotherContext_SharedKernel")).findFirst().get();
assertEquals(1, newBC.getAggregates().size());
Aggregate aggregate = newBC.getAggregates().get(0);
assertEquals("SharedKernelAggregate", aggregate.getName());
assertEquals(1, aggregate.getDomainObjects().size());
assertEquals("SharedKernelRoot", aggregate.getDomainObjects().get(0).getName());
assertTrue(((Entity) aggregate.getDomainObjects().get(0)).isAggregateRoot());
}
use of org.contextmapper.dsl.refactoring.ExtractSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.
the class ExtractSharedKernelRefactoringTest method canCheck4NoRelationshipAvailable.
@Test
void canCheck4NoRelationshipAvailable() throws IOException {
// given
String boundedContext1 = "TestContext1";
String boundedContext2 = "TestContext2";
CMLResource input = getResourceCopyOfTestCML("extract-shared-kernel-precondition-checks-no-rel-input.cml");
// when, then
Assertions.assertThrows(RefactoringInputException.class, () -> {
new ExtractSharedKernelRefactoring(boundedContext1, boundedContext2).refactor(input);
});
}
use of org.contextmapper.dsl.refactoring.ExtractSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.
the class ExtractSharedKernelRefactoringTest method canCheck4EqualBoundedContexts.
@Test
void canCheck4EqualBoundedContexts() throws IOException {
// given
String boundedContext1 = "TestContext";
String boundedContext2 = "TestContext";
CMLResource input = getResourceCopyOfTestCML("extract-shared-kernel-precondition-checks-input.cml");
// when, then
Assertions.assertThrows(RefactoringInputException.class, () -> {
new ExtractSharedKernelRefactoring(boundedContext1, boundedContext2).refactor(input);
});
}
use of org.contextmapper.dsl.refactoring.ExtractSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.
the class ExtractSharedKernelRefactoringHandler method executeRefactoring.
@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
SharedKernel sk = (SharedKernel) getSelectedElement();
SemanticCMLRefactoring ar = new ExtractSharedKernelRefactoring(sk.getParticipant1().getName(), sk.getParticipant2().getName());
ar.refactor(resource);
ar.persistChanges(serializer);
}
use of org.contextmapper.dsl.refactoring.ExtractSharedKernelRefactoring in project context-mapper-dsl by ContextMapper.
the class ExtractSharedKernelRefactoringTest method canCheck4NullBoundedContext2.
@Test
void canCheck4NullBoundedContext2() throws IOException {
// given
String boundedContext1 = null;
String boundedContext2 = "TestContext";
CMLResource input = getResourceCopyOfTestCML("extract-shared-kernel-precondition-checks-input.cml");
// when, then
Assertions.assertThrows(RefactoringInputException.class, () -> {
new ExtractSharedKernelRefactoring(boundedContext1, boundedContext2).refactor(input);
});
}
Aggregations