use of org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship in project context-mapper-dsl by ContextMapper.
the class SplitAggregateByEntitiesTest method canHandleContextMapInDifferentFile.
@Test
void canHandleContextMapInDifferentFile() throws IOException {
// given
CMLResource mainResource = getResourceCopyOfTestCML("split-agg-by-entities-test-4-input-2.cml");
ResourceSet additionalResources = getResourceSetOfTestCMLFiles("split-agg-by-entities-test-4-input-1.cml");
// when
SplitAggregateByEntitiesRefactoring ar = new SplitAggregateByEntitiesRefactoring("Customers");
ar.refactor(mainResource, additionalResources);
ar.persistChanges(serializer);
CMLResource contextMapResource = new CMLResource(additionalResources.getResources().stream().filter(r -> r.getURI().toString().endsWith("split-agg-by-entities-test-4-input-1.cml")).findFirst().get());
contextMapResource = reloadResource(contextMapResource);
// then
ContextMap contextMap = contextMapResource.getContextMappingModel().getMap();
assertEquals(2, contextMap.getBoundedContexts().size());
UpstreamDownstreamRelationship rel = (UpstreamDownstreamRelationship) contextMap.getRelationships().get(0);
assertEquals(2, rel.getUpstreamExposedAggregates().size());
}
use of org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship 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.contextMappingDSL.UpstreamDownstreamRelationship in project context-mapper-dsl by ContextMapper.
the class SplitSystemIntoSubsystemsTest method canSwitchIntegrationTypeToACL.
@Test
public void canSwitchIntegrationTypeToACL() throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML("split-system-tier-test-5-input.cml");
SplitSystemIntoSubsystems ar = new SplitSystemIntoSubsystems("TestBackend", "TestBackendLogic", "TestBackendDatabase");
ar.setIntegrationType(ACL);
// when
ar.refactor(input);
ar.persistChanges(serializer);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
assertNotNull(model.getMap());
assertEquals(1, model.getMap().getRelationships().size());
UpstreamDownstreamRelationship relationship = (UpstreamDownstreamRelationship) model.getMap().getRelationships().get(0);
assertEquals("TestBackendDatabase", relationship.getDownstream().getName());
assertEquals("TestBackendLogic", relationship.getUpstream().getName());
assertTrue(relationship.getUpstreamRoles().contains(UpstreamRole.PUBLISHED_LANGUAGE));
assertTrue(relationship.getDownstreamRoles().contains(DownstreamRole.ANTICORRUPTION_LAYER));
}
use of org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship 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.contextMappingDSL.UpstreamDownstreamRelationship in project context-mapper-dsl by ContextMapper.
the class DeriveFrontendAndBackendSystemsFromFeatureTest method canChangeDownstreamRole.
@Test
public void canChangeDownstreamRole() throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML("derive-frontend-backend-from-feature-test-1-input.cml");
DeriveFrontendAndBackendSystemsFromFeature ar = new DeriveFrontendAndBackendSystemsFromFeature("TestFeature", ACL);
// when
ar.refactor(input);
ar.persistChanges(serializer);
// then
UpstreamDownstreamRelationship relationship = (UpstreamDownstreamRelationship) reloadResource(input).getContextMappingModel().getMap().getRelationships().get(0);
assertFalse(relationship.getDownstreamRoles().contains(DownstreamRole.CONFORMIST));
assertTrue(relationship.getDownstreamRoles().contains(DownstreamRole.ANTICORRUPTION_LAYER));
}
Aggregations