use of org.contextmapper.dsl.generator.plantuml.PlantUMLStateDiagramCreator4Aggregate in project context-mapper-dsl by ContextMapper.
the class PlantUMLStateDiagramCreatorTest method canCreateStateDiagram4AggregateViaEntity.
@Test
public void canCreateStateDiagram4AggregateViaEntity() throws IOException {
// given
ContextMappingModel model = getOriginalResourceOfTestCML("state-diagram-generation-aggregate-test-2.cml").getContextMappingModel();
// when
Aggregate aggregate = model.getBoundedContexts().get(0).getAggregates().get(0);
String stateDiagram = new PlantUMLStateDiagramCreator4Aggregate().createDiagram(aggregate);
// then
assertEquals("@startuml" + System.lineSeparator() + System.lineSeparator() + "skinparam componentStyle uml2" + System.lineSeparator() + System.lineSeparator() + "QUOTE_EXPIRED : " + System.lineSeparator() + "REQUEST_SUBMITTED : " + System.lineSeparator() + "QUOTE_ACCEPTED : " + System.lineSeparator() + "POLICY_CREATED : " + System.lineSeparator() + "QUOTE_RECEIVED : " + System.lineSeparator() + "QUOTE_REJECTED : " + System.lineSeparator() + "REQUEST_REJECTED : " + System.lineSeparator() + "[*] --> REQUEST_SUBMITTED : submitRequest" + System.lineSeparator() + "REQUEST_SUBMITTED --> REQUEST_REJECTED : rejectRequest" + System.lineSeparator() + "REQUEST_SUBMITTED --> QUOTE_RECEIVED : receiveQuote" + System.lineSeparator() + "QUOTE_RECEIVED --> QUOTE_EXPIRED : checkQuote" + System.lineSeparator() + "QUOTE_RECEIVED --> QUOTE_ACCEPTED : checkQuote" + System.lineSeparator() + "QUOTE_RECEIVED --> QUOTE_REJECTED : checkQuote" + System.lineSeparator() + "QUOTE_ACCEPTED --> QUOTE_EXPIRED : createPolicy" + System.lineSeparator() + "QUOTE_ACCEPTED --> POLICY_CREATED : createPolicy" + System.lineSeparator() + System.lineSeparator() + System.lineSeparator() + "legend top center" + System.lineSeparator() + " QuoteRequest Aggregate Lifecycle" + System.lineSeparator() + "endlegend" + System.lineSeparator() + System.lineSeparator() + "@enduml" + System.lineSeparator() + "", stateDiagram);
}
use of org.contextmapper.dsl.generator.plantuml.PlantUMLStateDiagramCreator4Aggregate 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));
});
}
}
use of org.contextmapper.dsl.generator.plantuml.PlantUMLStateDiagramCreator4Aggregate in project context-mapper-dsl by ContextMapper.
the class PlantUMLStateDiagramCreatorTest method canCreateStateDiagram4AggregateViaService.
@Test
public void canCreateStateDiagram4AggregateViaService() throws IOException {
// given
ContextMappingModel model = getOriginalResourceOfTestCML("state-diagram-generation-aggregate-test-1.cml").getContextMappingModel();
// when
Aggregate aggregate = model.getBoundedContexts().get(0).getAggregates().get(0);
String stateDiagram = new PlantUMLStateDiagramCreator4Aggregate().createDiagram(aggregate);
// then
assertEquals("@startuml" + System.lineSeparator() + System.lineSeparator() + "skinparam componentStyle uml2" + System.lineSeparator() + System.lineSeparator() + "QUOTE_EXPIRED : " + System.lineSeparator() + "REQUEST_SUBMITTED : " + System.lineSeparator() + "QUOTE_ACCEPTED : " + System.lineSeparator() + "POLICY_CREATED : " + System.lineSeparator() + "QUOTE_RECEIVED : " + System.lineSeparator() + "QUOTE_REJECTED : " + System.lineSeparator() + "REQUEST_REJECTED : " + System.lineSeparator() + "[*] --> REQUEST_SUBMITTED : submitRequest" + System.lineSeparator() + "REQUEST_SUBMITTED --> REQUEST_REJECTED : rejectRequest" + System.lineSeparator() + "REQUEST_SUBMITTED --> QUOTE_RECEIVED : receiveQuote" + System.lineSeparator() + "QUOTE_RECEIVED --> QUOTE_EXPIRED : checkQuote" + System.lineSeparator() + "QUOTE_RECEIVED --> QUOTE_ACCEPTED : checkQuote" + System.lineSeparator() + "QUOTE_RECEIVED --> QUOTE_REJECTED : checkQuote" + System.lineSeparator() + "QUOTE_ACCEPTED --> QUOTE_EXPIRED : createPolicy" + System.lineSeparator() + "QUOTE_ACCEPTED --> POLICY_CREATED : createPolicy" + System.lineSeparator() + System.lineSeparator() + System.lineSeparator() + "legend top center" + System.lineSeparator() + " QuoteRequest Aggregate Lifecycle" + System.lineSeparator() + "endlegend" + System.lineSeparator() + System.lineSeparator() + "@enduml" + System.lineSeparator() + "", stateDiagram);
}
Aggregations