env ); Long sessionId = service.getSessionId(); StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); ProcessInstance processInstance = service.execute( startProcessCommand );
env ); Long sessionId = service.getSessionId(); StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); ProcessInstance processInstance = service.execute( startProcessCommand );
env ); Long sessionId = service.getSessionId(); StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); RuleFlowProcessInstance processInstance = (RuleFlowProcessInstance) service.execute( startProcessCommand );
Long sessionId = service.getSessionId(); StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); ProcessInstance processInstance = service.execute( startProcessCommand );
StartProcessCommand startProcessCommand = new StartProcessCommand(); startProcessCommand.setProcessId( "org.drools.test.TestProcess" ); ProcessInstance processInstance = service.execute( startProcessCommand );
@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\"")); }
@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\"")); }
@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); }
@Test public void verifyNsElementImplFound() throws Exception { StartProcessCommand cmd = new StartProcessCommand(); cmd.setProcessId("deployment-forgot-class"); Map<String, Object> params = new HashMap<String, Object>(); params.put("test", new Person("bob")); cmd.setParameters(params); JAXBContext jaxbContext = JAXBContext.newInstance(StartProcessCommand.class, Person.class); String xmlStr = serialize(jaxbContext, true, cmd); jaxbContext = JAXBContext.newInstance(StartProcessCommand.class); StartProcessCommand copyCmd = (StartProcessCommand) deserialize(jaxbContext, xmlStr); ProcessRequestBean procReqBean = new ProcessRequestBean(); String msg = null; try { procReqBean.checkThatUserDefinedClassesWereUnmarshalled(copyCmd.getParameters()); } catch( Exception e ) { assertTrue( "Did not expect an " + e.getClass().getSimpleName() + " instance", e instanceof KieRemoteServicesDeploymentException ); msg = e.getMessage(); } assertNotNull( "Expected exception to be thrown", msg ); msg = msg.replaceFirst("[^']*'", ""); assertEquals( "Exception did not refernce class type correctly.", Person.class.getSimpleName().toLowerCase() + "'", msg ); }
@Test public void testProcess() throws Exception { BatchExecutionCommandImpl cmd = new BatchExecutionCommandImpl(); cmd.setLookup("ksession1"); StartProcessCommand start = new StartProcessCommand("org.drools.actions", "process-instance-id"); start.putParameter("person", new Person("lucaz", 25)); start.putParameter("person2", new Person("hadrian", 25)); start.putParameter("person3", new Person("baunax", 21)); cmd.addCommand(start); StringWriter xmlReq = new StringWriter(); Marshaller marshaller = getJaxbContext().createMarshaller(); marshaller.setProperty("jaxb.formatted.output", true); marshaller.marshal(cmd, xmlReq); logger.debug(xmlReq.toString()); byte[] xmlResp = (byte[])template.requestBody("direct:test-with-session", xmlReq.toString()); assertNotNull(xmlResp); logger.debug(new String(xmlResp)); ExecutionResults resp = (ExecutionResults)getJaxbContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xmlResp)); assertNotNull(resp); assertNotNull(resp.getValue("process-instance-id")); }
@Test public void testProcess() throws Exception { BatchExecutionCommandImpl cmd = new BatchExecutionCommandImpl(); cmd.setLookup( "ksession1" ); StartProcessCommand start = new StartProcessCommand( "org.drools.actions" , "process-instance-id" ); start.putParameter( "person", new Person( "lucaz", 25 ) ); start.putParameter( "person2", new Person( "hadrian", 25 ) ); start.putParameter( "person3", new Person( "baunax", 21 ) ); cmd.getCommands().add( start ); StringWriter xmlReq = new StringWriter(); Marshaller marshaller = getJaxbContext().createMarshaller(); marshaller.setProperty( "jaxb.formatted.output", true ); marshaller.marshal( cmd, xmlReq ); System.out.println( xmlReq.toString() ); byte[] xmlResp = (byte[]) template.requestBody( "direct:test-with-session", xmlReq.toString() ); assertNotNull( xmlResp ); System.out.println( new String( xmlResp ) ); ExecutionResults resp = (ExecutionResults) getJaxbContext().createUnmarshaller().unmarshal( new ByteArrayInputStream( xmlResp ) ); assertNotNull( resp ); assertNotNull( resp.getValue( "process-instance-id" ) ); }
@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); }
Command<?> cmd = new StartProcessCommand(PROCESS_ID_1); int oompaProcessingResultIndex = 0; JaxbCommandsRequest req = new JaxbCommandsRequest(DEPLOYMENT_ID, cmd);
@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 ); }
cmdsRequest = new JaxbCommandsRequest(DEPLOYMENT_ID, new StartProcessCommand(TEST_PROCESS_DEF_NAME)); cmdsRequest.setCorrelationKeyString("anton"); JaxbCommandsResponse
req.setProcessInstanceId(43l); req.setVersion("6.0.1.0"); StartProcessCommand spCmd = new StartProcessCommand("test.proc.yaml"); cmds.add(spCmd); spCmd.getParameters().put("one", "a"); assertEquals(((StartProcessCommand) newReq.getCommands().get(0)).getParameters().get("two"), "B"); req = new JaxbCommandsRequest("deployment", new StartProcessCommand("org.jbpm.humantask")); newReq = testRoundTrip(req);
String val = "initial-val"; params.put("test", val); Command cmd = new StartProcessCommand("StructureRef"); ((StartProcessCommand) cmd).setParameters(params); ProcessInstance processInstance = ksession.execute((StartProcessCommand) cmd);
@Test public void commandsResponseTest() throws Exception { this.setupDataSource = true; this.sessionPersistence = true; super.setUp(); RuntimeEngine runtimeEngine = createRuntimeManager("BPMN2-StringStructureRef.bpmn2").getRuntimeEngine(null); KieSession ksession = runtimeEngine.getKieSession(); Map<String, Object> params = new HashMap<String, Object>(); String val = "initial-val"; params.put("test", val); Command cmd = new StartProcessCommand("StructureRef"); ((StartProcessCommand) cmd).setParameters(params); ProcessInstance processInstance = ksession.execute((StartProcessCommand) cmd); assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE); JaxbCommandsResponse resp = new JaxbCommandsResponse(); resp.setDeploymentId("deploy"); resp.setProcessInstanceId(processInstance.getId()); resp.addResult(processInstance, 0, cmd); testRoundTrip(resp); cmd = new GetTaskAssignedAsBusinessAdminCommand(); List<TaskSummary> result = new ArrayList<TaskSummary>(); resp = new JaxbCommandsResponse(); resp.addResult(result, 0, cmd); cmd = new GetTasksByProcessInstanceIdCommand(); List<Long> resultTwo = new ArrayList<Long>(); resp.addResult(resultTwo, 1, cmd); Object newResp = testRoundTrip(resp); assertNotNull(newResp); assertEquals(2, ((JaxbCommandsResponse) newResp).getResponses().size()); }