use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class BindUserCreateOperationAcceptorTest method testMissingEnv.
@Test
public void testMissingEnv() {
Operation currentOperation = createCurrentOperation();
currentOperation.setEnvironmentList(null);
when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(currentOperation));
AcceptResult result = underTest.accept(currentOperation);
assertFalse(result.isAccepted());
assertEquals("Bind user create must run only for one environment!", result.getRejectionMessage().get());
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class BindUserCreateOperationAcceptorTest method testMultipleSuffix.
@Test
public void testMultipleSuffix() {
Operation currentOperation = createCurrentOperation();
currentOperation.setUserList(List.of(SUFFIX, "cluster2"));
when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(currentOperation));
AcceptResult result = underTest.accept(currentOperation);
assertFalse(result.isAccepted());
assertEquals("Bind user create must run only for one suffix!", result.getRejectionMessage().get());
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class SyncOperationToOperationStatusConverterTest method convertFailed.
@Test
void convertFailed() {
OperationState operationState = OperationState.FAILED;
SynchronizationStatus synchronizationStatus = SynchronizationStatus.fromOperationState(operationState);
Operation operation = createSyncOperation(operationState);
String errorMessage = "error message";
operation.setError(errorMessage);
SyncOperationStatus actual = underTest.convert(operation);
assertEqualsDefaults(actual);
assertEquals(synchronizationStatus, actual.getStatus());
assertEquals(List.of(), actual.getSuccess());
assertEquals(List.of(), actual.getFailure());
assertEquals(errorMessage, actual.getError());
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class SyncOperationToOperationStatusConverterTest method convertCompleted.
@Test
void convertCompleted() {
OperationState operationState = OperationState.COMPLETED;
SynchronizationStatus synchronizationStatus = SynchronizationStatus.fromOperationState(operationState);
List<SuccessDetails> successDetails = List.of(new SuccessDetails("environment1"), new SuccessDetails("environment2"));
List<FailureDetails> failureDetails = List.of(new FailureDetails("environment3", "failure message1"), new FailureDetails("environment4", "failure message2"));
Operation operation = createSyncOperation(operationState);
operation.setSuccessList(successDetails);
operation.setFailureList(failureDetails);
SyncOperationStatus actual = underTest.convert(operation);
assertEqualsDefaults(actual);
assertEquals(synchronizationStatus, actual.getStatus());
assertEquals(successDetails, actual.getSuccess());
assertEquals(failureDetails, actual.getFailure());
assertNull(actual.getError());
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UserV1ControllerTest method getStatusInternal.
@Test
void getStatusInternal() {
String operationId = "testId";
Operation operation = mock(Operation.class);
when(operationService.getOperationForAccountIdAndOperationId(ACCOUNT_ID, operationId)).thenReturn(operation);
SyncOperationStatus status = mock(SyncOperationStatus.class);
when(operationToSyncOperationStatus.convert(operation)).thenReturn(status);
assertEquals(status, ThreadBasedUserCrnProvider.doAsInternalActor("crn", () -> underTest.getSyncOperationStatusInternal(ACCOUNT_ID, operationId)));
verify(operationService, times(1)).getOperationForAccountIdAndOperationId(ACCOUNT_ID, operationId);
}
Aggregations