use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext in project cloudbreak by hortonworks.
the class StorageConsumptionCollectionActions method storageConsumptionCollectionAction.
@Bean(name = "STORAGE_CONSUMPTION_COLLECTION_STATE")
public Action<?, ?> storageConsumptionCollectionAction() {
return new AbstractStorageConsumptionCollectionAction<>(StorageConsumptionCollectionEvent.class) {
@Override
protected void doExecute(ConsumptionContext context, StorageConsumptionCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into STORAGE_CONSUMPTION_COLLECTION_STATE. resourceCrn: '{}'", resourceCrn);
StorageConsumptionCollectionHandlerEvent event = new StorageConsumptionCollectionHandlerEvent(StorageConsumptionCollectionHandlerSelectors.STORAGE_CONSUMPTION_COLLECTION_HANDLER.selector(), payload.getResourceId(), resourceCrn, context);
sendEvent(context, event);
}
};
}
use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext in project cloudbreak by hortonworks.
the class StorageConsumptionCollectionActions method finishedAction.
@Bean(name = "STORAGE_CONSUMPTION_COLLECTION_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractStorageConsumptionCollectionAction<>(StorageConsumptionCollectionEvent.class) {
@Override
protected void doExecute(ConsumptionContext context, StorageConsumptionCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into STORAGE_CONSUMPTION_COLLECTION_FINISHED_STATE. resourceCrn: '{}'", resourceCrn);
StorageConsumptionCollectionEvent event = StorageConsumptionCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(resourceCrn).withSelector(StorageConsumptionCollectionStateSelectors.STORAGE_CONSUMPTION_COLLECTION_FINALIZED_EVENT.selector()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext in project cloudbreak by hortonworks.
the class StorageConsumptionCollectionActions method failedAction.
@Bean(name = "STORAGE_CONSUMPTION_COLLECTION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractStorageConsumptionCollectionAction<>(StorageConsumptionCollectionEvent.class) {
@Override
protected void doExecute(ConsumptionContext context, StorageConsumptionCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into STORAGE_CONSUMPTION_COLLECTION_FAILED_STATE. resourceCrn: '{}'", resourceCrn);
StorageConsumptionCollectionEvent event = StorageConsumptionCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(resourceCrn).withSelector(StorageConsumptionCollectionStateSelectors.STORAGE_CONSUMPTION_COLLECTION_HANDLED_FAILED_EVENT.selector()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext in project cloudbreak by hortonworks.
the class StorageConsumptionCollectionActions method sendConsumptionEventAction.
@Bean(name = "SEND_CONSUMPTION_EVENT_STATE")
public Action<?, ?> sendConsumptionEventAction() {
return new AbstractStorageConsumptionCollectionAction<>(StorageConsumptionCollectionEvent.class) {
@Override
protected void doExecute(ConsumptionContext context, StorageConsumptionCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into SEND_CONSUMPTION_EVENT_STATE. resourceCrn: '{}'", resourceCrn);
StorageConsumptionCollectionHandlerEvent event = new StorageConsumptionCollectionHandlerEvent(StorageConsumptionCollectionHandlerSelectors.SEND_CONSUMPTION_EVENT_HANDLER.selector(), payload.getResourceId(), resourceCrn, context);
sendEvent(context, event);
}
};
}
use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext in project cloudbreak by hortonworks.
the class AbstractStorageConsumptionCollectionActionTest method testCreateFlowContext.
@Test
public void testCreateFlowContext() {
when(consumptionService.findConsumptionById(RESOURCE_ID)).thenReturn(consumption);
ConsumptionContext ctx = underTest.createFlowContext(flowParameters, stateContext, new TestPayload());
assertEquals(consumption, ctx.getConsumption());
}
Aggregations