@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 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 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); }
@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 ); }
Map<String, Object> params = cmd.getParameters(); for( Entry<String, Object> entry : params.entrySet() ) { assertNotNull( entry.getKey(), entry.getValue() );
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");