use of org.contextmapper.dsl.refactoring.SplitBoundedContextByOwner in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByOwnerTest method canSplitWithMultipleAggregatesPerOwner.
@Test
void canSplitWithMultipleAggregatesPerOwner() throws IOException {
// given
String inputModelName = "split-bc-by-owner-test-2-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.refactoring.SplitBoundedContextByOwner in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByOwnerTest method canSplitIfThereIsNothingToSplit.
@Test
void canSplitIfThereIsNothingToSplit() throws IOException {
// given
String inputModelName = "split-bc-by-owner-test-3-input.cml";
CMLResource input = getResourceCopyOfTestCML(inputModelName);
// when
SplitBoundedContextByOwner ar = new SplitBoundedContextByOwner("CustomerManagement");
ar.refactor(input);
// then
assertEquals(1, input.getContextMappingModel().getBoundedContexts().size());
}
use of org.contextmapper.dsl.refactoring.SplitBoundedContextByOwner 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.refactoring.SplitBoundedContextByOwner 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());
}
use of org.contextmapper.dsl.refactoring.SplitBoundedContextByOwner in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByOwnerRefactoringHandler method executeRefactoring.
@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
BoundedContext bc = (BoundedContext) getSelectedElement();
SemanticCMLRefactoring ar = new SplitBoundedContextByOwner(bc.getName());
ar.refactor(resource, getAllResources());
ar.persistChanges(serializer);
}
Aggregations