Search in sources :

Example 11 with AbstractAction

use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.

the class DatalakeRestoreActionsTest method testRestoreWithNoFlowChain.

@Test
public void testRestoreWithNoFlowChain() throws Exception {
    when(sdxBackupRestoreService.triggerDatalakeRestore(eq(OLD_SDX_ID), any(), any(), eq(USER_CRN))).thenReturn(new DatalakeRestoreStatusResponse(BACKUP_ID, RESTORE_ID, State.STARTED, Optional.empty()));
    DatalakeTriggerRestoreEvent event = new DatalakeTriggerRestoreEvent(DATALAKE_TRIGGER_RESTORE_EVENT.event(), OLD_SDX_ID, DATALAKE_NAME, USER_CRN, null, BACKUP_LOCATION, null, DatalakeRestoreFailureReason.RESTORE_ON_RESIZE);
    AbstractAction action = (AbstractAction) underTest.triggerDatalakeRestore();
    initActionPrivateFields(action);
    AbstractActionTestSupport testSupport = new AbstractActionTestSupport(action);
    SdxContext context = SdxContext.from(new FlowParameters(FLOW_ID, FLOW_ID, null), event);
    testSupport.doExecute(context, event, new HashMap());
    ArgumentCaptor<DatalakeDatabaseRestoreStartEvent> captor = ArgumentCaptor.forClass(DatalakeDatabaseRestoreStartEvent.class);
    verify(reactorEventFactory, times(1)).createEvent(any(), captor.capture());
    DatalakeDatabaseRestoreStartEvent captorValue = captor.getValue();
    Assertions.assertEquals(OLD_SDX_ID, captorValue.getResourceId());
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) DatalakeTriggerRestoreEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent) HashMap(java.util.HashMap) AbstractActionTestSupport(com.sequenceiq.flow.core.AbstractActionTestSupport) DatalakeDatabaseRestoreStartEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeDatabaseRestoreStartEvent) AbstractAction(com.sequenceiq.flow.core.AbstractAction) DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Test(org.junit.jupiter.api.Test)

Example 12 with AbstractAction

use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.

the class DatahubRefreshActionsTest method testStartTriggersCall.

@Test
public void testStartTriggersCall() throws Exception {
    DatahubRefreshStartEvent event = new DatahubRefreshStartEvent(SDX_ID, SDX_NAME, USER_CRN);
    AbstractAction action = (AbstractAction) underTest.startDatahubRefreshAction();
    initActionPrivateFields(action);
    AbstractActionTestSupport testSupport = new AbstractActionTestSupport(action);
    SdxContext context = SdxContext.from(new FlowParameters(FLOW_ID, USER_CRN, null), event);
    testSupport.doExecute(context, event, new HashMap());
    ArgumentCaptor<DatahubRefreshStartEvent> captor = ArgumentCaptor.forClass(DatahubRefreshStartEvent.class);
    verify(reactorEventFactory, times(1)).createEvent(any(), captor.capture());
    DatahubRefreshStartEvent captorValue = captor.getValue();
    Assertions.assertEquals(SDX_NAME, captorValue.getSdxName());
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) HashMap(java.util.HashMap) AbstractActionTestSupport(com.sequenceiq.flow.core.AbstractActionTestSupport) AbstractAction(com.sequenceiq.flow.core.AbstractAction) DatahubRefreshStartEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshStartEvent) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Test(org.junit.jupiter.api.Test)

Example 13 with AbstractAction

use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.

the class EnvDeleteActionsTest method configureAction.

private Action<?, ?> configureAction(Supplier<Action<?, ?>> actionSupplier) {
    Action<?, ?> action = actionSupplier.get();
    assertThat(action).isNotNull();
    setActionPrivateFields(action);
    AbstractAction abstractAction = (AbstractAction) action;
    abstractAction.setFailureEvent(failureEvent);
    return action;
}
Also used : AbstractAction(com.sequenceiq.flow.core.AbstractAction)

Example 14 with AbstractAction

use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.

the class UpgradeCcmActionsTest method configureAction.

private Action<?, ?> configureAction(Supplier<Action<?, ?>> actionSupplier) {
    Action<?, ?> action = actionSupplier.get();
    assertThat(action).isNotNull();
    setActionPrivateFields(action);
    AbstractAction abstractAction = (AbstractAction) action;
    abstractAction.setFailureEvent(failureEvent);
    return action;
}
Also used : AbstractAction(com.sequenceiq.flow.core.AbstractAction)

Example 15 with AbstractAction

use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.

the class EnvCreationActionsTest method configureAction.

private Action<?, ?> configureAction(Supplier<Action<?, ?>> actionSupplier) {
    Action<?, ?> action = actionSupplier.get();
    assertThat(action).isNotNull();
    setActionPrivateFields(action);
    AbstractAction abstractAction = (AbstractAction) action;
    abstractAction.setFailureEvent(failureEvent);
    return action;
}
Also used : AbstractAction(com.sequenceiq.flow.core.AbstractAction)

Aggregations

AbstractAction (com.sequenceiq.flow.core.AbstractAction)15 FlowParameters (com.sequenceiq.flow.core.FlowParameters)6 SdxContext (com.sequenceiq.datalake.flow.SdxContext)4 AbstractActionTestSupport (com.sequenceiq.flow.core.AbstractActionTestSupport)4 Test (org.junit.jupiter.api.Test)4 DatalakeTriggerRestoreEvent (com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent)3 HashMap (java.util.HashMap)3 DatalakeRestoreStatusResponse (com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse)2 DatalakeDatabaseRestoreStartEvent (com.sequenceiq.datalake.flow.dr.restore.event.DatalakeDatabaseRestoreStartEvent)2 Flow (com.sequenceiq.flow.core.Flow)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Bean (org.springframework.context.annotation.Bean)2 StateContext (org.springframework.statemachine.StateContext)2 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 ClusterUpgradeContext (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.ClusterUpgradeContext)1 ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent)1 ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)1 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)1