use of org.contextmapper.dsl.refactoring.SplitBoundedContextByFeatures 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.refactoring.SplitBoundedContextByFeatures 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.refactoring.SplitBoundedContextByFeatures 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.refactoring.SplitBoundedContextByFeatures in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByUseCasesRefactoringHandler method executeRefactoring.
@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
BoundedContext bc = (BoundedContext) getSelectedElement();
SemanticCMLRefactoring ar = new SplitBoundedContextByFeatures(bc.getName());
ar.refactor(resource, getAllResources());
ar.persistChanges(serializer);
}
use of org.contextmapper.dsl.refactoring.SplitBoundedContextByFeatures in project context-mapper-dsl by ContextMapper.
the class SplitBoundedContextByUseCasesTest method canUpdateContextMapInDifferentFile.
@Test
void canUpdateContextMapInDifferentFile() throws IOException {
// given
CMLResource mainResource = getResourceCopyOfTestCML("split-bc-by-use-cases-test-5-input-2.cml");
ResourceSet additionalResources = getResourceSetOfTestCMLFiles("split-bc-by-use-cases-test-5-input-1.cml");
// when
SplitBoundedContextByFeatures ar = new SplitBoundedContextByFeatures("CustomerManagement");
ar.refactor(mainResource, additionalResources);
ar.persistChanges(serializer);
CMLResource contextMapResource = new CMLResource(additionalResources.getResources().stream().filter(r -> r.getURI().toString().endsWith("split-bc-by-use-cases-test-5-input-1.cml")).findFirst().get());
contextMapResource = reloadResource(contextMapResource);
// then
ContextMappingModel model = contextMapResource.getContextMappingModel();
assertEquals(2, model.getMap().getRelationships().size());
UpstreamDownstreamRelationship rel1 = (UpstreamDownstreamRelationship) model.getMap().getRelationships().get(0);
UpstreamDownstreamRelationship rel2 = (UpstreamDownstreamRelationship) model.getMap().getRelationships().get(1);
assertEquals(1, rel1.getUpstreamExposedAggregates().size());
assertEquals(1, rel2.getUpstreamExposedAggregates().size());
}
Aggregations