Search in sources :

Example 1 with CloudPlatformResult

use of com.sequenceiq.cloudbreak.cloud.event.CloudPlatformResult in project cloudbreak by hortonworks.

the class StackImageUpdateActions method finishAction.

@Bean(name = "STACK_IMAGE_UPDATE_FINISHED")
public AbstractStackImageUpdateAction<?> finishAction() {
    return new AbstractStackImageUpdateAction<>(CloudPlatformResult.class) {

        @Override
        protected void doExecute(StackContext context, CloudPlatformResult payload, Map<Object, Object> variables) {
            getFlowMessageService().fireEventAndLog(context.getStack().getId(), Status.AVAILABLE.name(), STACK_IMAGE_UPDATE_FINISHED);
            getStackUpdater().updateStackStatus(context.getStack().getId(), DetailedStackStatus.AVAILABLE);
            sendEvent(context, new StackEvent(STACK_IMAGE_UPDATE_FINISHED_EVENT.event(), context.getStack().getId()));
        }
    };
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) CloudPlatformResult(com.sequenceiq.cloudbreak.cloud.event.CloudPlatformResult) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with CloudPlatformResult

use of com.sequenceiq.cloudbreak.cloud.event.CloudPlatformResult in project cloudbreak by hortonworks.

the class StackImageUpdateActionsTest method finishAction.

@Test
public void finishAction() {
    FlowEvent flowEvent = Mockito.mock(FlowEvent.class);
    when(stateContext.getEvent()).thenReturn(flowEvent);
    when(flowEvent.name()).thenReturn(EVENT_NAME);
    CloudPlatformResult payload = new CloudPlatformResult(1L);
    when(stateContext.getMessageHeader(HEADERS.DATA.name())).thenReturn(payload);
    when(state.getId()).thenReturn(StackImageUpdateState.STACK_IMAGE_UPDATE_FINISHED);
    finishAction.execute(stateContext);
    verify(flowMessageService, times(1)).fireEventAndLog(anyLong(), eq(Status.AVAILABLE.name()), eq(ResourceEvent.STACK_IMAGE_UPDATE_FINISHED));
}
Also used : FlowEvent(com.sequenceiq.flow.core.FlowEvent) CloudPlatformResult(com.sequenceiq.cloudbreak.cloud.event.CloudPlatformResult) Test(org.junit.Test)

Aggregations

CloudPlatformResult (com.sequenceiq.cloudbreak.cloud.event.CloudPlatformResult)2 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 FlowEvent (com.sequenceiq.flow.core.FlowEvent)1 Map (java.util.Map)1 Test (org.junit.Test)1 Bean (org.springframework.context.annotation.Bean)1