ProcessReceipts extends AbstractBaseHandler { @Override protected InvocationResponse doProcessing(final IMessageProcessingContext procCtx, final Logger log) throws PersistenceException { log.debug("Check for received receipts in message."); final Collection<IReceiptEntity> receipts = procCtx.getReceivedReceipts(); if (!Utils.isNullOrEmpty(receipts)) { log.debug("Message contains " + receipts.size() + " Receipts signals, start processing"); for (final IReceiptEntity r : receipts) if (r.getCurrentProcessingState().getState() != ProcessingState.FAILURE) processReceipt(r, procCtx, log); log.debug("All Receipts in message processed"); } return InvocationResponse.CONTINUE; }    }
@Test public void testDoProcessing() throws Exception { PMode pmode = TestUtils.create1WaySendPushPMode(); Leg leg = pmode.getLeg(Label.REQUEST); ReceiptConfiguration receiptConfiguration = new ReceiptConfiguration(); leg.setReceiptConfiguration(receiptConfiguration); HolodeckB2BCore.getPModeSet().add(pmode); MessageContext mc = new MessageContext(); mc.setFLOW(MessageContext.IN_FLOW); StorageManager storageManager = HolodeckB2BCore.getStorageManager(); UserMessage userMessage = new UserMessage(); userMessage.setMessageId(MessageIdUtils.createMessageId()); userMessage.setPModeId(pmode.getId()); IUserMessageEntity userMessageEntity = storageManager.storeOutGoingMessageUnit(userMessage); storageManager.setProcessingState(userMessageEntity, ProcessingState.AWAITING_RECEIPT); Receipt receipt = new Receipt(); receipt.setRefToMessageId(userMessage.getMessageId()); receipt.setMessageId(MessageIdUtils.createMessageId()); IReceiptEntity receiptEntity = storageManager.storeIncomingMessageUnit(receipt); IMessageProcessingContext procCtx = MessageProcessingContext.getFromMessageContext(mc); procCtx.addReceivedReceipt(receiptEntity); try { assertEquals(Handler.InvocationResponse.CONTINUE, new ProcessReceipts().invoke(mc)); } catch (Exception e) { fail(e.getMessage()); } assertEquals(ProcessingState.DELIVERED, HolodeckB2BCoreInterface.getQueryManager() .getMessageUnitsWithId(userMessage.getMessageId()) .iterator().next().getCurrentProcessingState().getState()); assertEquals(ProcessingState.READY_FOR_DELIVERY, receiptEntity.getCurrentProcessingState().getState()); }