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)));
}
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());
}
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));
}
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));
}
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;
}
Aggregations