@Test void testWhenCredentialDeleteIsSuccessfulThenNotificationShouldBeSent() { Credential cred = createCredentialWithName("first"); when(credentialService.findByNameAndAccountId(eq(cred.getName()), eq(ACCOUNT_ID), any(Set.class), any())).thenReturn(Optional.of(cred)); when(credentialService.save(cred)).thenReturn(cred); doNothing().when(grpcUmsClient).notifyResourceDeleted(any(), any()); underTest.deleteMultiple(Set.of(cred.getName()), ACCOUNT_ID, ENVIRONMENT); notificationSender.send(any(Notification.class), any(List.class), any(Client.class)); verify(grpcUmsClient, times(1)).notifyResourceDeleted(any(), any()); }
public Set<Credential> deleteMultiple(Set<String> names, String accountId, CredentialType type) { Set<Credential> deletedOnes = new LinkedHashSet<>(); names.forEach(credentialName -> { try { deletedOnes.add(deleteByName(credentialName, accountId, type)); } catch (Exception ex) { LOGGER.debug("Could not delete Credential with name {} because: {}", credentialName, ex.getMessage()); } }); return deletedOnes; }
CredentialDeleteService extends AbstractCredentialService { public Set<Credential> deleteMultiple(Set<String> names, String accountId, CredentialType type) { Set<Credential> deletedOnes = new LinkedHashSet<>(); names.forEach(credentialName -> { try { deletedOnes.add(deleteByName(credentialName, accountId, type)); } catch (Exception ex) { LOGGER.debug("Could not delete Credential with name {} because: {}", credentialName, ex.getMessage()); } }); return deletedOnes; } }
CredentialDeleteService extends AbstractCredentialService { public Set<Credential> deleteMultiple(Set<String> names, String accountId, CredentialType type) { Set<Credential> deletedOnes = new LinkedHashSet<>(); names.forEach(credentialName -> { try { deletedOnes.add(deleteByName(credentialName, accountId, type)); } catch (Exception ex) { LOGGER.debug("Could not delete Credential with name {} because: {}", credentialName, ex.getMessage()); } }); return deletedOnes; } CredentialDeleteService(CredentialService credentialService,
            NotificationSender notificationSender,
            CloudbreakMessagesService messagesService,
            EnvironmentViewService environmentViewService,
            GrpcUmsClient grpcUmsClient,
            @Value("${environment.enabledplatforms}") Set<String> enabledPlatforms); }
CredentialDeleteService extends AbstractCredentialService { public Set<Credential> deleteMultiple(Set<String> names, String accountId, CredentialType type) { Set<Credential> deletedOnes = new LinkedHashSet<>(); names.forEach(credentialName -> { try { deletedOnes.add(deleteByName(credentialName, accountId, type)); } catch (Exception ex) { LOGGER.debug("Could not delete Credential with name {} because: {}", credentialName, ex.getMessage()); } }); return deletedOnes; } CredentialDeleteService(CredentialService credentialService,
            NotificationSender notificationSender,
            CloudbreakMessagesService messagesService,
            EnvironmentViewService environmentViewService,
            GrpcUmsClient grpcUmsClient,
            @Value("${environment.enabledplatforms}") Set<String> enabledPlatforms); Set<Credential> deleteMultiple(Set<String> names, String accountId, CredentialType type); Credential deleteByName(String name, String accountId, CredentialType type); Credential deleteByCrn(String crn, String accountId, CredentialType type); }
CredentialDeleteService extends AbstractCredentialService { public Set<Credential> deleteMultiple(Set<String> names, String accountId, CredentialType type) { Set<Credential> deletedOnes = new LinkedHashSet<>(); names.forEach(credentialName -> { try { deletedOnes.add(deleteByName(credentialName, accountId, type)); } catch (Exception ex) { LOGGER.debug("Could not delete Credential with name {} because: {}", credentialName, ex.getMessage()); } }); return deletedOnes; } CredentialDeleteService(CredentialService credentialService,
            NotificationSender notificationSender,
            CloudbreakMessagesService messagesService,
            EnvironmentViewService environmentViewService,
            GrpcUmsClient grpcUmsClient,
            @Value("${environment.enabledplatforms}") Set<String> enabledPlatforms); Set<Credential> deleteMultiple(Set<String> names, String accountId, CredentialType type); Credential deleteByName(String name, String accountId, CredentialType type); Credential deleteByCrn(String crn, String accountId, CredentialType type);  }