Search in sources :

Example 1 with DomainEvent

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));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) RelationType(ch.hsr.servicecutter.api.model.EntityRelation.RelationType) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) DomainEvent(org.contextmapper.tactic.dsl.tacticdsl.DomainEvent) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) ValueObject(org.contextmapper.tactic.dsl.tacticdsl.ValueObject) Collectors(java.util.stream.Collectors) ContextMappingModelToServiceCutterERDConverter(org.contextmapper.dsl.generator.servicecutter.input.converter.ContextMappingModelToServiceCutterERDConverter) Test(org.junit.jupiter.api.Test) Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) List(java.util.List) Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) TacticdslFactory(org.contextmapper.tactic.dsl.tacticdsl.TacticdslFactory) ContextMappingDSLFactory(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory) EntityRelationDiagram(ch.hsr.servicecutter.api.model.EntityRelationDiagram) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Reference(org.contextmapper.tactic.dsl.tacticdsl.Reference) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) DomainEvent(org.contextmapper.tactic.dsl.tacticdsl.DomainEvent) Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) BeforeEach(org.junit.jupiter.api.BeforeEach) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) EntityRelationDiagram(ch.hsr.servicecutter.api.model.EntityRelationDiagram) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) Test(org.junit.jupiter.api.Test)

Example 2 with DomainEvent

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()));
}
Also used : DomainEvent(org.contextmapper.tactic.dsl.tacticdsl.DomainEvent) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 3 with DomainEvent

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()));
}
Also used : DomainEvent(org.contextmapper.tactic.dsl.tacticdsl.DomainEvent) CommandEvent(org.contextmapper.tactic.dsl.tacticdsl.CommandEvent) Service(org.contextmapper.tactic.dsl.tacticdsl.Service) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) Application(org.contextmapper.dsl.contextMappingDSL.Application) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 4 with DomainEvent

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()));
}
Also used : DomainEvent(org.contextmapper.tactic.dsl.tacticdsl.DomainEvent) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 5 with DomainEvent

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;
}
Also used : DomainEvent(org.contextmapper.tactic.dsl.tacticdsl.DomainEvent)

Aggregations

DomainEvent (org.contextmapper.tactic.dsl.tacticdsl.DomainEvent)10 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)5 Test (org.junit.jupiter.api.Test)5 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)4 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)4 CommandEvent (org.contextmapper.tactic.dsl.tacticdsl.CommandEvent)4 Application (org.contextmapper.dsl.contextMappingDSL.Application)2 Service (org.contextmapper.tactic.dsl.tacticdsl.Service)2 ValueObject (org.contextmapper.tactic.dsl.tacticdsl.ValueObject)2 RelationType (ch.hsr.servicecutter.api.model.EntityRelation.RelationType)1 EntityRelationDiagram (ch.hsr.servicecutter.api.model.EntityRelationDiagram)1 InvalidParameterException (java.security.InvalidParameterException)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 CommandInvokationStep (org.contextmapper.dsl.contextMappingDSL.CommandInvokationStep)1 ConcurrentCommandInvokation (org.contextmapper.dsl.contextMappingDSL.ConcurrentCommandInvokation)1 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)1 ContextMappingDSLFactory (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 DomainEventProductionStep (org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep)1