@Test public void testMissingParameter() throws JMSException { Message textMessage = createMessage(); when(textMessage.getStringProperty(CERTIFICATE_ID)).thenReturn(null); testee.onMessage(textMessage); verifyNoInteractions(notificationService); }
@Override @JmsListener(destination = "${internal.notification.queueName}") public void onMessage(Message message) { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; try { String intygsId = textMessage.getStringProperty(CERTIFICATE_ID); String intygsTyp = textMessage.getStringProperty(CERTIFICATE_TYPE); String intygsTypVersion = textMessage.getStringProperty(CERTIFICATE_TYPE_VERSION); String enhetsId = textMessage.getStringProperty(CARE_UNIT_ID); checkArgument(StringUtils.isNotEmpty(intygsId), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE); checkArgument(StringUtils.isNotEmpty(intygsTypVersion), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE_VERSION); checkArgument(StringUtils.isNotEmpty(enhetsId), "Message on queue %s does not have a %s header.", queueName, CARE_UNIT_ID); if (!integreradeEnheterRegistry.isEnhetIntegrerad(enhetsId, intygsTyp)) { LOG.debug("Not forwarding internal notification to care system, care unit '{}' is not integrated.", enhetsId); return; } ModuleApi moduleApi = intygModuleRegistry.getModuleApi(intygsTyp, intygsTypVersion); CertificateResponse certificateResponse = moduleApi.getCertificate(intygsId, logicalAddress, "HSVARD"); Utlatande utlatande = certificateResponse.getUtlatande(); notificationService.forwardInternalNotification(utlatande.getId(), utlatande.getTyp(), utlatande, HandelsekodEnum.SKICKA); } catch (IllegalArgumentException e) { LOG.error("Could not process internal notification, message is missing required header: {}", e.getMessage()); } catch (JMSException | ModuleNotFoundException | ModuleException e) { LOG.error("Caught {} transforming internal notification to external notification. Message: {}", e.getMessage()); } } }
InternalNotificationMessageListener implements MessageListener { @Override @JmsListener(destination = "${internal.notification.queueName}") public void onMessage(Message message) { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; try { String intygsId = textMessage.getStringProperty(CERTIFICATE_ID); String intygsTyp = textMessage.getStringProperty(CERTIFICATE_TYPE); String intygsTypVersion = textMessage.getStringProperty(CERTIFICATE_TYPE_VERSION); String enhetsId = textMessage.getStringProperty(CARE_UNIT_ID); checkArgument(StringUtils.isNotEmpty(intygsId), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE); checkArgument(StringUtils.isNotEmpty(intygsTypVersion), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE_VERSION); checkArgument(StringUtils.isNotEmpty(enhetsId), "Message on queue %s does not have a %s header.", queueName, CARE_UNIT_ID); if (!integreradeEnheterRegistry.isEnhetIntegrerad(enhetsId, intygsTyp)) { LOG.debug("Not forwarding internal notification to care system, care unit '{}' is not integrated.", enhetsId); return; } ModuleApi moduleApi = intygModuleRegistry.getModuleApi(intygsTyp, intygsTypVersion); CertificateResponse certificateResponse = moduleApi.getCertificate(intygsId, logicalAddress, "HSVARD"); Utlatande utlatande = certificateResponse.getUtlatande(); notificationService.forwardInternalNotification(utlatande.getId(), utlatande.getTyp(), utlatande, HandelsekodEnum.SKICKA); } catch (IllegalArgumentException e) { LOG.error("Could not process internal notification, message is missing required header: {}", e.getMessage()); } catch (JMSException | ModuleNotFoundException | ModuleException e) { LOG.error("Caught {} transforming internal notification to external notification. Message: {}", e.getMessage()); } } } }
InternalNotificationMessageListener implements MessageListener { @Override @JmsListener(destination = "${internal.notification.queueName}") public void onMessage(Message message) { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; try { String intygsId = textMessage.getStringProperty(CERTIFICATE_ID); String intygsTyp = textMessage.getStringProperty(CERTIFICATE_TYPE); String intygsTypVersion = textMessage.getStringProperty(CERTIFICATE_TYPE_VERSION); String enhetsId = textMessage.getStringProperty(CARE_UNIT_ID); checkArgument(StringUtils.isNotEmpty(intygsId), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE); checkArgument(StringUtils.isNotEmpty(intygsTypVersion), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE_VERSION); checkArgument(StringUtils.isNotEmpty(enhetsId), "Message on queue %s does not have a %s header.", queueName, CARE_UNIT_ID); if (!integreradeEnheterRegistry.isEnhetIntegrerad(enhetsId, intygsTyp)) { LOG.debug("Not forwarding internal notification to care system, care unit '{}' is not integrated.", enhetsId); return; } ModuleApi moduleApi = intygModuleRegistry.getModuleApi(intygsTyp, intygsTypVersion); CertificateResponse certificateResponse = moduleApi.getCertificate(intygsId, logicalAddress, "HSVARD"); Utlatande utlatande = certificateResponse.getUtlatande(); notificationService.forwardInternalNotification(utlatande.getId(), utlatande.getTyp(), utlatande, HandelsekodEnum.SKICKA); } catch (IllegalArgumentException e) { LOG.error("Could not process internal notification, message is missing required header: {}", e.getMessage()); } catch (JMSException | ModuleNotFoundException | ModuleException e) { LOG.error("Caught {} transforming internal notification to external notification. Message: {}", e.getMessage()); } } }  }
InternalNotificationMessageListener implements MessageListener { @Override @JmsListener(destination = "${internal.notification.queueName}") public void onMessage(Message message) { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; try { String intygsId = textMessage.getStringProperty(CERTIFICATE_ID); String intygsTyp = textMessage.getStringProperty(CERTIFICATE_TYPE); String intygsTypVersion = textMessage.getStringProperty(CERTIFICATE_TYPE_VERSION); String enhetsId = textMessage.getStringProperty(CARE_UNIT_ID); checkArgument(StringUtils.isNotEmpty(intygsId), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE); checkArgument(StringUtils.isNotEmpty(intygsTypVersion), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE_VERSION); checkArgument(StringUtils.isNotEmpty(enhetsId), "Message on queue %s does not have a %s header.", queueName, CARE_UNIT_ID); if (!integreradeEnheterRegistry.isEnhetIntegrerad(enhetsId, intygsTyp)) { LOG.debug("Not forwarding internal notification to care system, care unit '{}' is not integrated.", enhetsId); return; } ModuleApi moduleApi = intygModuleRegistry.getModuleApi(intygsTyp, intygsTypVersion); CertificateResponse certificateResponse = moduleApi.getCertificate(intygsId, logicalAddress, "HSVARD"); Utlatande utlatande = certificateResponse.getUtlatande(); notificationService.forwardInternalNotification(utlatande.getId(), utlatande.getTyp(), utlatande, HandelsekodEnum.SKICKA); } catch (IllegalArgumentException e) { LOG.error("Could not process internal notification, message is missing required header: {}", e.getMessage()); } catch (JMSException | ModuleNotFoundException | ModuleException e) { LOG.error("Caught {} transforming internal notification to external notification. Message: {}", e.getMessage()); } } }  @Override @JmsListener(destination = "${internal.notification.queueName}") void onMessage(Message message); }
InternalNotificationMessageListener implements MessageListener { @Override @JmsListener(destination = "${internal.notification.queueName}") public void onMessage(Message message) { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; try { String intygsId = textMessage.getStringProperty(CERTIFICATE_ID); String intygsTyp = textMessage.getStringProperty(CERTIFICATE_TYPE); String intygsTypVersion = textMessage.getStringProperty(CERTIFICATE_TYPE_VERSION); String enhetsId = textMessage.getStringProperty(CARE_UNIT_ID); checkArgument(StringUtils.isNotEmpty(intygsId), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_ID); checkArgument(StringUtils.isNotEmpty(intygsTyp), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE); checkArgument(StringUtils.isNotEmpty(intygsTypVersion), "Message on queue %s does not have a %s header.", queueName, CERTIFICATE_TYPE_VERSION); checkArgument(StringUtils.isNotEmpty(enhetsId), "Message on queue %s does not have a %s header.", queueName, CARE_UNIT_ID); if (!integreradeEnheterRegistry.isEnhetIntegrerad(enhetsId, intygsTyp)) { LOG.debug("Not forwarding internal notification to care system, care unit '{}' is not integrated.", enhetsId); return; } ModuleApi moduleApi = intygModuleRegistry.getModuleApi(intygsTyp, intygsTypVersion); CertificateResponse certificateResponse = moduleApi.getCertificate(intygsId, logicalAddress, "HSVARD"); Utlatande utlatande = certificateResponse.getUtlatande(); notificationService.forwardInternalNotification(utlatande.getId(), utlatande.getTyp(), utlatande, HandelsekodEnum.SKICKA); } catch (IllegalArgumentException e) { LOG.error("Could not process internal notification, message is missing required header: {}", e.getMessage()); } catch (JMSException | ModuleNotFoundException | ModuleException e) { LOG.error("Caught {} transforming internal notification to external notification. Message: {}", e.getMessage()); } } }  @Override @JmsListener(destination = "${internal.notification.queueName}") void onMessage(Message message);  }