Search in sources :

Example 26 with NotFoundException

use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.

the class LdapConfigServiceTest method testDeleteNotFound.

@Test
public void testDeleteNotFound() {
    // GIVEN
    Mockito.when(crnService.getCurrentAccountId()).thenReturn(ACCOUNT_ID);
    NotFoundException ex = Assertions.assertThrows(NotFoundException.class, () -> {
        // WHEN
        underTest.delete(ENVIRONMENT_ID);
    });
    assertEquals("LdapConfig for environment 'environmentId' not found.", ex.getMessage());
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 27 with NotFoundException

use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.

the class LdapConfigServiceTest method testGetNotFound.

@Test
public void testGetNotFound() {
    // GIVEN
    Mockito.when(crnService.getCurrentAccountId()).thenReturn(ACCOUNT_ID);
    NotFoundException ex = Assertions.assertThrows(NotFoundException.class, () -> {
        // WHEN
        underTest.get(ENVIRONMENT_ID);
    });
    assertEquals("LdapConfig for environment 'environmentId' not found.", ex.getMessage());
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 28 with NotFoundException

use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.

the class CleanupServiceTest method testRemoveUsersWhenKerberosConfigAlreadyDeleted.

@Test
public void testRemoveUsersWhenKerberosConfigAlreadyDeleted() throws FreeIpaClientException {
    Set<String> usersNames = Set.of("ldapbind-test-wl-1", "kerberosbind-test-wl-1");
    Set<User> ipaUsers = Set.of(createUser("ldapbind-test-wl-1"), createUser("ldapbind-test-wl-2"), createUser("kerberosbind-test-wl-1"), createUser("kerberosbind-test-wl-2"), createUser("mockuser0"), createUser("csso_khorvath"));
    FreeIpaClient freeIpaClient = mock(FreeIpaClient.class);
    when(freeIpaClientFactory.getFreeIpaClientForStackId(STACK_ID)).thenReturn(freeIpaClient);
    when(freeIpaClient.userFindAll()).thenReturn(ipaUsers);
    when(stackService.getStackById(anyLong())).thenReturn(createStack());
    doThrow(new NotFoundException("Kerberos config not found")).when(kerberosConfigService).delete("envCrn", "accountId", "test-wl-1");
    Pair<Set<String>, Map<String, String>> result = cleanupService.removeUsers(STACK_ID, usersNames, "test-wl-1", ENV_CRN);
    verify(freeIpaClient, times(1)).deleteUser("ldapbind-test-wl-1");
    verify(freeIpaClient, times(1)).deleteUser("kerberosbind-test-wl-1");
    verifyUserDeleteNotInvoked(freeIpaClient, "ldapbind-test-wl-2", "kerberosbind-test-wl-2", "mockuser0", "csso_khorvath");
    assertEquals(2, result.getFirst().size());
    assertTrue(result.getFirst().stream().anyMatch("ldapbind-test-wl-1"::equals));
    assertTrue(result.getFirst().stream().anyMatch("kerberosbind-test-wl-1"::equals));
    verify(kerberosConfigService, times(1)).delete("envCrn", "accountId", "test-wl-1");
    verify(ldapConfigService, times(1)).delete("envCrn", "accountId", "test-wl-1");
}
Also used : User(com.sequenceiq.freeipa.client.model.User) Set(java.util.Set) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Map(java.util.Map) Test(org.junit.Test)

Example 29 with NotFoundException

use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.

the class RootCertRegisterServiceTest method testDeleteNotFoundHandled.

@Test
public void testDeleteNotFoundHandled() {
    doThrow(new NotFoundException("asdgf")).when(rootCertService).deleteByStack(stack);
    underTest.delete(stack);
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 30 with NotFoundException

use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.

the class KerberosConfigServiceTest method testGetNotFound.

@Test
public void testGetNotFound() {
    // GIVEN
    Mockito.when(crnService.getCurrentAccountId()).thenReturn(ACCOUNT_ID);
    NotFoundException ex = Assertions.assertThrows(NotFoundException.class, () -> {
        // WHEN
        underTest.get(ENVIRONMENT_ID);
    // THEN NotFoundException has to be thrown
    });
    assertEquals("KerberosConfig for environment 'environmentId' not found.", ex.getMessage());
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Test(org.junit.jupiter.api.Test)

Aggregations

NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)73 Test (org.junit.jupiter.api.Test)33 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)9 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)8 Map (java.util.Map)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)6 List (java.util.List)6 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)5 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)5 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)5 Optional (java.util.Optional)5 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)4 Set (java.util.Set)4 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3