@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 ); }
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);
@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()); }