@Test(expected = TemporaryException.class) public void processWebServiceExceptionTest() throws Exception { when(sendMessageToRecipientResponder.sendMessageToRecipient(anyString(), any(SendMessageToRecipientType.class))) .thenThrow(new WebServiceException()); sendMessageProcessor.process(XML_BODY, INTYG_ID, LOGICAL_ADDRESS); }
public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { try { SendMessageToRecipientType parameters = SendMessageToRecipientTypeConverter.fromXml(xmlBody); SendMessageToRecipientResponseType response = sendMessageToRecipientResponder.sendMessageToRecipient(logicalAddress, parameters); ResultType result = response.getResult(); switch (result.getResultCode()) { case OK: case INFO: return; case ERROR: switch (result.getErrorId()) { case REVOKED: case VALIDATION_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as PermanentException", intygsId, result.getResultText(), result.getErrorId()); throw new PermanentException(result.getResultText()); case APPLICATION_ERROR: case TECHNICAL_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as TemporaryException", intygsId, result.getResultText(), result.getErrorId()); throw new TemporaryException(result.getResultText()); } } } catch (UnmarshallingFailureException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Rethrowing as PermanentException", intygsId, e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }
SendMessageToRecipientProcessor { public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { try { SendMessageToRecipientType parameters = SendMessageToRecipientTypeConverter.fromXml(xmlBody); SendMessageToRecipientResponseType response = sendMessageToRecipientResponder.sendMessageToRecipient(logicalAddress, parameters); ResultType result = response.getResult(); switch (result.getResultCode()) { case OK: case INFO: return; case ERROR: switch (result.getErrorId()) { case REVOKED: case VALIDATION_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as PermanentException", intygsId, result.getResultText(), result.getErrorId()); throw new PermanentException(result.getResultText()); case APPLICATION_ERROR: case TECHNICAL_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as TemporaryException", intygsId, result.getResultText(), result.getErrorId()); throw new TemporaryException(result.getResultText()); } } } catch (UnmarshallingFailureException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Rethrowing as PermanentException", intygsId, e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } } }
SendMessageToRecipientProcessor { public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { try { SendMessageToRecipientType parameters = SendMessageToRecipientTypeConverter.fromXml(xmlBody); SendMessageToRecipientResponseType response = sendMessageToRecipientResponder.sendMessageToRecipient(logicalAddress, parameters); ResultType result = response.getResult(); switch (result.getResultCode()) { case OK: case INFO: return; case ERROR: switch (result.getErrorId()) { case REVOKED: case VALIDATION_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as PermanentException", intygsId, result.getResultText(), result.getErrorId()); throw new PermanentException(result.getResultText()); case APPLICATION_ERROR: case TECHNICAL_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as TemporaryException", intygsId, result.getResultText(), result.getErrorId()); throw new TemporaryException(result.getResultText()); } } } catch (UnmarshallingFailureException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Rethrowing as PermanentException", intygsId, e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  }
SendMessageToRecipientProcessor { public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { try { SendMessageToRecipientType parameters = SendMessageToRecipientTypeConverter.fromXml(xmlBody); SendMessageToRecipientResponseType response = sendMessageToRecipientResponder.sendMessageToRecipient(logicalAddress, parameters); ResultType result = response.getResult(); switch (result.getResultCode()) { case OK: case INFO: return; case ERROR: switch (result.getErrorId()) { case REVOKED: case VALIDATION_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as PermanentException", intygsId, result.getResultText(), result.getErrorId()); throw new PermanentException(result.getResultText()); case APPLICATION_ERROR: case TECHNICAL_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as TemporaryException", intygsId, result.getResultText(), result.getErrorId()); throw new TemporaryException(result.getResultText()); } } } catch (UnmarshallingFailureException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Rethrowing as PermanentException", intygsId, e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId,
        @Header(Constants.LOGICAL_ADDRESS) String logicalAddress); }
SendMessageToRecipientProcessor { public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { try { SendMessageToRecipientType parameters = SendMessageToRecipientTypeConverter.fromXml(xmlBody); SendMessageToRecipientResponseType response = sendMessageToRecipientResponder.sendMessageToRecipient(logicalAddress, parameters); ResultType result = response.getResult(); switch (result.getResultCode()) { case OK: case INFO: return; case ERROR: switch (result.getErrorId()) { case REVOKED: case VALIDATION_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as PermanentException", intygsId, result.getResultText(), result.getErrorId()); throw new PermanentException(result.getResultText()); case APPLICATION_ERROR: case TECHNICAL_ERROR: LOG.error( "Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as TemporaryException", intygsId, result.getResultText(), result.getErrorId()); throw new TemporaryException(result.getResultText()); } } } catch (UnmarshallingFailureException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Rethrowing as PermanentException", intygsId, e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId,
        @Header(Constants.LOGICAL_ADDRESS) String logicalAddress);  }