use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UserSyncAcceptorTest method testSingleUserSyncRejectedOnUserAndEnvOverlap.
@Test
void testSingleUserSyncRejectedOnUserAndEnvOverlap() {
Operation syncOperation = mock(Operation.class);
when(syncOperation.getUserList()).thenReturn(List.of("userA", "userB"));
when(syncOperation.getEnvironmentList()).thenReturn(List.of("envA"));
Operation runningSyncOperation = mock(Operation.class);
when(runningSyncOperation.getUserList()).thenReturn(List.of("userA"));
when(runningSyncOperation.getEnvironmentList()).thenReturn(List.of("envA"));
assertTrue(userSyncAcceptor.doOperationsConflict(syncOperation, runningSyncOperation));
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class BindUserCreateServiceTest method testOperationRejected.
@Test
public void testOperationRejected() {
BindUserCreateRequest request = createRequest();
Operation operation = new Operation();
operation.setOperationId("op");
operation.setStatus(OperationState.REJECTED);
when(operationService.startOperation(eq(ACCOUNT), eq(OperationType.BIND_USER_CREATE), anyCollection(), anyCollection())).thenReturn(operation);
OperationStatus operationStatus = new OperationStatus();
when(operationConverter.convert(operation)).thenReturn(operationStatus);
OperationStatus response = underTest.createBindUser(ACCOUNT, request);
assertEquals(operationStatus, response);
verifyNoInteractions(flowManager);
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class BindUserCreateServiceTest method testFlowRejected.
@Test
public void testFlowRejected() {
BindUserCreateRequest request = createRequest();
Operation operation = new Operation();
operation.setOperationId("op");
operation.setStatus(OperationState.RUNNING);
Operation failedOperation = new Operation();
failedOperation.setOperationId("op");
failedOperation.setStatus(OperationState.FAILED);
when(operationService.startOperation(eq(ACCOUNT), eq(OperationType.BIND_USER_CREATE), anyCollection(), anyCollection())).thenReturn(operation);
when(operationService.failOperation(ACCOUNT, operation.getOperationId(), "Couldn't start create bind user flow: Flow failure")).thenReturn(failedOperation);
OperationStatus failedOperationStatus = new OperationStatus();
failedOperationStatus.setStatus(OperationState.FAILED);
when(operationConverter.convert(failedOperation)).thenReturn(failedOperationStatus);
when(flowManager.notify(anyString(), any(Acceptable.class))).thenThrow(new RuntimeException("Flow failure"));
OperationStatus response = underTest.createBindUser(ACCOUNT, request);
assertEquals(failedOperationStatus, response);
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateLastSyncTimedout.
@Test
void internalCalculateEnvironmentUserSyncStateLastSyncTimedout() {
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());
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class EnvironmentUserSyncStateCalculatorTest method internalCalculateEnvironmentUserSyncStateLastSyncRequested.
@Test
void internalCalculateEnvironmentUserSyncStateLastSyncRequested() {
UserSyncStatus userSyncStatus = new UserSyncStatus();
Operation lastSync = new Operation();
lastSync.setOperationId(UUID.randomUUID().toString());
lastSync.setStatus(OperationState.REQUESTED);
userSyncStatus.setLastStartedFullSync(lastSync);
assertThrows(IllegalStateException.class, () -> underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, Optional.of(userSyncStatus)));
}
Aggregations