use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.
the class SketchMinerModelCreatorTest method canAddStateTransitionCommentWithMultipleStates.
@Test
public void canAddStateTransitionCommentWithMultipleStates() throws IOException {
// given
ContextMappingModel model = getOriginalResourceOfTestCML("state-transition-comment-test-2.cml").getContextMappingModel();
Flow flow = EcoreUtil2.eAllOfType(model, Flow.class).get(0);
// when
String output = new SketchMinerModelCreator().createText(flow);
// then
assertEquals("TestContext Application:" + System.lineSeparator() + System.lineSeparator() + "(StartEvent)" + System.lineSeparator() + "// TestAggregate [STATE1, STATE2 -> STATE3 X STATE4]" + System.lineSeparator() + "service Command1" + System.lineSeparator() + "(EndEvent)" + System.lineSeparator() + System.lineSeparator(), output);
}
use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.
the class SketchMinerModelCreatorTest method canRespectOrderOfSeparateSequences.
@Test
public void canRespectOrderOfSeparateSequences() throws IOException {
// given
ContextMappingModel model = getOriginalResourceOfTestCML("order-of-separate-sequences-test-1.cml").getContextMappingModel();
Flow flow = EcoreUtil.copy(EcoreUtil2.eAllOfType(model, Flow.class).get(0));
// when
String output = new SketchMinerModelCreator().createText(flow);
// then
assertEquals("Application:" + System.lineSeparator() + System.lineSeparator() + "service appop1" + System.lineSeparator() + "(DE1)" + System.lineSeparator() + System.lineSeparator() + "service appop2" + System.lineSeparator() + "(DE2)" + System.lineSeparator() + System.lineSeparator(), output);
}
use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.
the class SketchMinerModelCreatorTest method canGenerateSimpleSequenceStartingWithCommand.
@ParameterizedTest
@ValueSource(strings = { "simple-sequence-test-1", "simple-sequence-test-2" })
public void canGenerateSimpleSequenceStartingWithCommand(String inputFileName) throws IOException {
// given
ContextMappingModel model = getOriginalResourceOfTestCML(inputFileName + ".cml").getContextMappingModel();
Flow flow = EcoreUtil2.eAllOfType(model, Flow.class).get(0);
// when
String output = new SketchMinerModelCreator().createText(flow);
// then
assertEquals("TestContext Application:" + System.lineSeparator() + System.lineSeparator() + "service StartCommand" + System.lineSeparator() + "(FirstEvent)" + System.lineSeparator() + "service EndCommand" + System.lineSeparator() + System.lineSeparator(), output);
}
use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.
the class MDSLModelCreator method createServiceSpecification.
private ServiceSpecification createServiceSpecification(String apiName, UpstreamAPIContext context) {
ServiceSpecification specification = new ServiceSpecification();
specification.setName(mdslEncoder.encodeName(apiName));
if (context.getUpstreamRoles().contains(UpstreamRole.OPEN_HOST_SERVICE) && context.getUpstreamRoles().contains(UpstreamRole.PUBLISHED_LANGUAGE)) {
specification.setUsageContext(APIUsageContext.PUBLIC_API);
} else if (context.getUpstreamRoles().contains(UpstreamRole.OPEN_HOST_SERVICE)) {
specification.setUsageContext(APIUsageContext.COMMUNITY_API);
}
if (context.getApplicationLayer() != null) {
specification.addEndpoint(createEndpoint(context.getApplicationLayer(), specification));
for (DomainEvent de : context.getApplicationLayer().getEvents()) {
specification.addEventType(de.getName());
// TODO map data structure, not just name (if present)
}
// add event types for all domain events in all exposed aggregates
for (Aggregate exposedAggregate : context.getExposedAggregates()) {
for (SimpleDomainObject objectInAggregate : exposedAggregate.getDomainObjects()) {
// check type of domain object (entity? event?...?):
if (objectInAggregate instanceof DomainEvent) {
DomainEvent de = (DomainEvent) objectInAggregate;
// TODO make sure names are unique/do not add duplicates
specification.addEventType(de.getName());
}
}
}
for (CommandEvent ce : context.getApplicationLayer().getCommands()) {
specification.addCommandType(ce.getName());
}
EList<Flow> flows = context.getApplicationLayer().getFlows();
for (Flow cmlFlow : flows) {
OrchestrationFlow mdslFlow = new OrchestrationFlow();
mdslFlow.setName(cmlFlow.getName());
for (FlowStep step : cmlFlow.getSteps()) {
mapFlowStep(mdslFlow, step);
}
specification.addFlow(mdslFlow);
}
}
for (Aggregate aggregate : context.getExposedAggregates()) {
specification.addEndpoint(createEndpoint(aggregate, specification));
}
for (DataType dataType : dataTypeCreator.getAllDataTypes()) {
specification.addDataType(dataType);
}
specification.addProvider(createProvider(context, specification.getEndpoints()));
for (DownstreamContext downstreamContext : context.getDownstreamContexts()) {
specification.addClient(createClient(downstreamContext));
}
return specification;
}
use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.
the class PlantUMLGenerator method generateFromContextMappingModel.
@Override
protected void generateFromContextMappingModel(ContextMappingModel model, IFileSystemAccess2 fsa, URI inputFileURI) {
checkPreconditions();
String fileName = inputFileURI.trimFileExtension().lastSegment();
// generate component diagram, if Context Map available
if (model.getMap() != null)
fsa.generateFile(fileName + "_ContextMap." + PLANT_UML_FILE_EXT, new PlantUMLComponentDiagramCreator().createDiagram(model.getMap()));
// generate class and state diagrams for Bounded Contexts
for (BoundedContext boundedContext : model.getBoundedContexts()) {
// class diagram for complete BC
fsa.generateFile(fileName + "_BC_" + boundedContext.getName() + "." + PLANT_UML_FILE_EXT, new PlantUMLBoundedContextClassDiagramCreator().createDiagram(boundedContext));
// class diagram for aggregates
for (Aggregate aggregate : boundedContext.getAggregates()) {
fsa.generateFile(fileName + "_BC_" + boundedContext.getName() + "_" + aggregate.getName() + "." + PLANT_UML_FILE_EXT, new PlantUMLAggregateClassDiagramCreator().createDiagram(aggregate));
}
// class diagram for modules
for (SculptorModule module : boundedContext.getModules()) {
fsa.generateFile(fileName + "_BC_" + boundedContext.getName() + "_" + module.getName() + "." + PLANT_UML_FILE_EXT, new PlantUMLModuleClassDiagramCreator().createDiagram(module));
}
// state diagram for aggregates
List<Aggregate> aggregatesWithStates = getAggregatesWithStatesAndTransitions(boundedContext);
for (Aggregate aggregate : aggregatesWithStates) {
fsa.generateFile(fileName + "_BC_" + boundedContext.getName() + "_" + aggregate.getName() + "_StateDiagram" + "." + PLANT_UML_FILE_EXT, new PlantUMLStateDiagramCreator4Aggregate().createDiagram(aggregate));
}
// state diagram for flows
for (Flow flow : getFlowsWithStates(boundedContext)) {
fsa.generateFile(fileName + "_BC_" + boundedContext.getName() + "_" + flow.getName() + "_StateDiagram." + PLANT_UML_FILE_EXT, new PlantUMLStateDiagramCreator4Flow().createDiagram(flow));
}
}
// generate class diagrams for subdomains (that have entities)
for (Domain domain : model.getDomains()) {
domain.getSubdomains().stream().filter(subdomain -> !subdomain.getEntities().isEmpty()).forEach(subdomain -> {
fsa.generateFile(fileName + "_SD_" + subdomain.getName() + "." + PLANT_UML_FILE_EXT, new PlantUMLSubdomainClassDiagramCreator(domain.getName()).createDiagram(subdomain));
});
}
}
Aggregations