@Test(expected = PermanentException.class) public void testUnparsableBodyThrowsPermanentException() throws TemporaryException, PermanentException { try { testee.process("this-is-not-json", INTYG_ID, INTYG_TYP, LOGICAL_ADDRESS); } finally { verifyNoInteractions(registerApprovedReceiversClient); } }
public void process(@Body String jsonBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.INTYGS_TYP) String intygsTyp, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { List<ReceiverApprovalStatus> receiverIds = transformMessageBodyToReceiverList(jsonBody); try { checkArgument(StringUtils.isNotEmpty(intygsId), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_TYP); RegisterApprovedReceiversType req = new RegisterApprovedReceiversType(); IntygId intygId = new IntygId(); intygId.setExtension(intygsId); req.setIntygId(intygId); TypAvIntyg typAvIntyg = new TypAvIntyg(); typAvIntyg.setCode(intygsTyp); req.setTypAvIntyg(typAvIntyg); req.getApprovedReceivers().addAll(receiverIds); RegisterApprovedReceiversResponseType responseType = registerApprovedReceiversClient.registerApprovedReceivers(logicalAddress, req); if (responseType.getResult().getResultCode() == ResultCodeType.ERROR) { throw new PermanentException(responseType.getResult().getResultText()); } } catch (IllegalArgumentException e) { LOG.error("RegisterApprovedReceiversProcessor message processing failed due to IllegalArgumentException, message: {}", e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to RegisterApprovedReceivers for intyg {} caused an error: {}. Will retry.", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }
RegisterApprovedReceiversProcessor { public void process(@Body String jsonBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.INTYGS_TYP) String intygsTyp, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { List<ReceiverApprovalStatus> receiverIds = transformMessageBodyToReceiverList(jsonBody); try { checkArgument(StringUtils.isNotEmpty(intygsId), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_TYP); RegisterApprovedReceiversType req = new RegisterApprovedReceiversType(); IntygId intygId = new IntygId(); intygId.setExtension(intygsId); req.setIntygId(intygId); TypAvIntyg typAvIntyg = new TypAvIntyg(); typAvIntyg.setCode(intygsTyp); req.setTypAvIntyg(typAvIntyg); req.getApprovedReceivers().addAll(receiverIds); RegisterApprovedReceiversResponseType responseType = registerApprovedReceiversClient.registerApprovedReceivers(logicalAddress, req); if (responseType.getResult().getResultCode() == ResultCodeType.ERROR) { throw new PermanentException(responseType.getResult().getResultText()); } } catch (IllegalArgumentException e) { LOG.error("RegisterApprovedReceiversProcessor message processing failed due to IllegalArgumentException, message: {}", e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to RegisterApprovedReceivers for intyg {} caused an error: {}. Will retry.", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } } }
RegisterApprovedReceiversProcessor { public void process(@Body String jsonBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.INTYGS_TYP) String intygsTyp, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { List<ReceiverApprovalStatus> receiverIds = transformMessageBodyToReceiverList(jsonBody); try { checkArgument(StringUtils.isNotEmpty(intygsId), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_TYP); RegisterApprovedReceiversType req = new RegisterApprovedReceiversType(); IntygId intygId = new IntygId(); intygId.setExtension(intygsId); req.setIntygId(intygId); TypAvIntyg typAvIntyg = new TypAvIntyg(); typAvIntyg.setCode(intygsTyp); req.setTypAvIntyg(typAvIntyg); req.getApprovedReceivers().addAll(receiverIds); RegisterApprovedReceiversResponseType responseType = registerApprovedReceiversClient.registerApprovedReceivers(logicalAddress, req); if (responseType.getResult().getResultCode() == ResultCodeType.ERROR) { throw new PermanentException(responseType.getResult().getResultText()); } } catch (IllegalArgumentException e) { LOG.error("RegisterApprovedReceiversProcessor message processing failed due to IllegalArgumentException, message: {}", e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to RegisterApprovedReceivers for intyg {} caused an error: {}. Will retry.", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  }
RegisterApprovedReceiversProcessor { public void process(@Body String jsonBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.INTYGS_TYP) String intygsTyp, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { List<ReceiverApprovalStatus> receiverIds = transformMessageBodyToReceiverList(jsonBody); try { checkArgument(StringUtils.isNotEmpty(intygsId), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_TYP); RegisterApprovedReceiversType req = new RegisterApprovedReceiversType(); IntygId intygId = new IntygId(); intygId.setExtension(intygsId); req.setIntygId(intygId); TypAvIntyg typAvIntyg = new TypAvIntyg(); typAvIntyg.setCode(intygsTyp); req.setTypAvIntyg(typAvIntyg); req.getApprovedReceivers().addAll(receiverIds); RegisterApprovedReceiversResponseType responseType = registerApprovedReceiversClient.registerApprovedReceivers(logicalAddress, req); if (responseType.getResult().getResultCode() == ResultCodeType.ERROR) { throw new PermanentException(responseType.getResult().getResultText()); } } catch (IllegalArgumentException e) { LOG.error("RegisterApprovedReceiversProcessor message processing failed due to IllegalArgumentException, message: {}", e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to RegisterApprovedReceivers for intyg {} caused an error: {}. Will retry.", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  void process(@Body String jsonBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.INTYGS_TYP) String intygsTyp,
        @Header(Constants.LOGICAL_ADDRESS) String logicalAddress); }
RegisterApprovedReceiversProcessor { public void process(@Body String jsonBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.INTYGS_TYP) String intygsTyp, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException { List<ReceiverApprovalStatus> receiverIds = transformMessageBodyToReceiverList(jsonBody); try { checkArgument(StringUtils.isNotEmpty(intygsId), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message of type %s does not have a %s header.", Constants.REGISTER_APPROVED_RECEIVERS_MESSAGE, Constants.INTYGS_TYP); RegisterApprovedReceiversType req = new RegisterApprovedReceiversType(); IntygId intygId = new IntygId(); intygId.setExtension(intygsId); req.setIntygId(intygId); TypAvIntyg typAvIntyg = new TypAvIntyg(); typAvIntyg.setCode(intygsTyp); req.setTypAvIntyg(typAvIntyg); req.getApprovedReceivers().addAll(receiverIds); RegisterApprovedReceiversResponseType responseType = registerApprovedReceiversClient.registerApprovedReceivers(logicalAddress, req); if (responseType.getResult().getResultCode() == ResultCodeType.ERROR) { throw new PermanentException(responseType.getResult().getResultText()); } } catch (IllegalArgumentException e) { LOG.error("RegisterApprovedReceiversProcessor message processing failed due to IllegalArgumentException, message: {}", e.getMessage()); throw new PermanentException(e.getMessage()); } catch (WebServiceException e) { LOG.error("Call to RegisterApprovedReceivers for intyg {} caused an error: {}. Will retry.", intygsId, e.getMessage()); throw new TemporaryException(e.getMessage()); } }  void process(@Body String jsonBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.INTYGS_TYP) String intygsTyp,
        @Header(Constants.LOGICAL_ADDRESS) String logicalAddress);  }