@Test public void getNamesByHsaIds() { String id1 = "not_found"; String id2 = "foundId"; List<String> hsaIds = Arrays.asList(id1, id2); when(hsaEmployeeService.getEmployee(eq(id1), any())).thenThrow(WebServiceException.class); when(hsaEmployeeService.getEmployee(eq(id2), any())).thenAnswer(invocation -> { PersonInformationType personInformation = new PersonInformationType(); personInformation.setMiddleAndSurName((String) invocation.getArguments()[0]); List<PersonInformationType> personInformationTypeList = new ArrayList<>(); personInformationTypeList.add(personInformation); return personInformationTypeList; }); Map<String, String> map = ArendeConverter.getNamesByHsaIds(hsaIds, hsaEmployeeService); assertNotNull(map); assertEquals(1, map.size()); assertTrue(map.containsKey(id2)); assertFalse(map.containsKey(id1)); }
public static Map<String, String> getNamesByHsaIds(Collection<String> hsaIds, HsaEmployeeService hsaEmployeeService) { Map<String, String> hsaIdNameMap = new HashMap<>(); hsaIds.forEach(hsaId -> { Optional<String> name = getNameByHsaIdNullIfNotFound(hsaId, hsaEmployeeService); name.ifPresent(s -> hsaIdNameMap.put(hsaId, s)); }); return hsaIdNameMap; }
ArendeConverter { public static Map<String, String> getNamesByHsaIds(Collection<String> hsaIds, HsaEmployeeService hsaEmployeeService) { Map<String, String> hsaIdNameMap = new HashMap<>(); hsaIds.forEach(hsaId -> { Optional<String> name = getNameByHsaIdNullIfNotFound(hsaId, hsaEmployeeService); name.ifPresent(s -> hsaIdNameMap.put(hsaId, s)); }); return hsaIdNameMap; } }
ArendeConverter { public static Map<String, String> getNamesByHsaIds(Collection<String> hsaIds, HsaEmployeeService hsaEmployeeService) { Map<String, String> hsaIdNameMap = new HashMap<>(); hsaIds.forEach(hsaId -> { Optional<String> name = getNameByHsaIdNullIfNotFound(hsaId, hsaEmployeeService); name.ifPresent(s -> hsaIdNameMap.put(hsaId, s)); }); return hsaIdNameMap; } private  ArendeConverter(); }
ArendeConverter { public static Map<String, String> getNamesByHsaIds(Collection<String> hsaIds, HsaEmployeeService hsaEmployeeService) { Map<String, String> hsaIdNameMap = new HashMap<>(); hsaIds.forEach(hsaId -> { Optional<String> name = getNameByHsaIdNullIfNotFound(hsaId, hsaEmployeeService); name.ifPresent(s -> hsaIdNameMap.put(hsaId, s)); }); return hsaIdNameMap; } 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 Map<String, String> getNamesByHsaIds(Collection<String> hsaIds, HsaEmployeeService hsaEmployeeService) { Map<String, String> hsaIdNameMap = new HashMap<>(); hsaIds.forEach(hsaId -> { Optional<String> name = getNameByHsaIdNullIfNotFound(hsaId, hsaEmployeeService); name.ifPresent(s -> hsaIdNameMap.put(hsaId, s)); }); return hsaIdNameMap; } 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);  }