Search in sources :

Example 1 with End

use of io.serverlessworkflow.api.end.End in project kogito-runtimes by kiegroup.

the class ServerlessWorkflowParsingTest method testMinimumWorkflow.

@Test
public void testMinimumWorkflow() {
    Workflow workflow = new Workflow();
    workflow.setId("javierito");
    Start start = new Start();
    start.setStateName("javierito");
    End end = new End();
    end.setTerminate(true);
    SleepState startState = new SleepState();
    startState.setType(Type.SLEEP);
    startState.setDuration("1s");
    startState.setName("javierito");
    startState.setEnd(end);
    workflow.setStates(Collections.singletonList(startState));
    workflow.setStart(start);
    ServerlessWorkflowParser parser = ServerlessWorkflowParser.of(workflow, JavaKogitoBuildContext.builder().build());
    Process process = parser.getProcessInfo().info();
    assertSame(process, parser.getProcessInfo().info());
    assertEquals(ServerlessWorkflowParser.DEFAULT_NAME, process.getName());
    assertEquals(ServerlessWorkflowParser.DEFAULT_VERSION, process.getVersion());
    assertEquals(ServerlessWorkflowParser.DEFAULT_PACKAGE, process.getPackageName());
}
Also used : Start(io.serverlessworkflow.api.start.Start) ServerlessWorkflowParser(org.kie.kogito.serverless.workflow.parser.ServerlessWorkflowParser) Workflow(io.serverlessworkflow.api.Workflow) End(io.serverlessworkflow.api.end.End) Process(org.kie.api.definition.process.Process) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) SleepState(io.serverlessworkflow.api.states.SleepState) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with End

use of io.serverlessworkflow.api.end.End in project kogito-runtimes by kiegroup.

the class SwitchValidatorTest method validateDefaultConditionWithEventConditionsEndButTimeoutNotSetError.

@Test
void validateDefaultConditionWithEventConditionsEndButTimeoutNotSetError() {
    switchState.getEventConditions().add(mock(EventCondition.class));
    DefaultConditionDefinition defaultCondition = mock(DefaultConditionDefinition.class);
    End end = mock(End.class);
    doReturn(end).when(defaultCondition).getEnd();
    Assertions.assertThatThrownBy(() -> SwitchValidator.validateDefaultCondition(defaultCondition, switchState, workflow, parserContext)).isInstanceOf(IllegalArgumentException.class).hasMessage(String.format(EVENT_TIMEOUT_REQUIRED_ERROR, SWITCH_STATE_NAME, WORKFLOW_NAME));
}
Also used : End(io.serverlessworkflow.api.end.End) EventCondition(io.serverlessworkflow.api.switchconditions.EventCondition) DefaultConditionDefinition(io.serverlessworkflow.api.defaultdef.DefaultConditionDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

End (io.serverlessworkflow.api.end.End)2 Test (org.junit.jupiter.api.Test)2 Workflow (io.serverlessworkflow.api.Workflow)1 DefaultConditionDefinition (io.serverlessworkflow.api.defaultdef.DefaultConditionDefinition)1 Start (io.serverlessworkflow.api.start.Start)1 SleepState (io.serverlessworkflow.api.states.SleepState)1 EventCondition (io.serverlessworkflow.api.switchconditions.EventCondition)1 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 Process (org.kie.api.definition.process.Process)1 ServerlessWorkflowParser (org.kie.kogito.serverless.workflow.parser.ServerlessWorkflowParser)1