ProcessErrors extends AbstractBaseHandler { @Override protected InvocationResponse doProcessing(final IMessageProcessingContext procCtx, final Logger log) throws PersistenceException { log.debug("Check for received errors in message."); final Collection<IErrorMessageEntity> errorSignals = procCtx.getReceivedErrors(); if (!Utils.isNullOrEmpty(errorSignals)) { log.debug("Message contains " + errorSignals.size() + " Error signals, start processing"); for (final IErrorMessageEntity e : errorSignals) if (e.getCurrentProcessingState().getState() != ProcessingState.FAILURE) processErrorSignal(e, procCtx, log); log.debug("All Error Signals processed"); } return InvocationResponse.CONTINUE; }    }
@Test public void testDoProcessing() throws Exception { UserMessage userMessage = new UserMessage(); userMessage.setMessageId(MessageIdUtils.createMessageId()); MessageContext mc = new MessageContext(); mc.setServerSide(true); mc.setFLOW(MessageContext.IN_FLOW); mc.setAxisService(new AxisService("TEST")); EbmsError ebmsError = new EbmsError(); ebmsError.setSeverity(IEbmsError.Severity.failure); ebmsError.setErrorCode("some_error_code"); ebmsError.setRefToMessageInError(userMessage.getMessageId()); ebmsError.setMessage("some error message"); ErrorMessage errorMessage = new ErrorMessage(ebmsError); errorMessage.setMessageId(MessageIdUtils.createMessageId()); errorMessage.setRefToMessageId(userMessage.getMessageId()); StorageManager storageManager = HolodeckB2BCore.getStorageManager(); storageManager.storeOutGoingMessageUnit(userMessage); IErrorMessageEntity errorMessageEntity = storageManager.storeIncomingMessageUnit(errorMessage); storageManager.setProcessingState(errorMessageEntity, ProcessingState.RECEIVED); IMessageProcessingContext procCtx = MessageProcessingContext.getFromMessageContext(mc); procCtx.addReceivedError(errorMessageEntity); try { Handler.InvocationResponse invokeResp = handler.invoke(mc); assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp); } catch (Exception e) { fail(e.getMessage()); } assertEquals(ProcessingState.FAILURE, HolodeckB2BCoreInterface.getQueryManager().getMessageUnitsWithId(userMessage.getMessageId()).iterator() .next().getCurrentProcessingState().getState()); assertEquals(ProcessingState.READY_FOR_DELIVERY, errorMessageEntity.getCurrentProcessingState().getState()); }