@Test public void testUnmarshalPojo() throws Exception { MockEndpoint mock = getMockEndpoint("mock:reversePojo"); mock.expectedMessageCount(1); mock.message(0).body().isInstanceOf(TestPojo.class); String json = "<pojo name=\"Camel\"/>"; template.sendBodyAndHeader( "direct:backPojo", json, JacksonXMLConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); assertMockEndpointsSatisfied(); TestPojo pojo = mock.getReceivedExchanges().get(0).getIn().getBody(TestPojo.class); assertNotNull(pojo); assertEquals("Camel", pojo.getName()); }
/** * <功能简述> <功能详细描述> * * @param testPojo * @param facts [参数说明] * @return void [返回类型说明] * @exception throws [异常类型] [异常说明] * @see [类、类#方法、类#成员] */ @RuleMethod(rule = "minAgeRule", serviceType = "processLoanBill", name = "年龄不能小于18岁") public void minAgeRule( TestPojo testPojo, TestPojoDao testPojoDao, @RuleMethodParam Map<String, ?> facts, @RuleMethodResult ArrayList<ProcessRule> violateProcessRuleList) { Object globalValue1 = RuleSessionContext.getContext().getGlobals().get("globalKey1"); System.out.println(globalValue1); System.out.println(testPojo != null ? testPojo.getTest() : "null"); System.out.println(testPojoDao != null ? testPojoDao.call() : "null"); // 如果违背某规则,则将对应规则的实例放入 violateProcessRuleList.add(new ProcessRule("年龄不能小于18岁")); }