Search in sources :

Example 1 with EnvironmentUserSyncState

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState in project cloudbreak by hortonworks.

the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateLastSyncFailed.

@Test
void internalCalculateEnvironmentUserSyncStateLastSyncFailed() {
    UserSyncStatus userSyncStatus = new UserSyncStatus();
    Operation lastSync = new Operation();
    lastSync.setOperationId(UUID.randomUUID().toString());
    lastSync.setStatus(OperationState.FAILED);
    userSyncStatus.setLastStartedFullSync(lastSync);
    EnvironmentUserSyncState result = underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, Optional.of(userSyncStatus));
    assertEquals(UserSyncState.SYNC_FAILED, result.getState());
    assertEquals(lastSync.getOperationId(), result.getLastUserSyncOperationId());
}
Also used : UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) Test(org.junit.jupiter.api.Test)

Example 2 with EnvironmentUserSyncState

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState in project cloudbreak by hortonworks.

the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateLastSyncCompletedFailure.

@Test
void internalCalculateEnvironmentUserSyncStateLastSyncCompletedFailure() {
    UserSyncStatus userSyncStatus = new UserSyncStatus();
    Operation lastSync = new Operation();
    lastSync.setOperationId(UUID.randomUUID().toString());
    lastSync.setStatus(OperationState.COMPLETED);
    lastSync.setFailureList(List.of(new FailureDetails(ENVIRONMENT_CRN, "failure message")));
    userSyncStatus.setLastStartedFullSync(lastSync);
    EnvironmentUserSyncState result = underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, Optional.of(userSyncStatus));
    assertEquals(UserSyncState.SYNC_FAILED, result.getState());
    assertEquals(lastSync.getOperationId(), result.getLastUserSyncOperationId());
}
Also used : UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) FailureDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails) Test(org.junit.jupiter.api.Test)

Example 3 with EnvironmentUserSyncState

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState in project cloudbreak by hortonworks.

the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateLastSyncRunning.

@Test
void internalCalculateEnvironmentUserSyncStateLastSyncRunning() {
    UserSyncStatus userSyncStatus = new UserSyncStatus();
    Operation lastSync = new Operation();
    lastSync.setOperationId(UUID.randomUUID().toString());
    lastSync.setStatus(OperationState.RUNNING);
    userSyncStatus.setLastStartedFullSync(lastSync);
    EnvironmentUserSyncState result = underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, Optional.of(userSyncStatus));
    assertEquals(UserSyncState.SYNC_IN_PROGRESS, result.getState());
    assertEquals(lastSync.getOperationId(), result.getLastUserSyncOperationId());
}
Also used : UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) Test(org.junit.jupiter.api.Test)

Example 4 with EnvironmentUserSyncState

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState in project cloudbreak by hortonworks.

the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateNoLastSync.

@Test
void internalCalculateEnvironmentUserSyncStateNoLastSync() {
    UserSyncStatus userSyncStatus = new UserSyncStatus();
    EnvironmentUserSyncState result = underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, Optional.of(userSyncStatus));
    assertEquals(UserSyncState.STALE, result.getState());
    assertNull(result.getLastUserSyncOperationId());
}
Also used : UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) Test(org.junit.jupiter.api.Test)

Example 5 with EnvironmentUserSyncState

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState in project cloudbreak by hortonworks.

the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateLastSyncCompletedSuccessInSync.

@Test
void internalCalculateEnvironmentUserSyncStateLastSyncCompletedSuccessInSync() {
    UserSyncStatus userSyncStatus = new UserSyncStatus();
    Operation lastSync = new Operation();
    lastSync.setOperationId(UUID.randomUUID().toString());
    lastSync.setStatus(OperationState.COMPLETED);
    lastSync.setSuccessList(List.of(new SuccessDetails(ENVIRONMENT_CRN)));
    userSyncStatus.setLastStartedFullSync(lastSync);
    UmsEventGenerationIds current = new UmsEventGenerationIds();
    when(umsEventGenerationIdsProvider.getEventGenerationIds(eq(ACCOUNT_ID), any())).thenReturn(current);
    when(eventGenerationIdsChecker.isInSync(userSyncStatus, current)).thenReturn(true);
    EnvironmentUserSyncState result = underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, Optional.of(userSyncStatus));
    assertEquals(UserSyncState.UP_TO_DATE, result.getState());
    assertEquals(lastSync.getOperationId(), result.getLastUserSyncOperationId());
}
Also used : SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) UmsEventGenerationIds(com.sequenceiq.freeipa.service.freeipa.user.model.UmsEventGenerationIds) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) Test(org.junit.jupiter.api.Test)

Aggregations

EnvironmentUserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState)13 Test (org.junit.jupiter.api.Test)8 UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)7 Operation (com.sequenceiq.freeipa.entity.Operation)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)2 SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)2 UmsEventGenerationIds (com.sequenceiq.freeipa.service.freeipa.user.model.UmsEventGenerationIds)2 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 ResourceCrn (com.sequenceiq.authorization.annotation.ResourceCrn)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 UserV1Endpoint (com.sequenceiq.freeipa.api.v1.freeipa.user.UserV1Endpoint)1 FailureDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails)1 ClientErrorException (javax.ws.rs.ClientErrorException)1