env ); Long sessionId = service.getSessionId(); StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); RuleFlowProcessInstance processInstance = (RuleFlowProcessInstance) service.execute( startProcessCommand ); logger.info( "Started process instance {}", processInstance.getId() ); config, env ); GetProcessInstanceCommand getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( processInstanceId ); processInstance = (RuleFlowProcessInstance) service.execute( getProcessInstanceCommand ); assertNotNull( processInstance ); SubProcessNodeInstance subProcessNodeInstance = (SubProcessNodeInstance) nodeInstances.iterator().next(); long subProcessInstanceId = subProcessNodeInstance.getProcessInstanceId(); getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( subProcessInstanceId ); RuleFlowProcessInstance subProcessInstance = (RuleFlowProcessInstance) service.execute( getProcessInstanceCommand ); assertNotNull( subProcessInstance ); config, env ); CompleteWorkItemCommand completeWorkItemCommand = new CompleteWorkItemCommand(); completeWorkItemCommand.setWorkItemId( workItem.getId() ); service.execute( completeWorkItemCommand ); service.dispose(); config,
env ); Long sessionId = service.getSessionId(); StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); ProcessInstance processInstance = service.execute( startProcessCommand ); logger.info( "Started process instance {}", processInstance.getId() ); config, env ); GetProcessInstanceCommand getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() ); processInstance = service.execute( getProcessInstanceCommand ); assertNull( processInstance );
Map<String, Object> updatedVariables = new HashMap<>(); updatedVariables.put("fatherId", 999L); ksession.execute(new SetProcessInstanceVariablesCommand(changeProcessInstanceId, updatedVariables));
@Test public void commandRequestTest() throws Exception { JaxbCommandsRequest req = new JaxbCommandsRequest(); req.setUser("krampus"); List<Command> cmds = new ArrayList<Command>(); req.setCommands(cmds); req.setDeploymentId("depId"); req.setProcessInstanceId(43l); req.setVersion("2"); StartProcessCommand spCmd = new StartProcessCommand("test.proc.yaml"); cmds.add(spCmd); spCmd.getParameters().put("one", "a"); spCmd.getParameters().put("two", "B"); Object weirdParam = new Integer[] { 59, 2195 }; spCmd.getParameters().put("thr", weirdParam); JaxbCommandsRequest newReq = testRoundTrip(req); assertEquals(((StartProcessCommand) newReq.getCommands().get(0)).getParameters().get("two"), "B"); Object newStringReq = deserialize(cmdReqXmlStr); assertNotNull(newStringReq); assertEquals( 1, ((JaxbCommandsRequest) newStringReq).getCommands().size()); Command<?> newCmd = ((JaxbCommandsRequest) newStringReq).getCommands().get(0); }
@Test public void testMarshallStartProcessCmdWithNoOutIdentifier() { // the "out-identifier" is optional -> the marshalling should succeed even if it is null StartProcessCommand cmd = new StartProcessCommand("some-process-id"); String xmlString = xstream.toXML(cmd); Assert.assertTrue(xmlString.contains("processId=\"some-process-id\"")); }
req.setProcessInstanceId(43l); req.setVersion("6.0.1.0"); StartProcessCommand spCmd = new StartProcessCommand("test.proc.yaml"); cmds.add(spCmd); spCmd.getParameters().put("one", "a"); spCmd.getParameters().put("two", "B"); Object weirdParam = new Integer[] { 59, 2195 }; spCmd.getParameters().put("thr", weirdParam); assertEquals(((StartProcessCommand) newReq.getCommands().get(0)).getParameters().get("two"), "B"); req = new JaxbCommandsRequest("deployment", new StartProcessCommand("org.jbpm.humantask")); newReq = testRoundTrip(req); corrKey.addProperty(new CorrelationPropertyInfo("null", "val")); GetProcessInstanceByCorrelationKeyCommand gpibckCmd = new GetProcessInstanceByCorrelationKeyCommand(corrKey); req = new JaxbCommandsRequest("test", gpibckCmd); testRoundTrip(req);
cmdsRequest = new JaxbCommandsRequest(DEPLOYMENT_ID, new StartProcessCommand(TEST_PROCESS_DEF_NAME)); cmdsRequest.setCorrelationKeyString("anton"); JaxbCommandsResponse cmdsRequest = new JaxbCommandsRequest(DEPLOYMENT_ID, new SignalEventCommand(TEST_PROCESS_INST_ID, "test", null)); cmdsRequest.setVersion(ServicesVersion.VERSION); cmdsRequest.setProcessInstanceId(TEST_PROCESS_INST_ID);
batchCmd.setLookup("lookup"); AbortWorkItemCommand cmd = new AbortWorkItemCommand(23l); resultValList.add("chances"); results.put("list", resultValList); CompleteWorkItemCommand cmd = new CompleteWorkItemCommand(random.nextInt(1000), results);
@Test public void testUnMarshallStartProcessCmdWithNoOutIdentifier() { // the "out-identifier" is optional -> the unmarshalling should create valid object Object obj = xstream.fromXML( "<start-process processId=\"some-process-id\"/>"); Assert.assertEquals(StartProcessCommand.class, obj.getClass()); StartProcessCommand cmd = (StartProcessCommand)obj; Assert.assertEquals( "some-process-id", cmd.getProcessId() ); }
@Test public void serializingPrimitiveArraysTest() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("url", "http://soaptest.parasoft.com/calculator.wsdl"); parameters.put("namespace", "http://www.parasoft.com/wsdl/calculator/"); parameters.put("interface", "Calculator"); parameters.put("operation", "add"); Float [] arrayParam = new Float[] { 9.0f, 12.0f }; parameters.put("parameters", arrayParam); addClassesToSerializationProvider(arrayParam.getClass()); org.kie.remote.jaxb.gen.StartProcessCommand cmd = new org.kie.remote.jaxb.gen.StartProcessCommand(); cmd.setProcessId("proc.with.array.params"); cmd.setParameter(ConversionUtil.convertMapToJaxbStringObjectPairArray(parameters)); org.kie.remote.client.jaxb.JaxbCommandsRequest clientReq = new org.kie.remote.client.jaxb.JaxbCommandsRequest("test", cmd); JaxbCommandsRequest serviceReq = (JaxbCommandsRequest) clientServicesRoundTrip(clientReq); StartProcessCommand newCmd = (StartProcessCommand) serviceReq.getCommands().get(0); assertNotNull(newCmd); Float [] arrayParamCopy = (Float[]) newCmd.getParameters().get("parameters"); assertArrayEquals(arrayParam, arrayParamCopy); }
org.drools.core.command.runtime.process.AbortProcessInstanceCommand realApCmd = (org.drools.core.command.runtime.process.AbortProcessInstanceCommand) cmds.get(0); assertEquals(apCmd.getProcessInstanceId(), realApCmd.getProcessInstanceId()); = (org.drools.core.command.runtime.process.GetProcessInstanceByCorrelationKeyCommand) serviceReq.getCommands().get(0); List<CorrelationProperty<?>> corrProps = realGpicbckCmd.getCorrelationKey().getProperties(); assertEquals( "Number of correlation properties in request", 2, corrProps.size()); assertEquals( "Correlation property value in request", corrPropVal1, corrProps.get(0).getValue());
@Test public void testStartProcessAndExecuteCmd() { assertNotNull(deploymentService); KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION); deploymentService.deploy(deploymentUnit); units.add(deploymentUnit); boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier()); assertTrue(isDeployed); assertNotNull(processService); long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument"); assertNotNull(processInstanceId); ProcessInstance pi = processService.execute(deploymentUnit.getIdentifier(), new GetProcessInstanceCommand(processInstanceId)); assertNotNull(pi); processService.abortProcessInstance(processInstanceId); pi = processService.getProcessInstance(processInstanceId); assertNull(pi); }
StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); ProcessInstance processInstance = service.execute( startProcessCommand ); logger.info( "Started process instance {}", processInstance.getId() ); config, env ); GetProcessInstanceCommand getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() ); processInstance = service.execute( getProcessInstanceCommand ); assertNotNull( processInstance ); config, env ); CompleteWorkItemCommand completeWorkItemCommand = new CompleteWorkItemCommand(); completeWorkItemCommand.setWorkItemId( workItem.getId() ); service.execute( completeWorkItemCommand ); config, env ); getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() ); processInstance = service.execute( getProcessInstanceCommand ); assertNotNull( processInstance ); config, env ); completeWorkItemCommand = new CompleteWorkItemCommand(); completeWorkItemCommand.setWorkItemId( workItem.getId() );
env ); Long sessionId = service.getSessionId(); StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); ProcessInstance processInstance = service.execute( startProcessCommand ); logger.info( "Started process instance {}", processInstance.getId() ); config, env ); GetProcessInstanceCommand getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() ); processInstance = service.execute( getProcessInstanceCommand ); assertNotNull( processInstance ); env ); Thread.sleep( 5000 ); getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() ); processInstance = service.execute( getProcessInstanceCommand ); assertNull( processInstance );
@Test public void commandRequestTest() throws Exception { JaxbCommandsRequest req = new JaxbCommandsRequest(); req.setUser("krampus"); List<Command> cmds = new ArrayList<Command>(); req.setCommands(cmds); req.setDeploymentId("depId"); req.setProcessInstanceId(43l); req.setVersion("2"); StartProcessCommand spCmd = new StartProcessCommand("test.proc.yaml"); cmds.add(spCmd); spCmd.getParameters().put("one", "a"); spCmd.getParameters().put("two", "B"); Object weirdParam = new Integer[] { 59, 2195 }; spCmd.getParameters().put("thr", weirdParam); JaxbCommandsRequest newReq = testRoundTrip(req); assertEquals(((StartProcessCommand) newReq.getCommands().get(0)).getParameters().get("two"), "B"); Object newStringReq = deserialize(cmdReqXmlStr); assertNotNull(newStringReq); assertEquals( 1, ((JaxbCommandsRequest) newStringReq).getCommands().size()); Command<?> newCmd = ((JaxbCommandsRequest) newStringReq).getCommands().get(0); assertNotNull( newCmd ); }
@Test public void testMarshallStartProcessCmd() { StartProcessCommand cmd = new StartProcessCommand("some-process-id", "some-out-identifier"); String xmlString = xstream.toXML(cmd); Assert.assertTrue(xmlString.contains("processId=\"some-process-id\"")); Assert.assertTrue(xmlString.contains("out-identifier=\"some-out-identifier\"")); }
Map<String, Object> updatedVariables = new HashMap<>(); updatedVariables.put("fatherId", 999L); ksession.execute(new SetProcessInstanceVariablesCommand(changeProcessInstanceId, updatedVariables));
@Test public void testMarshallStartProcessCommand() { String xmlCommand = "<start-process processId=\"org.drools.task.processOne\" out-identifier=\"id\"/>"; StartProcessCommand command = marshaller.unmarshall(xmlCommand, StartProcessCommand.class); assertEquals("org.drools.task.processOne", command.getProcessId()); assertEquals(xmlCommand, marshaller.marshall(command)); }
StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); ProcessInstance processInstance = service.execute( startProcessCommand ); logger.info( "Started process instance {}", processInstance.getId() ); env ); ut.begin(); GetProcessInstanceCommand getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() ); processInstance = service.execute( getProcessInstanceCommand ); assertNotNull( processInstance ); env ); ut.begin(); CompleteWorkItemCommand completeWorkItemCommand = new CompleteWorkItemCommand(); completeWorkItemCommand.setWorkItemId( workItem.getId() ); service.execute( completeWorkItemCommand ); ut.commit(); env ); ut.begin(); getProcessInstanceCommand = new GetProcessInstanceCommand(); getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() ); processInstance = service.execute( getProcessInstanceCommand ); ut.commit(); env ); ut.begin(); completeWorkItemCommand = new CompleteWorkItemCommand();
@Test public void serializingPrimitiveArraysTest() throws Exception { // Don't run with JSON: /execute is only JAXB Assume.assumeFalse(getType().equals(TestType.JSON)); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("url", "http://soaptest.parasoft.com/calculator.wsdl"); parameters.put("namespace", "http://www.parasoft.com/wsdl/calculator/"); parameters.put("interface", "Calculator"); parameters.put("operation", "add"); Object arrayParam = new Float[]{9.0f, 12.0f}; parameters.put("parameters", arrayParam); addClassesToSerializationProvider(arrayParam.getClass()); Command<?> cmd = new StartProcessCommand("proc.with.array.params", parameters); JaxbCommandsRequest req = new JaxbCommandsRequest("test", cmd); Command<?> newCmd = testRoundTrip(req).getCommands().get(0); assertNotNull(newCmd); }