@Test void setWorkloadCredentials() throws Exception { FreeIpaClient freeIpaClient = mock(FreeIpaClient.class); Map<String, WorkloadCredential> workloadCredentialMap = Map.of( "user1", mock(WorkloadCredential.class), "user2", mock(WorkloadCredential.class), "user3", mock(WorkloadCredential.class), "user4", mock(WorkloadCredential.class)); WorkloadCredentialService spyUnderTest = spy(underTest); doNothing().when(spyUnderTest).setWorkloadCredential(any(FreeIpaClient.class), anyString(), any(WorkloadCredential.class)); BiConsumer<String, String> warnings = mock(BiConsumer.class); spyUnderTest.setWorkloadCredentials(freeIpaClient, workloadCredentialMap, warnings); verify(spyUnderTest).setWorkloadCredentials(freeIpaClient, workloadCredentialMap, warnings); for (Map.Entry<String, WorkloadCredential> entry : workloadCredentialMap.entrySet()) { verify(spyUnderTest).setWorkloadCredential(freeIpaClient, entry.getKey(), entry.getValue()); } verifyNoMoreInteractions(spyUnderTest); }
public void setWorkloadCredentials(FreeIpaClient freeIpaClient, Map<String, WorkloadCredential> workloadCredentials, BiConsumer<String, String> warnings) throws FreeIpaClientException { for (Map.Entry<String, WorkloadCredential> entry : workloadCredentials.entrySet()) { try { setWorkloadCredential(freeIpaClient, entry.getKey(), entry.getValue()); } catch (IOException e) { recordWarning(entry.getKey(), e, warnings); } catch (FreeIpaClientException e) { recordWarning(entry.getKey(), e, warnings); if (e.isClientUnusable()) { LOGGER.warn("Client is not usable for further usage"); throw e; } } } }
WorkloadCredentialService { public void setWorkloadCredentials(FreeIpaClient freeIpaClient, Map<String, WorkloadCredential> workloadCredentials, BiConsumer<String, String> warnings) throws FreeIpaClientException { for (Map.Entry<String, WorkloadCredential> entry : workloadCredentials.entrySet()) { try { setWorkloadCredential(freeIpaClient, entry.getKey(), entry.getValue()); } catch (IOException e) { recordWarning(entry.getKey(), e, warnings); } catch (FreeIpaClientException e) { recordWarning(entry.getKey(), e, warnings); if (e.isClientUnusable()) { LOGGER.warn("Client is not usable for further usage"); throw e; } } } } }
WorkloadCredentialService { public void setWorkloadCredentials(FreeIpaClient freeIpaClient, Map<String, WorkloadCredential> workloadCredentials, BiConsumer<String, String> warnings) throws FreeIpaClientException { for (Map.Entry<String, WorkloadCredential> entry : workloadCredentials.entrySet()) { try { setWorkloadCredential(freeIpaClient, entry.getKey(), entry.getValue()); } catch (IOException e) { recordWarning(entry.getKey(), e, warnings); } catch (FreeIpaClientException e) { recordWarning(entry.getKey(), e, warnings); if (e.isClientUnusable()) { LOGGER.warn("Client is not usable for further usage"); throw e; } } } }  }
WorkloadCredentialService { public void setWorkloadCredentials(FreeIpaClient freeIpaClient, Map<String, WorkloadCredential> workloadCredentials, BiConsumer<String, String> warnings) throws FreeIpaClientException { for (Map.Entry<String, WorkloadCredential> entry : workloadCredentials.entrySet()) { try { setWorkloadCredential(freeIpaClient, entry.getKey(), entry.getValue()); } catch (IOException e) { recordWarning(entry.getKey(), e, warnings); } catch (FreeIpaClientException e) { recordWarning(entry.getKey(), e, warnings); if (e.isClientUnusable()) { LOGGER.warn("Client is not usable for further usage"); throw e; } } } }  void setWorkloadCredential(FreeIpaClient freeIpaClient, String username, WorkloadCredential workloadCredential); void setWorkloadCredentials(FreeIpaClient freeIpaClient, Map<String, WorkloadCredential> workloadCredentials,
            BiConsumer<String, String> warnings); }
WorkloadCredentialService { public void setWorkloadCredentials(FreeIpaClient freeIpaClient, Map<String, WorkloadCredential> workloadCredentials, BiConsumer<String, String> warnings) throws FreeIpaClientException { for (Map.Entry<String, WorkloadCredential> entry : workloadCredentials.entrySet()) { try { setWorkloadCredential(freeIpaClient, entry.getKey(), entry.getValue()); } catch (IOException e) { recordWarning(entry.getKey(), e, warnings); } catch (FreeIpaClientException e) { recordWarning(entry.getKey(), e, warnings); if (e.isClientUnusable()) { LOGGER.warn("Client is not usable for further usage"); throw e; } } } }  void setWorkloadCredential(FreeIpaClient freeIpaClient, String username, WorkloadCredential workloadCredential); void setWorkloadCredentials(FreeIpaClient freeIpaClient, Map<String, WorkloadCredential> workloadCredentials,
            BiConsumer<String, String> warnings);  }