use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.
the class EnvClustersDeleteActionsTest 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;
}
use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.
the class SleepFlow method sleepFailed.
@Bean("SLEEP_FAILED_STATE")
public Action<?, ?> sleepFailed() {
return new AbstractAction<>(SleepFailedEvent.class) {
@Override
protected CommonContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SleepFailedEvent payload) {
return new CommonContext(flowParameters);
}
@Override
protected void doExecute(CommonContext context, SleepFailedEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Sleep fail handled!");
Flow flow = getFlow(context.getFlowId());
flow.setFlowFailed(new Exception(payload.getReason()));
sendEvent(context, SleepEvent.SLEEP_FAIL_HANDLED_EVENT.selector(), payload);
}
@Override
protected Object getFailurePayload(SleepFailedEvent payload, Optional<CommonContext> flowContext, Exception ex) {
return null;
}
};
}
use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.
the class ExternalDatabaseCreationActionsTest 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;
}
use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.
the class ExternalDatabaseStopActionsTest 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;
}
use of com.sequenceiq.flow.core.AbstractAction in project cloudbreak by hortonworks.
the class DatalakeRestoreActionsTest method testGetNewSdxIdForResizeDoExecute.
@Test
public void testGetNewSdxIdForResizeDoExecute() throws Exception {
when(sdxBackupRestoreService.triggerDatalakeRestore(eq(NEW_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(), NEW_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(NEW_SDX_ID, captorValue.getResourceId());
}
Aggregations