Search in sources :

Example 1 with OperationState

use of com.sequenceiq.freeipa.api.v1.operation.model.OperationState in project cloudbreak by hortonworks.

the class FreeIpaPollerProviderTest method testUpgradeCcmPoller.

@ParameterizedTest
@MethodSource("upgradeCcmStatuses")
void testUpgradeCcmPoller(OperationState operationState, AttemptState attemptState, String message) {
    OperationStatus status = new OperationStatus("123", OperationType.UPGRADE_CCM, operationState, null, null, null, 0, null);
    when(freeIpaService.getOperationStatus("123")).thenReturn(status);
    AttemptResult<Void> result = underTest.upgradeCcmPoller(ENV_ID, CRN, "123");
    Assertions.assertEquals(attemptState, result.getState());
    Assertions.assertEquals(message, result.getMessage());
}
Also used : OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with OperationState

use of com.sequenceiq.freeipa.api.v1.operation.model.OperationState in project cloudbreak by hortonworks.

the class FreeIpaUpgradeCcmServiceTest method upgradeCcmTestWhenAvailableAndOperationNotRunning.

@ParameterizedTest(name = "{0}")
@EnumSource(value = OperationState.class, names = { "RUNNING" }, mode = EnumSource.Mode.EXCLUDE)
void upgradeCcmTestWhenAvailableAndOperationNotRunning(OperationState operationState) {
    Stack stack = createStack(Status.AVAILABLE);
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
    Operation operation = createOperation(operationState);
    when(operationService.startOperation(ACCOUNT_ID, OperationType.UPGRADE_CCM, List.of(ENVIRONMENT_CRN), List.of())).thenReturn(operation);
    when(operationConverter.convert(operation)).thenReturn(operationStatus);
    OperationStatus result = underTest.upgradeCcm(ENVIRONMENT_CRN, ACCOUNT_ID);
    assertThat(result).isSameAs(operationStatus);
    verifyNoInteractions(flowManager);
}
Also used : OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) Operation(com.sequenceiq.freeipa.entity.Operation) Stack(com.sequenceiq.freeipa.entity.Stack) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with OperationState

use of com.sequenceiq.freeipa.api.v1.operation.model.OperationState 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());
}
Also used : SynchronizationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) Operation(com.sequenceiq.freeipa.entity.Operation) OperationState(com.sequenceiq.freeipa.api.v1.operation.model.OperationState) Test(org.junit.jupiter.api.Test)

Example 4 with OperationState

use of com.sequenceiq.freeipa.api.v1.operation.model.OperationState 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());
}
Also used : SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) SynchronizationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) Operation(com.sequenceiq.freeipa.entity.Operation) FailureDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails) OperationState(com.sequenceiq.freeipa.api.v1.operation.model.OperationState) Test(org.junit.jupiter.api.Test)

Example 5 with OperationState

use of com.sequenceiq.freeipa.api.v1.operation.model.OperationState in project cloudbreak by hortonworks.

the class SyncOperationToOperationStatusConverterTest method convertRunning.

@Test
void convertRunning() {
    OperationState operationState = OperationState.RUNNING;
    SynchronizationStatus synchronizationStatus = SynchronizationStatus.fromOperationState(operationState);
    Operation operation = createSyncOperation(operationState);
    SyncOperationStatus actual = underTest.convert(operation);
    assertEqualsDefaults(actual);
    assertEquals(synchronizationStatus, actual.getStatus());
    assertEquals(List.of(), actual.getSuccess());
    assertEquals(List.of(), actual.getFailure());
    assertNull(actual.getError());
}
Also used : SynchronizationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) Operation(com.sequenceiq.freeipa.entity.Operation) OperationState(com.sequenceiq.freeipa.api.v1.operation.model.OperationState) Test(org.junit.jupiter.api.Test)

Aggregations

SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)4 Operation (com.sequenceiq.freeipa.entity.Operation)4 SynchronizationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus)3 OperationState (com.sequenceiq.freeipa.api.v1.operation.model.OperationState)3 Test (org.junit.jupiter.api.Test)3 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 FailureDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails)1 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1