Search in sources :

Example 26 with Flow

use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.

the class SketchMinerModelCreatorTest method canUseActorIfAvailable.

@Test
public void canUseActorIfAvailable() throws IOException {
    // given
    ContextMappingModel model = getOriginalResourceOfTestCML("actor-test-1.cml").getContextMappingModel();
    Flow flow = EcoreUtil2.eAllOfType(model, Flow.class).get(0);
    // when
    String output = new SketchMinerModelCreator().createText(flow);
    // then
    assertEquals("(StartEvent)" + System.lineSeparator() + "Test User: // TestAggregate [STATE1, STATE2 -> STATE3 X STATE4]" + System.lineSeparator() + "Test User: service Command1" + System.lineSeparator() + "(EndEvent)" + System.lineSeparator() + System.lineSeparator(), output);
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) SketchMinerModelCreator(org.contextmapper.dsl.generator.sketchminer.SketchMinerModelCreator) Flow(org.contextmapper.dsl.contextMappingDSL.Flow) Test(org.junit.jupiter.api.Test) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with Flow

use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.

the class SketchMinerModelCreatorTest method canGenerateStepsForLoopIfStartNameAlreadyGiven.

@Test
public void canGenerateStepsForLoopIfStartNameAlreadyGiven() throws IOException {
    // given
    ContextMappingModel model = getOriginalResourceOfTestCML("loop-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() + "(InitialEvent0)" + System.lineSeparator() + "service InitialEvent" + System.lineSeparator() + "(FirstEvent)" + System.lineSeparator() + "service MiddleCommand" + System.lineSeparator() + "(EndEvent)" + System.lineSeparator() + "service InitialEvent" + System.lineSeparator() + "(FirstEvent)" + System.lineSeparator() + "service MiddleCommand" + System.lineSeparator() + "(EndEvent)" + System.lineSeparator() + System.lineSeparator(), output);
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) SketchMinerModelCreator(org.contextmapper.dsl.generator.sketchminer.SketchMinerModelCreator) Flow(org.contextmapper.dsl.contextMappingDSL.Flow) Test(org.junit.jupiter.api.Test) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with Flow

use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.

the class SketchMinerModelCreatorTest method canGenerateParallelStep4EventProduction.

@Test
public void canGenerateParallelStep4EventProduction() throws IOException {
    // given
    ContextMappingModel model = getOriginalResourceOfTestCML("simple-sequence-with-parallel-step-test-1.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)|(SecondEvent)" + System.lineSeparator() + "..." + System.lineSeparator() + System.lineSeparator() + "..." + System.lineSeparator() + "(FirstEvent)" + System.lineSeparator() + "service EndCommand" + System.lineSeparator() + System.lineSeparator() + "..." + System.lineSeparator() + "(SecondEvent)" + System.lineSeparator() + "service EndCommand" + System.lineSeparator() + System.lineSeparator(), output);
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) SketchMinerModelCreator(org.contextmapper.dsl.generator.sketchminer.SketchMinerModelCreator) Flow(org.contextmapper.dsl.contextMappingDSL.Flow) Test(org.junit.jupiter.api.Test) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 29 with Flow

use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.

the class SketchMinerModelCreatorTest method canAddStateTransitionComment.

@Test
public void canAddStateTransitionComment() throws IOException {
    // given
    ContextMappingModel model = getOriginalResourceOfTestCML("state-transition-comment-test-1.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]" + System.lineSeparator() + "service Command1" + System.lineSeparator() + "(EndEvent)" + System.lineSeparator() + System.lineSeparator(), output);
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) SketchMinerModelCreator(org.contextmapper.dsl.generator.sketchminer.SketchMinerModelCreator) Flow(org.contextmapper.dsl.contextMappingDSL.Flow) Test(org.junit.jupiter.api.Test) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with Flow

use of org.contextmapper.dsl.contextMappingDSL.Flow in project context-mapper-dsl by ContextMapper.

the class PlantUMLStateDiagramCreator4Flow method printDiagramContent.

@Override
protected void printDiagramContent(Flow flow) {
    List<DomainEventProductionStep> eventProductionStepsWithStateTransitions = flow.getSteps().stream().filter(s -> s instanceof DomainEventProductionStep).map(s -> (DomainEventProductionStep) s).filter(s -> s.getStateTransition() != null).collect(Collectors.toList());
    List<StateTransition> allStateTransitions = eventProductionStepsWithStateTransitions.stream().map(s -> s.getStateTransition()).collect(Collectors.toList());
    for (String state : collectStates(allStateTransitions)) {
        printState(state);
    }
    for (DomainEventProductionStep step : eventProductionStepsWithStateTransitions) printTransition(step.getStateTransition(), step.getAction().getCommand() != null ? step.getAction().getCommand().getName() : step.getAction().getOperation().getName());
    linebreak(2);
    sb.append("legend top center");
    linebreak();
    sb.append("  " + flow.getName() + " State Transitions");
    linebreak();
    sb.append("endlegend");
}
Also used : List(java.util.List) DomainEventProductionStep(org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep) StateTransition(org.contextmapper.tactic.dsl.tacticdsl.StateTransition) Flow(org.contextmapper.dsl.contextMappingDSL.Flow) Collectors(java.util.stream.Collectors) DomainEventProductionStep(org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep) StateTransition(org.contextmapper.tactic.dsl.tacticdsl.StateTransition)

Aggregations

Flow (org.contextmapper.dsl.contextMappingDSL.Flow)30 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)26 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)21 SketchMinerModelCreator (org.contextmapper.dsl.generator.sketchminer.SketchMinerModelCreator)21 Test (org.junit.jupiter.api.Test)21 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 SketchMinerLinkCreator (org.contextmapper.dsl.generator.sketchminer.SketchMinerLinkCreator)5 DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)4 ValueSource (org.junit.jupiter.params.provider.ValueSource)4 List (java.util.List)2 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)2 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)2 PlantUMLStateDiagramCreator4Flow (org.contextmapper.dsl.generator.plantuml.PlantUMLStateDiagramCreator4Flow)2 StateTransition (org.contextmapper.tactic.dsl.tacticdsl.StateTransition)2 EObject (org.eclipse.emf.ecore.EObject)2 Lists (com.google.common.collect.Lists)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Domain (org.contextmapper.dsl.contextMappingDSL.Domain)1 DomainEventProductionStep (org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep)1