use of org.contextmapper.tactic.dsl.tacticdsl.DomainEvent in project context-mapper-dsl by ContextMapper.
the class ContextMappingModelToServiceCutterERDConverterTest method canCreateEntity4DomainEvent.
@Test
public void canCreateEntity4DomainEvent() {
// given
ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
ContextMap contextMap = ContextMappingDSLFactory.eINSTANCE.createContextMap();
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
boundedContext.setName("testBC");
contextMap.getBoundedContexts().add(boundedContext);
model.getBoundedContexts().add(boundedContext);
Aggregate aggregate = ContextMappingDSLFactory.eINSTANCE.createAggregate();
aggregate.setName("testAggregate");
boundedContext.getAggregates().add(aggregate);
DomainEvent domainEvent = TacticdslFactory.eINSTANCE.createDomainEvent();
domainEvent.setName("TestDomainEvent");
Attribute attribute = TacticdslFactory.eINSTANCE.createAttribute();
attribute.setName("attribute1");
aggregate.getDomainObjects().add(domainEvent);
domainEvent.getAttributes().add(attribute);
model.setMap(contextMap);
// when
EntityRelationDiagram scDiagram = this.converter.convert("TestModel", model);
// then
List<String> entityNames = scDiagram.getEntities().stream().map(e -> e.getName()).collect(Collectors.toList());
assertTrue(entityNames.contains("TestDomainEvent"));
ch.hsr.servicecutter.api.model.Entity scEntity = getEntity(scDiagram.getEntities(), "TestDomainEvent");
assertEquals(1, scEntity.getNanoentities().size());
assertEquals("attribute1", scEntity.getNanoentities().get(0));
}
use of org.contextmapper.tactic.dsl.tacticdsl.DomainEvent in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreatorTest method canCreateInheritance4DomainEvent.
@Test
public void canCreateInheritance4DomainEvent() {
// given
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
Aggregate aggregate = ContextMappingDSLFactory.eINSTANCE.createAggregate();
aggregate.setName("testAggregate");
boundedContext.getAggregates().add(aggregate);
DomainEvent event1 = TacticdslFactory.eINSTANCE.createDomainEvent();
event1.setName("Customer");
DomainEvent event2 = TacticdslFactory.eINSTANCE.createDomainEvent();
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 <<(E,#ff9f4b) Domain Event>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
assertTrue(plantUML.contains(" class AbstractEvent <<(E,#ff9f4b) Domain Event>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
assertTrue(plantUML.contains("Customer --|> AbstractEvent" + System.lineSeparator()));
}
use of org.contextmapper.tactic.dsl.tacticdsl.DomainEvent 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.DomainEvent in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreatorTest method canCreateClassFromDomainEvent.
@Test
public void canCreateClassFromDomainEvent() {
// given
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
Aggregate aggregate = ContextMappingDSLFactory.eINSTANCE.createAggregate();
aggregate.setName("testAggregate");
boundedContext.getAggregates().add(aggregate);
DomainEvent domainEvent = TacticdslFactory.eINSTANCE.createDomainEvent();
domainEvent.setName("TestEvent");
aggregate.getDomainObjects().add(domainEvent);
// when
String plantUML = this.creator.createDiagram(boundedContext);
// then
assertTrue(plantUML.contains(" class TestEvent <<(E,#ff9f4b) Domain Event>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
}
use of org.contextmapper.tactic.dsl.tacticdsl.DomainEvent in project context-mapper-dsl by ContextMapper.
the class MDSLModelCreator method combineEvents.
private String combineEvents(EList<DomainEvent> events, String operator) {
String combinedEvent = "";
boolean isFirstElementInList = true;
for (DomainEvent event : events) {
if (isFirstElementInList) {
isFirstElementInList = false;
} else {
// must be false
combinedEvent += operator;
}
combinedEvent += event.getName();
}
return combinedEvent;
}
Aggregations