Search in sources :

Example 6 with ConsumptionContext

use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext in project cloudbreak by hortonworks.

the class StorageConsumptionCollectionHandlerTest method testExecuteOperation.

@Test
public void testExecuteOperation() {
    String resourceCrn = "consumptionCrn";
    Long resourceId = 1L;
    String envCrn = "envCrn";
    Consumption consumption = new Consumption();
    consumption.setResourceCrn(resourceCrn);
    consumption.setId(resourceId);
    consumption.setEnvironmentCrn(envCrn);
    ConsumptionContext context = new ConsumptionContext(null, consumption);
    StorageConsumptionCollectionHandlerEvent event = new StorageConsumptionCollectionHandlerEvent(STORAGE_CONSUMPTION_COLLECTION_HANDLER.selector(), resourceId, resourceCrn, context);
    when(credentialService.getCredentialByEnvCrn(envCrn)).thenReturn(credential);
    when(credentialConverter.convert(credential)).thenReturn(new CloudCredential());
    StorageConsumptionCollectionEvent result = (StorageConsumptionCollectionEvent) underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
    verify(credentialService).getCredentialByEnvCrn(envCrn);
    verify(credentialConverter).convert(credential);
    assertEquals(resourceCrn, result.getResourceCrn());
    assertEquals(resourceId, result.getResourceId());
    assertEquals(SEND_CONSUMPTION_EVENT_EVENT.selector(), result.selector());
}
Also used : Consumption(com.sequenceiq.consumption.domain.Consumption) StorageConsumptionCollectionHandlerEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionHandlerEvent) ConsumptionContext(com.sequenceiq.consumption.flow.consumption.ConsumptionContext) StorageConsumptionCollectionEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StorageConsumptionCollectionHandlerEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionHandlerEvent) Test(org.junit.jupiter.api.Test)

Aggregations

ConsumptionContext (com.sequenceiq.consumption.flow.consumption.ConsumptionContext)6 StorageConsumptionCollectionEvent (com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent)5 Map (java.util.Map)4 Bean (org.springframework.context.annotation.Bean)4 StorageConsumptionCollectionHandlerEvent (com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionHandlerEvent)3 Test (org.junit.jupiter.api.Test)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 Consumption (com.sequenceiq.consumption.domain.Consumption)1 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)1