Search in sources :

Example 6 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class RangerCloudIdentityServiceTest method mockSdxStatus.

private SdxStatusEntity mockSdxStatus(DatalakeStatusEnum status) {
    SdxStatusEntity sdxStatusEntity = mock(SdxStatusEntity.class);
    when(sdxStatusEntity.getStatus()).thenReturn(status);
    return sdxStatusEntity;
}
Also used : SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity)

Example 7 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class RangerCloudIdentityServiceTest method testSetAzureCloudIdentityMappingFailSync.

@Test
public void testSetAzureCloudIdentityMappingFailSync() throws ApiException {
    ApiCommand apiCommand = mock(ApiCommand.class);
    when(apiCommand.getId()).thenReturn(BigDecimal.ONE);
    when(apiCommand.getSuccess()).thenReturn(false);
    SdxStatusEntity sdxStatus = mockSdxStatus(DatalakeStatusEnum.RUNNING);
    when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(sdxStatus);
    testSetAzureCloudIdentityMapping(Optional.of(apiCommand), RangerCloudIdentitySyncState.FAILED);
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) Test(org.junit.jupiter.api.Test)

Example 8 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class RangerCloudIdentityServiceTest method testSetAzureCloudIdentityMappingNoApiCommand.

@Test
public void testSetAzureCloudIdentityMappingNoApiCommand() throws ApiException {
    SdxStatusEntity sdxStatus = mockSdxStatus(DatalakeStatusEnum.RUNNING);
    when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(sdxStatus);
    testSetAzureCloudIdentityMapping(Optional.empty(), RangerCloudIdentitySyncState.SUCCESS);
}
Also used : SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) Test(org.junit.jupiter.api.Test)

Example 9 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class RangerCloudIdentityServiceTest method testSetAzureCloudIdentityMappingActiveSync.

@Test
public void testSetAzureCloudIdentityMappingActiveSync() throws ApiException {
    ApiCommand apiCommand = mock(ApiCommand.class);
    when(apiCommand.getId()).thenReturn(BigDecimal.ONE);
    when(apiCommand.getActive()).thenReturn(true);
    SdxStatusEntity sdxStatus = mockSdxStatus(DatalakeStatusEnum.RUNNING);
    when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(sdxStatus);
    testSetAzureCloudIdentityMapping(Optional.of(apiCommand), RangerCloudIdentitySyncState.ACTIVE);
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) Test(org.junit.jupiter.api.Test)

Example 10 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class RangerCloudIdentityServiceTest method testSetAzureCloudIdentityMappingDatalakNotRunning.

@Test
public void testSetAzureCloudIdentityMappingDatalakNotRunning() throws ApiException {
    when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(List.of(mock(SdxCluster.class)));
    SdxStatusEntity sdxStatus = mockSdxStatus(DatalakeStatusEnum.PROVISIONING_FAILED);
    when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(sdxStatus);
    Map<String, String> userMapping = Map.of("user", "val1");
    RangerCloudIdentitySyncStatus status = underTest.setAzureCloudIdentityMapping("env-crn", userMapping);
    assertEquals(RangerCloudIdentitySyncState.NOT_APPLICABLE, status.getState());
    verify(clouderaManagerRangerUtil, never()).setAzureCloudIdentityMapping(eq("stack-crn"), eq(userMapping));
}
Also used : RangerCloudIdentitySyncStatus(com.sequenceiq.sdx.api.model.RangerCloudIdentitySyncStatus) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)23 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)9 Test (org.junit.jupiter.api.Test)9 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)3 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)3 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)2 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)2 CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)2 DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)2 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)2 SdxRecoverableResponse (com.sequenceiq.sdx.api.model.SdxRecoverableResponse)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)1 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 FlowLog (com.sequenceiq.flow.domain.FlowLog)1 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)1 SslConfigV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request)1