@Test public void testSchemaVersion2Transformation() throws Exception { NotificationMessage notificationMessage = new NotificationMessage(INTYGS_ID, LUSE, LocalDateTime.now(), HandelsekodEnum.SKAPAT, LOGISK_ADRESS, "{ }", null, ArendeCount.getEmpty(), ArendeCount.getEmpty(), SchemaVersion.VERSION_3, "ref"); Message message = spy(new DefaultMessage(camelContext)); message.setBody(notificationMessage); ModuleApi moduleApi = mock(ModuleApi.class); when(moduleRegistry.getModuleApi(eq(LUSE), eq("1.0"))).thenReturn(moduleApi); when(moduleRegistry.resolveVersionFromUtlatandeJson(anyString(), anyString())).thenReturn("1.0"); Intyg intyg = new Intyg(); IntygId intygsId = new IntygId(); intygsId.setExtension(INTYGS_ID); intyg.setIntygsId(intygsId); HosPersonal hosPersonal = new HosPersonal(); Enhet enhet = new Enhet(); enhet.setArbetsplatskod(new ArbetsplatsKod()); enhet.setVardgivare(new Vardgivare()); hosPersonal.setEnhet(enhet); intyg.setSkapadAv(hosPersonal); when(moduleApi.getIntygFromUtlatande(any())).thenReturn(intyg); transformer.process(message); assertEquals(INTYGS_ID, ((se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareType) message .getBody()).getIntyg().getIntygsId().getExtension()); assertEquals(HandelsekodEnum.SKAPAT.value(), message.getHeader(NotificationRouteHeaders.HANDELSE)); assertEquals(INTYGS_ID, message.getHeader(NotificationRouteHeaders.INTYGS_ID)); assertEquals(LOGISK_ADRESS, message.getHeader(NotificationRouteHeaders.LOGISK_ADRESS)); assertEquals(SchemaVersion.VERSION_3.name(), message.getHeader(NotificationRouteHeaders.VERSION)); verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.LOGISK_ADRESS), eq(LOGISK_ADRESS)); verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.INTYGS_ID), eq(INTYGS_ID)); verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.HANDELSE), eq(HandelsekodEnum.SKAPAT.value())); verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.VERSION), eq(SchemaVersion.VERSION_3.name())); verify(moduleRegistry, times(1)).getModuleApi(eq(LUSE), eq("1.0")); verify(moduleApi, times(1)).getUtlatandeFromJson(any()); verify(moduleApi, times(1)).getIntygFromUtlatande(any()); verify(notificationPatientEnricher, times(1)).enrichWithPatient(any()); }
public void process(Message message) throws ModuleException, IOException, ModuleNotFoundException, TemporaryException { LOG.debug("Receiving message: {}", message.getMessageId()); NotificationMessage notificationMessage = message.getBody(NotificationMessage.class); message.setHeader(NotificationRouteHeaders.LOGISK_ADRESS, notificationMessage.getLogiskAdress()); message.setHeader(NotificationRouteHeaders.INTYGS_ID, notificationMessage.getIntygsId()); message.setHeader(NotificationRouteHeaders.HANDELSE, notificationMessage.getHandelse().value()); if (notificationMessage.getVersion() != null) { message.setHeader(NotificationRouteHeaders.VERSION, notificationMessage.getVersion().name()); } else { LOG.warn("Recieved notificationMessage with unknown VERSION header, forcing V3"); message.setHeader(NotificationRouteHeaders.VERSION, SchemaVersion.VERSION_3.name()); } if (SchemaVersion.VERSION_3.equals(notificationMessage.getVersion())) { String intygTypeVersion = resolveIntygTypeVersion(notificationMessage.getIntygsTyp(), message, notificationMessage.getUtkast()); ModuleApi moduleApi = moduleRegistry.getModuleApi(notificationMessage.getIntygsTyp(), intygTypeVersion); Utlatande utlatande = moduleApi.getUtlatandeFromJson(notificationMessage.getUtkast()); Intyg intyg = moduleApi.getIntygFromUtlatande(utlatande); notificationPatientEnricher.enrichWithPatient(intyg); message.setBody(NotificationTypeConverter.convert(notificationMessage, intyg)); } else { throw new IllegalArgumentException("Unsupported combination of version '" + notificationMessage.getVersion() + "' and type '" + notificationMessage.getIntygsTyp() + "'"); } }
NotificationTransformer { public void process(Message message) throws ModuleException, IOException, ModuleNotFoundException, TemporaryException { LOG.debug("Receiving message: {}", message.getMessageId()); NotificationMessage notificationMessage = message.getBody(NotificationMessage.class); message.setHeader(NotificationRouteHeaders.LOGISK_ADRESS, notificationMessage.getLogiskAdress()); message.setHeader(NotificationRouteHeaders.INTYGS_ID, notificationMessage.getIntygsId()); message.setHeader(NotificationRouteHeaders.HANDELSE, notificationMessage.getHandelse().value()); if (notificationMessage.getVersion() != null) { message.setHeader(NotificationRouteHeaders.VERSION, notificationMessage.getVersion().name()); } else { LOG.warn("Recieved notificationMessage with unknown VERSION header, forcing V3"); message.setHeader(NotificationRouteHeaders.VERSION, SchemaVersion.VERSION_3.name()); } if (SchemaVersion.VERSION_3.equals(notificationMessage.getVersion())) { String intygTypeVersion = resolveIntygTypeVersion(notificationMessage.getIntygsTyp(), message, notificationMessage.getUtkast()); ModuleApi moduleApi = moduleRegistry.getModuleApi(notificationMessage.getIntygsTyp(), intygTypeVersion); Utlatande utlatande = moduleApi.getUtlatandeFromJson(notificationMessage.getUtkast()); Intyg intyg = moduleApi.getIntygFromUtlatande(utlatande); notificationPatientEnricher.enrichWithPatient(intyg); message.setBody(NotificationTypeConverter.convert(notificationMessage, intyg)); } else { throw new IllegalArgumentException("Unsupported combination of version '" + notificationMessage.getVersion() + "' and type '" + notificationMessage.getIntygsTyp() + "'"); } } }
NotificationTransformer { public void process(Message message) throws ModuleException, IOException, ModuleNotFoundException, TemporaryException { LOG.debug("Receiving message: {}", message.getMessageId()); NotificationMessage notificationMessage = message.getBody(NotificationMessage.class); message.setHeader(NotificationRouteHeaders.LOGISK_ADRESS, notificationMessage.getLogiskAdress()); message.setHeader(NotificationRouteHeaders.INTYGS_ID, notificationMessage.getIntygsId()); message.setHeader(NotificationRouteHeaders.HANDELSE, notificationMessage.getHandelse().value()); if (notificationMessage.getVersion() != null) { message.setHeader(NotificationRouteHeaders.VERSION, notificationMessage.getVersion().name()); } else { LOG.warn("Recieved notificationMessage with unknown VERSION header, forcing V3"); message.setHeader(NotificationRouteHeaders.VERSION, SchemaVersion.VERSION_3.name()); } if (SchemaVersion.VERSION_3.equals(notificationMessage.getVersion())) { String intygTypeVersion = resolveIntygTypeVersion(notificationMessage.getIntygsTyp(), message, notificationMessage.getUtkast()); ModuleApi moduleApi = moduleRegistry.getModuleApi(notificationMessage.getIntygsTyp(), intygTypeVersion); Utlatande utlatande = moduleApi.getUtlatandeFromJson(notificationMessage.getUtkast()); Intyg intyg = moduleApi.getIntygFromUtlatande(utlatande); notificationPatientEnricher.enrichWithPatient(intyg); message.setBody(NotificationTypeConverter.convert(notificationMessage, intyg)); } else { throw new IllegalArgumentException("Unsupported combination of version '" + notificationMessage.getVersion() + "' and type '" + notificationMessage.getIntygsTyp() + "'"); } }  }
NotificationTransformer { public void process(Message message) throws ModuleException, IOException, ModuleNotFoundException, TemporaryException { LOG.debug("Receiving message: {}", message.getMessageId()); NotificationMessage notificationMessage = message.getBody(NotificationMessage.class); message.setHeader(NotificationRouteHeaders.LOGISK_ADRESS, notificationMessage.getLogiskAdress()); message.setHeader(NotificationRouteHeaders.INTYGS_ID, notificationMessage.getIntygsId()); message.setHeader(NotificationRouteHeaders.HANDELSE, notificationMessage.getHandelse().value()); if (notificationMessage.getVersion() != null) { message.setHeader(NotificationRouteHeaders.VERSION, notificationMessage.getVersion().name()); } else { LOG.warn("Recieved notificationMessage with unknown VERSION header, forcing V3"); message.setHeader(NotificationRouteHeaders.VERSION, SchemaVersion.VERSION_3.name()); } if (SchemaVersion.VERSION_3.equals(notificationMessage.getVersion())) { String intygTypeVersion = resolveIntygTypeVersion(notificationMessage.getIntygsTyp(), message, notificationMessage.getUtkast()); ModuleApi moduleApi = moduleRegistry.getModuleApi(notificationMessage.getIntygsTyp(), intygTypeVersion); Utlatande utlatande = moduleApi.getUtlatandeFromJson(notificationMessage.getUtkast()); Intyg intyg = moduleApi.getIntygFromUtlatande(utlatande); notificationPatientEnricher.enrichWithPatient(intyg); message.setBody(NotificationTypeConverter.convert(notificationMessage, intyg)); } else { throw new IllegalArgumentException("Unsupported combination of version '" + notificationMessage.getVersion() + "' and type '" + notificationMessage.getIntygsTyp() + "'"); } }  void process(Message message); }
NotificationTransformer { public void process(Message message) throws ModuleException, IOException, ModuleNotFoundException, TemporaryException { LOG.debug("Receiving message: {}", message.getMessageId()); NotificationMessage notificationMessage = message.getBody(NotificationMessage.class); message.setHeader(NotificationRouteHeaders.LOGISK_ADRESS, notificationMessage.getLogiskAdress()); message.setHeader(NotificationRouteHeaders.INTYGS_ID, notificationMessage.getIntygsId()); message.setHeader(NotificationRouteHeaders.HANDELSE, notificationMessage.getHandelse().value()); if (notificationMessage.getVersion() != null) { message.setHeader(NotificationRouteHeaders.VERSION, notificationMessage.getVersion().name()); } else { LOG.warn("Recieved notificationMessage with unknown VERSION header, forcing V3"); message.setHeader(NotificationRouteHeaders.VERSION, SchemaVersion.VERSION_3.name()); } if (SchemaVersion.VERSION_3.equals(notificationMessage.getVersion())) { String intygTypeVersion = resolveIntygTypeVersion(notificationMessage.getIntygsTyp(), message, notificationMessage.getUtkast()); ModuleApi moduleApi = moduleRegistry.getModuleApi(notificationMessage.getIntygsTyp(), intygTypeVersion); Utlatande utlatande = moduleApi.getUtlatandeFromJson(notificationMessage.getUtkast()); Intyg intyg = moduleApi.getIntygFromUtlatande(utlatande); notificationPatientEnricher.enrichWithPatient(intyg); message.setBody(NotificationTypeConverter.convert(notificationMessage, intyg)); } else { throw new IllegalArgumentException("Unsupported combination of version '" + notificationMessage.getVersion() + "' and type '" + notificationMessage.getIntygsTyp() + "'"); } }  void process(Message message);  }