Search in sources :

Example 51 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateLastSyncRejected.

@Test
void internalCalculateEnvironmentUserSyncStateLastSyncRejected() {
    UserSyncStatus userSyncStatus = new UserSyncStatus();
    Operation lastSync = new Operation();
    lastSync.setOperationId(UUID.randomUUID().toString());
    lastSync.setStatus(OperationState.REJECTED);
    userSyncStatus.setLastStartedFullSync(lastSync);
    assertThrows(IllegalStateException.class, () -> underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, Optional.of(userSyncStatus)));
}
Also used : UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) Test(org.junit.jupiter.api.Test)

Example 52 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateLastSyncCompletedSuccessNotInSync.

@Test
void internalCalculateEnvironmentUserSyncStateLastSyncCompletedSuccessNotInSync() {
    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(false);
    EnvironmentUserSyncState result = underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, Optional.of(userSyncStatus));
    assertEquals(UserSyncState.STALE, 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)

Example 53 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class CooldownCheckerTest method testIsNotCool.

@Test
void testIsNotCool() {
    Stack stack = UserSyncTestUtils.createStack();
    UserSyncStatus userSyncStatus = UserSyncTestUtils.createUserSyncStatus(stack);
    Instant cooldownExpiration = Instant.now();
    long lastStartTime = cooldownExpiration.toEpochMilli() + 1L;
    Operation lastRequestedOperation = new Operation();
    lastRequestedOperation.setStartTime(lastStartTime);
    userSyncStatus.setLastStartedFullSync(lastRequestedOperation);
    assertFalse(underTest.isCooldownExpired(userSyncStatus, cooldownExpiration));
}
Also used : Instant(java.time.Instant) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 54 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class CooldownCheckerTest method testIsCool.

@Test
void testIsCool() {
    Stack stack = UserSyncTestUtils.createStack();
    UserSyncStatus userSyncStatus = UserSyncTestUtils.createUserSyncStatus(stack);
    Instant cooldownExpiration = Instant.now();
    long lastStartTime = cooldownExpiration.toEpochMilli() - 1L;
    Operation lastRequestedOperation = new Operation();
    lastRequestedOperation.setStartTime(lastStartTime);
    userSyncStatus.setLastStartedFullSync(lastRequestedOperation);
    assertTrue(underTest.isCooldownExpired(userSyncStatus, cooldownExpiration));
}
Also used : Instant(java.time.Instant) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 55 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class SyncOperationToOperationStatusConverterTest method createSyncOperation.

private Operation createSyncOperation(OperationState status) {
    Operation operation = new Operation();
    operation.setOperationId(OPERATION_ID);
    operation.setAccountId(ACCOUNT_ID);
    operation.setOperationType(OPERATION_TYPE);
    operation.setStatus(status);
    operation.setStartTime(START_TIME);
    operation.setEndTime(END_TIME);
    return operation;
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation)

Aggregations

Operation (com.sequenceiq.freeipa.entity.Operation)88 Test (org.junit.jupiter.api.Test)55 Stack (com.sequenceiq.freeipa.entity.Stack)23 UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)18 SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)15 OperationToSyncOperationStatus (com.sequenceiq.freeipa.converter.freeipa.user.OperationToSyncOperationStatus)12 AcceptResult (com.sequenceiq.freeipa.service.freeipa.user.AcceptResult)11 UserSyncRequestFilter (com.sequenceiq.freeipa.service.freeipa.user.UserSyncRequestFilter)10 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)9 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)8 EnvironmentUserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState)7 OperationType (com.sequenceiq.freeipa.api.v1.operation.model.OperationType)7 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)6 UserSyncOptions (com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)5 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)5 FreeIpaUpgradeResponse (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeResponse)4 SynchronizeAllUsersRequest (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest)4 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)3