use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class BindUserCreateServiceTest method testCreateStartedFLowNotified.
@Test
public void testCreateStartedFLowNotified() {
BindUserCreateRequest request = createRequest();
Operation operation = new Operation();
operation.setOperationId("op");
operation.setStatus(OperationState.RUNNING);
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);
ArgumentCaptor<Acceptable> captor = ArgumentCaptor.forClass(Acceptable.class);
verify(flowManager).notify(eq(CREATE_BIND_USER_EVENT.event()), captor.capture());
Acceptable event = captor.getValue();
assertTrue(event instanceof CreateBindUserEvent);
CreateBindUserEvent bindUserEvent = (CreateBindUserEvent) event;
assertEquals(CREATE_BIND_USER_EVENT.event(), bindUserEvent.selector());
assertEquals(STACK_ID, bindUserEvent.getResourceId());
assertEquals(ACCOUNT, bindUserEvent.getAccountId());
assertEquals(operation.getOperationId(), bindUserEvent.getOperationId());
assertEquals(request.getEnvironmentCrn(), bindUserEvent.getEnvironmentCrn());
assertEquals(request.getBindUserNameSuffix(), bindUserEvent.getSuffix());
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UpgradeCcmOperationAcceptorTest method acceptTestWhenHasRunningOperationForSameStack.
@Test
void acceptTestWhenHasRunningOperationForSameStack() {
Operation operation = createOperation(ID_1, List.of(ENVIRONMENT_CRN_1));
when(operationRepository.findRunningByAccountIdAndType(ACCOUNT_ID, OperationType.UPGRADE_CCM)).thenReturn(List.of(createOperation(ID_2, List.of(ENVIRONMENT_CRN_1))));
AcceptResult result = underTest.accept(operation);
assertThat(result).isNotNull();
assertThat(result.isAccepted()).isFalse();
Optional<String> rejectionMessage = result.getRejectionMessage();
assertThat(rejectionMessage).isNotNull();
assertThat(rejectionMessage).isPresent();
assertThat(rejectionMessage.get()).isEqualTo("There is already a running Cluster Connectivity Manager upgrade for FreeIPA stack");
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UpgradeCcmOperationAcceptorTest method acceptTestWhenSuccess.
@ParameterizedTest(name = "{0}")
@MethodSource("acceptTestWhenSuccessDataProvider")
void acceptTestWhenSuccess(String testCaseName, List<Operation> runningOperations) {
Operation operation = createOperation(ID_1, List.of(ENVIRONMENT_CRN_1));
when(operationRepository.findRunningByAccountIdAndType(ACCOUNT_ID, OperationType.UPGRADE_CCM)).thenReturn(runningOperations);
AcceptResult result = underTest.accept(operation);
assertThat(result).isNotNull();
assertThat(result.isAccepted()).isTrue();
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UpgradeCcmOperationAcceptorTest method acceptTestWhenValidationFailure.
@ParameterizedTest(name = "{0}")
@MethodSource("acceptTestWhenValidationFailureDataProvider")
void acceptTestWhenValidationFailure(String testCaseName, List<String> environmentList) {
Operation operation = createOperation(ID_1, environmentList);
AcceptResult result = underTest.accept(operation);
assertThat(result).isNotNull();
assertThat(result.isAccepted()).isFalse();
Optional<String> rejectionMessage = result.getRejectionMessage();
assertThat(rejectionMessage).isNotNull();
assertThat(rejectionMessage).isPresent();
assertThat(rejectionMessage.get()).isEqualTo("Cluster Connectivity Manager upgrade must be invoked for a single environment!");
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class BindUserCreateOperationAcceptorTest method testMultipleEnv.
@Test
public void testMultipleEnv() {
Operation currentOperation = createCurrentOperation();
currentOperation.setEnvironmentList(List.of(ENV_CRN, "env2"));
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());
}
Aggregations