@Test public void testDecorateMessageFromCertificatet() throws WebCertServiceException { final String certificateType = "certificateType"; final String signedBy = "signedBy"; final String unitId = "unitId"; final String unitName = "unitName"; final String careProviderName = "careProviderName"; final LocalDateTime now = LocalDateTime.now(); final String fullName = "Test Testorsson Svensson"; final var certificate = mock(Utlatande.class); doReturn(certificateType).when(certificate).getTyp(); final var basicData = mock(GrundData.class); doReturn(basicData).when(certificate).getGrundData(); final var createdBy = mock(HoSPersonal.class); doReturn(createdBy).when(basicData).getSkapadAv(); doReturn(signedBy).when(createdBy).getPersonId(); doReturn(fullName).when(createdBy).getFullstandigtNamn(); final var unit = mock(Vardenhet.class); doReturn(unit).when(createdBy).getVardenhet(); doReturn(unitId).when(unit).getEnhetsid(); doReturn(unitName).when(unit).getEnhetsnamn(); final var careProvider = mock(Vardgivare.class); doReturn(careProvider).when(unit).getVardgivare(); doReturn(careProviderName).when(careProvider).getVardgivarnamn(); Arende actualMessage = new Arende(); ArendeConverter.decorateMessageFromCertificate(actualMessage, certificate, now); assertNotNull(actualMessage); assertEquals(now, actualMessage.getTimestamp()); assertEquals(now, actualMessage.getSenasteHandelse()); assertEquals(Boolean.FALSE, actualMessage.getVidarebefordrad()); assertEquals(Status.PENDING_INTERNAL_ACTION, actualMessage.getStatus()); assertEquals(certificateType, actualMessage.getIntygTyp()); assertEquals(signedBy, actualMessage.getSigneratAv()); assertEquals(unitId, actualMessage.getEnhetId()); assertEquals(unitName, actualMessage.getEnhetName()); assertEquals(careProviderName, actualMessage.getVardgivareName()); assertEquals(fullName, actualMessage.getSigneratAvName()); }
public static void decorateMessageFromCertificate(Arende arende, Utlatande certificate, LocalDateTime timestamp) { arende.setTimestamp(timestamp); arende.setSenasteHandelse(timestamp); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(certificate.getTyp()); arende.setSigneratAv(certificate.getGrundData().getSkapadAv().getPersonId()); arende.setSigneratAvName(certificate.getGrundData().getSkapadAv().getFullstandigtNamn()); arende.setEnhetId(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsid()); arende.setEnhetName(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsnamn()); arende.setVardgivareName(certificate.getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarnamn()); }
ArendeConverter { public static void decorateMessageFromCertificate(Arende arende, Utlatande certificate, LocalDateTime timestamp) { arende.setTimestamp(timestamp); arende.setSenasteHandelse(timestamp); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(certificate.getTyp()); arende.setSigneratAv(certificate.getGrundData().getSkapadAv().getPersonId()); arende.setSigneratAvName(certificate.getGrundData().getSkapadAv().getFullstandigtNamn()); arende.setEnhetId(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsid()); arende.setEnhetName(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsnamn()); arende.setVardgivareName(certificate.getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarnamn()); } }
ArendeConverter { public static void decorateMessageFromCertificate(Arende arende, Utlatande certificate, LocalDateTime timestamp) { arende.setTimestamp(timestamp); arende.setSenasteHandelse(timestamp); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(certificate.getTyp()); arende.setSigneratAv(certificate.getGrundData().getSkapadAv().getPersonId()); arende.setSigneratAvName(certificate.getGrundData().getSkapadAv().getFullstandigtNamn()); arende.setEnhetId(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsid()); arende.setEnhetName(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsnamn()); arende.setVardgivareName(certificate.getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarnamn()); } private  ArendeConverter(); }
ArendeConverter { public static void decorateMessageFromCertificate(Arende arende, Utlatande certificate, LocalDateTime timestamp) { arende.setTimestamp(timestamp); arende.setSenasteHandelse(timestamp); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(certificate.getTyp()); arende.setSigneratAv(certificate.getGrundData().getSkapadAv().getPersonId()); arende.setSigneratAvName(certificate.getGrundData().getSkapadAv().getFullstandigtNamn()); arende.setEnhetId(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsid()); arende.setEnhetName(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsnamn()); arende.setVardgivareName(certificate.getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarnamn()); } private  ArendeConverter(); static Arende convert(SendMessageToCareType request); static void decorateArendeFromUtkast(Arende arende, Utkast utkast, LocalDateTime now, HsaEmployeeService hsaEmployeeService); static void decorateMessageFromCertificate(Arende arende, Utlatande certificate, LocalDateTime timestamp); static Arende createArendeFromUtkast(ArendeAmne amne, String rubrik, String meddelande, Utkast utkast, LocalDateTime now,
        String vardaktorNamn, HsaEmployeeService hsaEmployeeService); static Arende createMessageFromCertificate(ArendeAmne subject, String header, String messageText, Utlatande certificate,
        LocalDateTime timestamp, String nameOfCareGiver, HsaEmployeeService hsaEmployeeService); static Arende createAnswerFromArende(String meddelande, Arende svarPaMeddelande, LocalDateTime now, String vardaktorNamn); static Map<String, String> getNamesByHsaIds(Collection<String> hsaIds, HsaEmployeeService hsaEmployeeService); }
ArendeConverter { public static void decorateMessageFromCertificate(Arende arende, Utlatande certificate, LocalDateTime timestamp) { arende.setTimestamp(timestamp); arende.setSenasteHandelse(timestamp); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(certificate.getTyp()); arende.setSigneratAv(certificate.getGrundData().getSkapadAv().getPersonId()); arende.setSigneratAvName(certificate.getGrundData().getSkapadAv().getFullstandigtNamn()); arende.setEnhetId(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsid()); arende.setEnhetName(certificate.getGrundData().getSkapadAv().getVardenhet().getEnhetsnamn()); arende.setVardgivareName(certificate.getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarnamn()); } private  ArendeConverter(); static Arende convert(SendMessageToCareType request); static void decorateArendeFromUtkast(Arende arende, Utkast utkast, LocalDateTime now, HsaEmployeeService hsaEmployeeService); static void decorateMessageFromCertificate(Arende arende, Utlatande certificate, LocalDateTime timestamp); static Arende createArendeFromUtkast(ArendeAmne amne, String rubrik, String meddelande, Utkast utkast, LocalDateTime now,
        String vardaktorNamn, HsaEmployeeService hsaEmployeeService); static Arende createMessageFromCertificate(ArendeAmne subject, String header, String messageText, Utlatande certificate,
        LocalDateTime timestamp, String nameOfCareGiver, HsaEmployeeService hsaEmployeeService); static Arende createAnswerFromArende(String meddelande, Arende svarPaMeddelande, LocalDateTime now, String vardaktorNamn); static Map<String, String> getNamesByHsaIds(Collection<String> hsaIds, HsaEmployeeService hsaEmployeeService);  }