@Test(expected = TemporaryException.class) public void testSendCertificateThrowsTemporaryOnApplicationError() throws Exception { SendCertificateToRecipientResponseType response = createResponse(ResultCodeType.ERROR, ErrorIdType.APPLICATION_ERROR); when(sendServiceClient.sendCertificate(INTYGS_ID1, PERSON_ID1, SKICKAT_AV, RECIPIENT1, LOGICAL_ADDRESS1)).thenReturn(response); certificateSendProcessor.process(SKICKAT_AV, INTYGS_ID1, PERSON_ID1, RECIPIENT1, LOGICAL_ADDRESS1); verify(sendServiceClient).sendCertificate(INTYGS_ID1, PERSON_ID1, SKICKAT_AV, RECIPIENT1, LOGICAL_ADDRESS1); }
public void process(@Body String skickatAv, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.PERSON_ID) String personId, @Header(Constants.RECIPIENT) String recipient, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { SendCertificateToRecipientResponseType response; try { response = sendServiceClient.sendCertificate(intygsId, personId, skickatAv, recipient, logicalAddress); final ResultType result = response.getResult(); final String resultText = result.getResultText(); if (ResultCodeType.ERROR == result.getResultCode()) { LOG.warn("Error occured when trying to send intyg '{}'; {}", intygsId, resultText); switch (result.getErrorId()) { case APPLICATION_ERROR: case TECHNICAL_ERROR: throw new TemporaryException(resultText); case REVOKED: case VALIDATION_ERROR: throw new PermanentException(resultText); } } else { if (ResultCodeType.INFO.equals(result.getResultCode())) { LOG.warn("Warning occured when trying to send intyg '{}'; {}. Will not requeue.", intygsId, resultText); } } } catch (WebServiceException e) { LOG.warn("Call to send intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }
CertificateSendProcessor { public void process(@Body String skickatAv, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.PERSON_ID) String personId, @Header(Constants.RECIPIENT) String recipient, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { SendCertificateToRecipientResponseType response; try { response = sendServiceClient.sendCertificate(intygsId, personId, skickatAv, recipient, logicalAddress); final ResultType result = response.getResult(); final String resultText = result.getResultText(); if (ResultCodeType.ERROR == result.getResultCode()) { LOG.warn("Error occured when trying to send intyg '{}'; {}", intygsId, resultText); switch (result.getErrorId()) { case APPLICATION_ERROR: case TECHNICAL_ERROR: throw new TemporaryException(resultText); case REVOKED: case VALIDATION_ERROR: throw new PermanentException(resultText); } } else { if (ResultCodeType.INFO.equals(result.getResultCode())) { LOG.warn("Warning occured when trying to send intyg '{}'; {}. Will not requeue.", intygsId, resultText); } } } catch (WebServiceException e) { LOG.warn("Call to send intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } } }
CertificateSendProcessor { public void process(@Body String skickatAv, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.PERSON_ID) String personId, @Header(Constants.RECIPIENT) String recipient, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { SendCertificateToRecipientResponseType response; try { response = sendServiceClient.sendCertificate(intygsId, personId, skickatAv, recipient, logicalAddress); final ResultType result = response.getResult(); final String resultText = result.getResultText(); if (ResultCodeType.ERROR == result.getResultCode()) { LOG.warn("Error occured when trying to send intyg '{}'; {}", intygsId, resultText); switch (result.getErrorId()) { case APPLICATION_ERROR: case TECHNICAL_ERROR: throw new TemporaryException(resultText); case REVOKED: case VALIDATION_ERROR: throw new PermanentException(resultText); } } else { if (ResultCodeType.INFO.equals(result.getResultCode())) { LOG.warn("Warning occured when trying to send intyg '{}'; {}. Will not requeue.", intygsId, resultText); } } } catch (WebServiceException e) { LOG.warn("Call to send intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  }
CertificateSendProcessor { public void process(@Body String skickatAv, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.PERSON_ID) String personId, @Header(Constants.RECIPIENT) String recipient, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { SendCertificateToRecipientResponseType response; try { response = sendServiceClient.sendCertificate(intygsId, personId, skickatAv, recipient, logicalAddress); final ResultType result = response.getResult(); final String resultText = result.getResultText(); if (ResultCodeType.ERROR == result.getResultCode()) { LOG.warn("Error occured when trying to send intyg '{}'; {}", intygsId, resultText); switch (result.getErrorId()) { case APPLICATION_ERROR: case TECHNICAL_ERROR: throw new TemporaryException(resultText); case REVOKED: case VALIDATION_ERROR: throw new PermanentException(resultText); } } else { if (ResultCodeType.INFO.equals(result.getResultCode())) { LOG.warn("Warning occured when trying to send intyg '{}'; {}. Will not requeue.", intygsId, resultText); } } } catch (WebServiceException e) { LOG.warn("Call to send intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  void process(@Body String skickatAv,
        @Header(Constants.INTYGS_ID) String intygsId,
        @Header(Constants.PERSON_ID) String personId,
        @Header(Constants.RECIPIENT) String recipient,
        @Header(Constants.LOGICAL_ADDRESS) String logicalAddress); }
CertificateSendProcessor { public void process(@Body String skickatAv, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.PERSON_ID) String personId, @Header(Constants.RECIPIENT) String recipient, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { SendCertificateToRecipientResponseType response; try { response = sendServiceClient.sendCertificate(intygsId, personId, skickatAv, recipient, logicalAddress); final ResultType result = response.getResult(); final String resultText = result.getResultText(); if (ResultCodeType.ERROR == result.getResultCode()) { LOG.warn("Error occured when trying to send intyg '{}'; {}", intygsId, resultText); switch (result.getErrorId()) { case APPLICATION_ERROR: case TECHNICAL_ERROR: throw new TemporaryException(resultText); case REVOKED: case VALIDATION_ERROR: throw new PermanentException(resultText); } } else { if (ResultCodeType.INFO.equals(result.getResultCode())) { LOG.warn("Warning occured when trying to send intyg '{}'; {}. Will not requeue.", intygsId, resultText); } } } catch (WebServiceException e) { LOG.warn("Call to send intyg {} caused an error: {}. Will retry", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  void process(@Body String skickatAv,
        @Header(Constants.INTYGS_ID) String intygsId,
        @Header(Constants.PERSON_ID) String personId,
        @Header(Constants.RECIPIENT) String recipient,
        @Header(Constants.LOGICAL_ADDRESS) String logicalAddress);  }