use of org.contextmapper.contextmap.generator.model.BoundedContext in project context-mapper-dsl by ContextMapper.
the class ContextMapModelConverterTest method canConvertTeamMapWithRealizingRelationships.
@Test
public void canConvertTeamMapWithRealizingRelationships() throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML("test-team-map-2.cml");
ContextMappingModel model = input.getContextMappingModel();
// when
ContextMap contextMap = new ContextMapModelConverter().convert(model.getMap());
// then
assertEquals(2, contextMap.getRelationships().size());
assertEquals(4, contextMap.getBoundedContexts().size());
BoundedContext customersTeam = contextMap.getBoundedContexts().stream().filter(bc -> bc.getName().equals("CustomersTeam")).findFirst().get();
BoundedContext contractsTeam = contextMap.getBoundedContexts().stream().filter(bc -> bc.getName().equals("ContractsTeam")).findFirst().get();
BoundedContext customerContext = contextMap.getBoundedContexts().stream().filter(bc -> bc.getName().equals("CustomerManagementContext")).findFirst().get();
BoundedContext policyContext = contextMap.getBoundedContexts().stream().filter(bc -> bc.getName().equals("PolicyManagementContext")).findFirst().get();
assertEquals(BoundedContextType.TEAM, customersTeam.getType());
assertEquals(BoundedContextType.TEAM, contractsTeam.getType());
assertEquals(BoundedContextType.GENERIC, customerContext.getType());
assertEquals(BoundedContextType.GENERIC, policyContext.getType());
assertEquals(1, customersTeam.getRealizedBoundedContexts().size());
assertEquals(1, contractsTeam.getRealizedBoundedContexts().size());
assertEquals("CustomerManagementContext", customersTeam.getRealizedBoundedContexts().iterator().next().getName());
assertEquals("PolicyManagementContext", contractsTeam.getRealizedBoundedContexts().iterator().next().getName());
}
use of org.contextmapper.contextmap.generator.model.BoundedContext in project context-mapper-dsl by ContextMapper.
the class ContextMapModelConverterTest method canConvertContextMap.
@Test
public void canConvertContextMap() throws IOException {
// given
String inputModelName = "test-context-map-1.cml";
CMLResource input = getResourceCopyOfTestCML(inputModelName);
ContextMappingModel model = input.getContextMappingModel();
// when
ContextMap contextMap = new ContextMapModelConverter().convert(model.getMap());
// then
assertEquals(6, contextMap.getBoundedContexts().size());
assertEquals(5, contextMap.getRelationships().size());
assertTrue(contextMap.getBoundedContexts().contains(new BoundedContext("CustomerManagementContext")));
assertTrue(contextMap.getBoundedContexts().contains(new BoundedContext("CustomerSelfServiceContext")));
assertTrue(contextMap.getBoundedContexts().contains(new BoundedContext("PrintingContext")));
assertTrue(contextMap.getBoundedContexts().contains(new BoundedContext("PolicyManagementContext")));
assertTrue(contextMap.getBoundedContexts().contains(new BoundedContext("RiskManagementContext")));
assertTrue(contextMap.getBoundedContexts().contains(new BoundedContext("DebtCollection")));
UpstreamDownstreamRelationship rel1 = contextMap.getRelationships().stream().filter(r -> r instanceof UpstreamDownstreamRelationship).map(r -> (UpstreamDownstreamRelationship) r).filter(r -> r.getUpstreamBoundedContext().getName().equals("CustomerManagementContext") && r.getDownstreamBoundedContext().getName().equals("CustomerSelfServiceContext")).findFirst().get();
assertNotNull(rel1);
assertTrue(rel1.isCustomerSupplier());
UpstreamDownstreamRelationship rel2 = contextMap.getRelationships().stream().filter(r -> r instanceof UpstreamDownstreamRelationship).map(r -> (UpstreamDownstreamRelationship) r).filter(r -> r.getUpstreamBoundedContext().getName().equals("PrintingContext") && r.getDownstreamBoundedContext().getName().equals("CustomerManagementContext")).findFirst().get();
assertNotNull(rel2);
assertFalse(rel2.isCustomerSupplier());
assertTrue(rel2.getUpstreamPatterns().contains(UpstreamPatterns.OPEN_HOST_SERVICE));
assertTrue(rel2.getUpstreamPatterns().contains(UpstreamPatterns.PUBLISHED_LANGUAGE));
assertTrue(rel2.getDownstreamPatterns().contains(DownstreamPatterns.ANTICORRUPTION_LAYER));
Partnership rel3 = contextMap.getRelationships().stream().filter(r -> r instanceof Partnership).map(r -> (Partnership) r).filter(r -> r.getFirstParticipant().getName().equals("RiskManagementContext") && r.getSecondParticipant().getName().equals("PolicyManagementContext")).findFirst().get();
assertNotNull(rel3);
UpstreamDownstreamRelationship rel4 = contextMap.getRelationships().stream().filter(r -> r instanceof UpstreamDownstreamRelationship).map(r -> (UpstreamDownstreamRelationship) r).filter(r -> r.getUpstreamBoundedContext().getName().equals("CustomerManagementContext") && r.getDownstreamBoundedContext().getName().equals("PolicyManagementContext")).findFirst().get();
assertNotNull(rel4);
assertFalse(rel4.isCustomerSupplier());
assertTrue(rel4.getUpstreamPatterns().contains(UpstreamPatterns.OPEN_HOST_SERVICE));
assertTrue(rel4.getDownstreamPatterns().contains(DownstreamPatterns.CONFORMIST));
SharedKernel rel5 = contextMap.getRelationships().stream().filter(r -> r instanceof SharedKernel).map(r -> (SharedKernel) r).filter(r -> r.getFirstParticipant().getName().equals("PolicyManagementContext") && r.getSecondParticipant().getName().equals("DebtCollection")).findFirst().get();
assertNotNull(rel5);
}
use of org.contextmapper.contextmap.generator.model.BoundedContext in project context-mapper-dsl by ContextMapper.
the class ContextMapModelConverter method convert.
private BoundedContext convert(org.contextmapper.dsl.contextMappingDSL.BoundedContext cmlBoundedContext) {
BoundedContextType type = BoundedContextType.GENERIC;
if (cmlBoundedContext.getType().equals(org.contextmapper.dsl.contextMappingDSL.BoundedContextType.TEAM))
type = BoundedContextType.TEAM;
BoundedContext boundedContext = new BoundedContext(cmlBoundedContext.getName(), type);
this.bcMap.put(cmlBoundedContext.getName(), boundedContext);
return boundedContext;
}
Aggregations