DefaultResourceProcessor implements ResourceProcessor { @Override public ResponseMessageContainer process(RequestMessageContainer requestMessages) { preProcess(requestMessages); ResponseMessageContainer responseMessages = doProcess(requestMessages); postProcess(requestMessages, responseMessages); return responseMessages; }  @Override ResponseMessageContainer process(RequestMessageContainer requestMessages); @Override void setResourceManager(ResourceManager resourceManager); @Override void setProcessContinuationStrategy(ProcessContinuationStrategy processContinuationStrategy); @Override void setMessageMetadata(MessageMetadata messageMetadata); @Override void setResourceConfigurationParameter(ResourceConfigurationParameter resourceConfigurationParameter);  }
@Test public void testProcess() throws Exception { final RequestMessage reqMsg1 = new RequestMessage(messageMetadata) { { put(messageMetadata.ACTION, "findById"); put(messageMetadata.REQUEST_PATH, "/resname1/1/"); } }; final RequestMessage reqMsg2 = new RequestMessage(messageMetadata) { { put(messageMetadata.ACTION, "action"); put(messageMetadata.REQUEST_PATH, "/resname2"); } }; final RequestMessageContainer reqContainer = new RequestMessageContainer(true) { { addMessage(reqMsg1); addMessage(reqMsg2); } }; final Object item1 = new Object(); final ResponseMessage resMsg1 = new ResponseMessage(reqMsg1) { { put(messageMetadata.RESPONSE_STATUS, ResourceActionStatus.OK, MessageSource.PROCESSOR); put(messageMetadata.RESPONSE_BODY, item1, MessageSource.PROCESSOR); put(messageMetadata.PROCESSING_STATUS, ResourceProcessingStatus.CONTINUE, MessageSource.PROCESSOR); } }; final Object item2 = new Object(); final ResponseMessage resMsg2 = new ResponseMessage(reqMsg2) { { put(messageMetadata.RESPONSE_STATUS, ResourceActionStatus.OK, MessageSource.PROCESSOR); put(messageMetadata.RESPONSE_BODY, item2, MessageSource.PROCESSOR); put(messageMetadata.PROCESSING_STATUS, ResourceProcessingStatus.CONTINUE, MessageSource.PROCESSOR); } }; final ResponseMessageContainer expected = new ResponseMessageContainer(true) { { addMessage(resMsg1); addMessage(resMsg2); } }; new Expectations() { ResourceMethodInvoker invoker1; ResourceMethodInvoker invoker2; { setField(target, resourceManager); resourceManager.getResourceMethodByName("resname1", "findById", reqMsg1); result = invoker1; invoker1.invoke(reqMsg1); result = item1; resourceManager.getResourceMethodByName("resname2", "action", reqMsg2); result = invoker2; invoker2.invoke(reqMsg2); result = item2; } }; ResponseMessageContainer actual = target.process(reqContainer); KeyInfoUtil.printKeyInfo(actual); KeyInfoUtil.printKeyInfo(expected); assertThat(actual.getMessages().size(), is(equalTo(expected.getMessages().size()))); for (ResponseMessage msg : expected.getMessages()) { assertThat(actual.getMessages().contains(msg), is(true)); } }