@Test public void testDecorateArendeFromUtkastNoGivenName() throws WebCertServiceException { final String intygId = "intygsid"; final String intygTyp = "intygTyp"; final String signeratAv = "signeratAv"; final String givenName = null; final String surname = "Testorsson Svensson"; Arende arende = new Arende(); arende.setIntygsId(intygId); Utkast utkast = new Utkast(); utkast.setIntygsTyp(intygTyp); utkast.setSignatur(mock(Signatur.class)); when(utkast.getSignatur().getSigneradAv()).thenReturn(signeratAv); when(hsaEmployeeService.getEmployee(eq(signeratAv), eq(null))).thenReturn(createHsaResponse(givenName, surname)); Arende res = new Arende(); ArendeConverter.decorateArendeFromUtkast(res, utkast, LocalDateTime.now(), hsaEmployeeService); assertNotNull(res); assertEquals("Testorsson Svensson", res.getSigneratAvName()); }
public static void decorateArendeFromUtkast(Arende arende, Utkast utkast, LocalDateTime now, HsaEmployeeService hsaEmployeeService) { arende.setTimestamp(now); arende.setSenasteHandelse(now); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(utkast.getIntygsTyp()); arende.setSigneratAv(utkast.getSignatur().getSigneradAv()); arende.setSigneratAvName(getSignedByName(utkast, hsaEmployeeService)); arende.setEnhetId(utkast.getEnhetsId()); arende.setEnhetName(utkast.getEnhetsNamn()); arende.setVardgivareName(utkast.getVardgivarNamn()); }
ArendeConverter { public static void decorateArendeFromUtkast(Arende arende, Utkast utkast, LocalDateTime now, HsaEmployeeService hsaEmployeeService) { arende.setTimestamp(now); arende.setSenasteHandelse(now); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(utkast.getIntygsTyp()); arende.setSigneratAv(utkast.getSignatur().getSigneradAv()); arende.setSigneratAvName(getSignedByName(utkast, hsaEmployeeService)); arende.setEnhetId(utkast.getEnhetsId()); arende.setEnhetName(utkast.getEnhetsNamn()); arende.setVardgivareName(utkast.getVardgivarNamn()); } }
ArendeConverter { public static void decorateArendeFromUtkast(Arende arende, Utkast utkast, LocalDateTime now, HsaEmployeeService hsaEmployeeService) { arende.setTimestamp(now); arende.setSenasteHandelse(now); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(utkast.getIntygsTyp()); arende.setSigneratAv(utkast.getSignatur().getSigneradAv()); arende.setSigneratAvName(getSignedByName(utkast, hsaEmployeeService)); arende.setEnhetId(utkast.getEnhetsId()); arende.setEnhetName(utkast.getEnhetsNamn()); arende.setVardgivareName(utkast.getVardgivarNamn()); } private  ArendeConverter(); }
ArendeConverter { public static void decorateArendeFromUtkast(Arende arende, Utkast utkast, LocalDateTime now, HsaEmployeeService hsaEmployeeService) { arende.setTimestamp(now); arende.setSenasteHandelse(now); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(utkast.getIntygsTyp()); arende.setSigneratAv(utkast.getSignatur().getSigneradAv()); arende.setSigneratAvName(getSignedByName(utkast, hsaEmployeeService)); arende.setEnhetId(utkast.getEnhetsId()); arende.setEnhetName(utkast.getEnhetsNamn()); arende.setVardgivareName(utkast.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 decorateArendeFromUtkast(Arende arende, Utkast utkast, LocalDateTime now, HsaEmployeeService hsaEmployeeService) { arende.setTimestamp(now); arende.setSenasteHandelse(now); arende.setStatus(arende.getSvarPaId() == null ? Status.PENDING_INTERNAL_ACTION : Status.ANSWERED); arende.setVidarebefordrad(Boolean.FALSE); arende.setIntygTyp(utkast.getIntygsTyp()); arende.setSigneratAv(utkast.getSignatur().getSigneradAv()); arende.setSigneratAvName(getSignedByName(utkast, hsaEmployeeService)); arende.setEnhetId(utkast.getEnhetsId()); arende.setEnhetName(utkast.getEnhetsNamn()); arende.setVardgivareName(utkast.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);  }