Search in sources :

Example 1 with ProcessClassBuilder

use of org.jbpm.process.builder.ProcessClassBuilder in project kogito-runtimes by kiegroup.

the class ActivityTest method testUserTaskWithAssignment.

@Test
public void testUserTaskWithAssignment() throws Exception {
    ProcessDialectRegistry.setDialect("custom", new ProcessDialect() {

        @Override
        public ReturnValueEvaluatorBuilder getReturnValueEvaluatorBuilder() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public ProcessClassBuilder getProcessClassBuilder() {
            return null;
        }

        @Override
        public AssignmentBuilder getAssignmentBuilder() {
            return new AssignmentBuilder() {

                @Override
                public void build(PackageBuildContext context, Assignment assignment, List<DataDefinition> sourceExpr, DataDefinition targetExpr) {
                    assertEquals("from_expression", assignment.getFrom().getExpression());
                    assertEquals("to_expression", assignment.getTo().getExpression());
                }
            };
        }

        @Override
        public ActionBuilder getActionBuilder() {
            return null;
        }

        @Override
        public void addProcess(ProcessBuildContext context) {
        }
    });
    kruntime = createKogitoProcessRuntime("BPMN2-DataOutputAssignmentCustomExpressionLang.bpmn2");
    Process scriptProcess = kruntime.getKieBase().getProcess("process");
    assertThat(scriptProcess).isNotNull();
    Node[] nodes = ((NodeContainer) scriptProcess).getNodes();
    assertThat(nodes).hasSize(3);
    assertThat(nodes).filteredOn(n -> n instanceof WorkItemNode).allMatch(this::matchExpectedAssociationSetup);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    Map<String, Object> params = new HashMap<>();
    params.put("name", "John");
    KogitoProcessInstance processInstance = kruntime.startProcess("process", params);
    kruntime.abortProcessInstance(processInstance.getStringId());
    assertProcessInstanceAborted(processInstance);
}
Also used : BeforeMatchFiredEvent(org.kie.api.event.rule.BeforeMatchFiredEvent) Address(org.jbpm.bpmn2.objects.Address) Account(org.jbpm.bpmn2.objects.Account) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HelloService(org.jbpm.bpmn2.objects.HelloService) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) Disabled(org.junit.jupiter.api.Disabled) DefaultKogitoProcessEventListener(org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener) Assignment(org.jbpm.workflow.core.node.Assignment) KogitoNodeInstanceContainer(org.kie.kogito.internal.process.runtime.KogitoNodeInstanceContainer) BigDecimal(java.math.BigDecimal) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) Map(java.util.Map) ProcessBuildContext(org.jbpm.process.builder.ProcessBuildContext) ProcessDialectRegistry(org.jbpm.process.builder.dialect.ProcessDialectRegistry) ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) ActionBuilder(org.jbpm.process.builder.ActionBuilder) ProcessClassBuilder(org.jbpm.process.builder.ProcessClassBuilder) RuleAwareProcessEventListener(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) Process(org.kie.api.definition.process.Process) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) VariableScope(org.jbpm.process.core.context.variable.VariableScope) Test(org.junit.jupiter.api.Test) List(java.util.List) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) Assertions.fail(org.assertj.core.api.Assertions.fail) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Person(org.jbpm.bpmn2.objects.Person) KogitoWorkItemManager(org.kie.kogito.internal.process.runtime.KogitoWorkItemManager) InternalKogitoWorkItem(org.kie.kogito.process.workitems.InternalKogitoWorkItem) NodeContainer(org.kie.api.definition.process.NodeContainer) DynamicUtils(org.jbpm.workflow.instance.node.DynamicUtils) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition) WorkflowRuntimeException(org.jbpm.workflow.instance.WorkflowRuntimeException) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AssignmentBuilder(org.jbpm.process.builder.AssignmentBuilder) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) NodeInstance(org.kie.api.runtime.process.NodeInstance) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) KogitoProcessRuntime(org.kie.kogito.internal.process.runtime.KogitoProcessRuntime) ExecutableCommand(org.kie.api.command.ExecutableCommand) TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) ArrayList(java.util.ArrayList) TriggerRulesEventListener(org.jbpm.process.instance.event.listeners.TriggerRulesEventListener) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) AfterMatchFiredEvent(org.kie.api.event.rule.AfterMatchFiredEvent) KogitoWorkflowProcessInstance(org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance) ServiceTaskHandler(org.jbpm.bpmn2.handler.ServiceTaskHandler) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) DataTransformer(org.kie.api.runtime.process.DataTransformer) ActionNode(org.jbpm.workflow.core.node.ActionNode) ReturnValueEvaluatorBuilder(org.jbpm.process.builder.ReturnValueEvaluatorBuilder) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence) AgendaEventListener(org.kie.api.event.rule.AgendaEventListener) PackageBuildContext(org.drools.compiler.rule.builder.PackageBuildContext) DataTransformerRegistry(org.jbpm.process.core.impl.DataTransformerRegistry) Node(org.kie.api.definition.process.Node) NodeLeftCountDownProcessEventListener(org.jbpm.test.util.NodeLeftCountDownProcessEventListener) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) MatchCreatedEvent(org.kie.api.event.rule.MatchCreatedEvent) Collections(java.util.Collections) Timeout(org.junit.jupiter.api.Timeout) ProcessStartedEvent(org.kie.api.event.process.ProcessStartedEvent) MatchCancelledEvent(org.kie.api.event.rule.MatchCancelledEvent) ReceiveTaskHandler(org.jbpm.bpmn2.handler.ReceiveTaskHandler) TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) ActionBuilder(org.jbpm.process.builder.ActionBuilder) HashMap(java.util.HashMap) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) Node(org.kie.api.definition.process.Node) Process(org.kie.api.definition.process.Process) NodeContainer(org.kie.api.definition.process.NodeContainer) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect) AssignmentBuilder(org.jbpm.process.builder.AssignmentBuilder) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition) ProcessClassBuilder(org.jbpm.process.builder.ProcessClassBuilder) Assignment(org.jbpm.workflow.core.node.Assignment) PackageBuildContext(org.drools.compiler.rule.builder.PackageBuildContext) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ProcessBuildContext(org.jbpm.process.builder.ProcessBuildContext) ReturnValueEvaluatorBuilder(org.jbpm.process.builder.ReturnValueEvaluatorBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.fail (org.assertj.core.api.Assertions.fail)1 PackageBuildContext (org.drools.compiler.rule.builder.PackageBuildContext)1 ReceiveTaskHandler (org.jbpm.bpmn2.handler.ReceiveTaskHandler)1 SendTaskHandler (org.jbpm.bpmn2.handler.SendTaskHandler)1 ServiceTaskHandler (org.jbpm.bpmn2.handler.ServiceTaskHandler)1 Account (org.jbpm.bpmn2.objects.Account)1 Address (org.jbpm.bpmn2.objects.Address)1 HelloService (org.jbpm.bpmn2.objects.HelloService)1 Person (org.jbpm.bpmn2.objects.Person)1 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)1 RequirePersistence (org.jbpm.bpmn2.test.RequirePersistence)1 ActionBuilder (org.jbpm.process.builder.ActionBuilder)1 AssignmentBuilder (org.jbpm.process.builder.AssignmentBuilder)1