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());
}
Aggregations