use of org.contextmapper.tactic.dsl.tacticdsl.CommandEvent in project context-mapper-dsl by ContextMapper.
the class ApplicationFlowSemanticsValidator method commandInvokationMustReferCommandInSameContext.
@Check
public void commandInvokationMustReferCommandInSameContext(final CommandInvokation commandInvokation) {
CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(commandInvokation));
BoundedContext currentContext = helper.resolveBoundedContext(commandInvokation);
for (CommandEvent commandEvent : commandInvokation.getCommands()) {
BoundedContext commandContext = helper.resolveBoundedContext((EObject) commandEvent);
if (commandContext == null || !currentContext.getName().equals(commandContext.getName()))
error(String.format(COMMAND_OR_OPERATION_IS_NOT_PART_OF_BOUNDED_CONTEXT, commandEvent.getName(), currentContext.getName()), commandInvokation, ContextMappingDSLPackage.Literals.COMMAND_INVOKATION__COMMANDS, commandInvokation.getCommands().indexOf(commandEvent));
}
}
use of org.contextmapper.tactic.dsl.tacticdsl.CommandEvent in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreatorTest method respectEventsAndCommandsAndServicesFromApplicationLayer.
@Test
public void respectEventsAndCommandsAndServicesFromApplicationLayer() {
// given
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
Application app = ContextMappingDSLFactory.eINSTANCE.createApplication();
boundedContext.setApplication(app);
DomainEvent testEvent = TacticdslFactory.eINSTANCE.createDomainEvent();
testEvent.setName("TestEvent");
app.getEvents().add(testEvent);
CommandEvent testCommand = TacticdslFactory.eINSTANCE.createCommandEvent();
testCommand.setName("TestCommand");
app.getCommands().add(testCommand);
Service testService = TacticdslFactory.eINSTANCE.createService();
testService.setName("TestService");
app.getServices().add(testService);
// when
String plantUML = this.creator.createDiagram(boundedContext);
// then
assertTrue(plantUML.contains("package \"'Application'\" <<Rectangle>> {" + System.lineSeparator()));
assertTrue(plantUML.contains(" class TestEvent <<(E,#ff9f4b) Domain Event>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
assertTrue(plantUML.contains(" class TestCommand <<(C,#3bc5e9) Command>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
assertTrue(plantUML.contains(" class TestService <<(S,DarkSeaGreen) Service>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
}
use of org.contextmapper.tactic.dsl.tacticdsl.CommandEvent in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreatorTest method canCreateInheritance4CommandEvent.
@Test
public void canCreateInheritance4CommandEvent() {
// given
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
Aggregate aggregate = ContextMappingDSLFactory.eINSTANCE.createAggregate();
aggregate.setName("testAggregate");
boundedContext.getAggregates().add(aggregate);
CommandEvent event1 = TacticdslFactory.eINSTANCE.createCommandEvent();
event1.setName("Customer");
CommandEvent event2 = TacticdslFactory.eINSTANCE.createCommandEvent();
event2.setName("AbstractEvent");
event1.setExtends(event2);
aggregate.getDomainObjects().add(event1);
aggregate.getDomainObjects().add(event2);
// when
String plantUML = this.creator.createDiagram(boundedContext);
// then
assertTrue(plantUML.contains(" class Customer <<(C,#3bc5e9) Command>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
assertTrue(plantUML.contains(" class AbstractEvent <<(C,#3bc5e9) Command>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
assertTrue(plantUML.contains("Customer --|> AbstractEvent" + System.lineSeparator()));
}
use of org.contextmapper.tactic.dsl.tacticdsl.CommandEvent 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.tactic.dsl.tacticdsl.CommandEvent in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreator method printApplication.
private void printApplication(Application application, int indentation) {
printIndentation(indentation);
String name = StringUtils.isNotEmpty(application.getName()) ? application.getName() : "Application";
sb.append("package ").append("\"'").append(name).append("'").append("\"").append(" <<Rectangle>> ").append("{");
linebreak();
if (!application.getFlows().isEmpty()) {
printIndentation(indentation + 1);
sb.append("legend left");
linebreak();
printIndentation(indentation + 2);
sb.append("This application layer contains flow definitions (visualization available via BPMN Sketch Miner).");
linebreak();
printIndentation(indentation + 1);
sb.append("end legend");
linebreak();
}
for (DomainEvent event : application.getEvents()) {
printDomainObject(event, indentation + 1);
}
for (CommandEvent command : application.getCommands()) {
printDomainObject(command, indentation + 1);
}
for (Service service : application.getServices()) {
printService(service, indentation + 1);
}
printIndentation(indentation);
sb.append("}");
linebreak();
}
Aggregations