use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.
the class CDPStructuredFlowEventToCDPEnvironmentRequestedConverterTest method testConvertingEmptyStructuredFlowEvent.
@Test
public void testConvertingEmptyStructuredFlowEvent() {
CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
UsageProto.CDPEnvironmentRequested environmentRequested = underTest.convert(cdpStructuredFlowEvent);
Assertions.assertNotNull(environmentRequested.getOperationDetails());
Assertions.assertNotNull(environmentRequested.getEnvironmentDetails());
Assertions.assertNotNull(environmentRequested.getFreeIPA());
Assertions.assertNotNull(environmentRequested.getTelemetryFeatureDetails());
}
use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.
the class EnvironmentStructuredFlowEventFactory method createStructuredFlowEvent.
@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Exception exception) {
Environment environment = environmentService.findEnvironmentByIdOrThrow(resourceId);
String resourceType = CloudbreakEventService.ENVIRONMENT_RESOURCE_TYPE;
CDPOperationDetails operationDetails = new CDPOperationDetails(clock.getCurrentTimeMillis(), FLOW, resourceType, environment.getId(), environment.getName(), nodeConfig.getId(), serviceVersion, environment.getAccountId(), environment.getResourceCrn(), environment.getCreator(), environment.getResourceCrn(), null);
EnvironmentDetails environmentDetails = environmentDtoConverter.environmentToDto(environment);
CDPEnvironmentStructuredFlowEvent event = new CDPEnvironmentStructuredFlowEvent(operationDetails, flowDetails, environmentDetails, environment.getStatus().name(), getReason(environment));
if (exception != null) {
event.setException(ExceptionUtils.getStackTrace(exception));
}
return event;
}
use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.
the class CDPEnvironmentStructuredFlowEventToCDPEnvironmentRequestedConverterTest method testConvertingEmptyStructuredFlowEvent.
@Test
public void testConvertingEmptyStructuredFlowEvent() {
CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
UsageProto.CDPEnvironmentRequested environmentRequested = underTest.convert(cdpStructuredFlowEvent);
Assertions.assertNotNull(environmentRequested.getOperationDetails());
Assertions.assertNotNull(environmentRequested.getEnvironmentDetails());
Assertions.assertNotNull(environmentRequested.getFreeIPA());
Assertions.assertNotNull(environmentRequested.getTelemetryFeatureDetails());
}
use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.
the class CDPEnvironmentStructuredFlowEventToCDPEnvironmentStatusChangedConverterTest method testConvertingEmptyStructuredFlowEvent.
@Test
public void testConvertingEmptyStructuredFlowEvent() {
CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
UsageProto.CDPEnvironmentStatusChanged environmentStatusChanged = underTest.convert(cdpStructuredFlowEvent, UsageProto.CDPEnvironmentStatus.Value.CREATE_STARTED);
Assertions.assertEquals(UsageProto.CDPEnvironmentStatus.Value.CREATE_STARTED, environmentStatusChanged.getNewStatus());
Assertions.assertEquals(UsageProto.CDPEnvironmentStatus.Value.UNSET, environmentStatusChanged.getOldStatus());
Assertions.assertNotNull(environmentStatusChanged.getOperationDetails());
Assertions.assertNotNull(environmentStatusChanged.getEnvironmentDetails());
Assertions.assertNotNull(environmentStatusChanged.getFreeIPA());
Assertions.assertNotNull(environmentStatusChanged.getTelemetryFeatureDetails());
}
use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.
the class CDPStructuredFlowEventToCDPOperationDetailsConverterTest method testFlowStateOnlyFilledOutInCaseOfFailure.
@Test
public void testFlowStateOnlyFilledOutInCaseOfFailure() {
CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
FlowDetails flowDetails = new FlowDetails();
cdpStructuredFlowEvent.setFlow(flowDetails);
flowDetails.setFlowState("FLOW_STATE");
flowDetails.setNextFlowState("ENV_CREATION_FAILED_STATE");
UsageProto.CDPOperationDetails details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("FLOW_STATE", details.getFlowState());
flowDetails.setFlowState("FLOW_STATE");
flowDetails.setNextFlowState("DOWNSCALE_FAIL_STATE");
details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("FLOW_STATE", details.getFlowState());
flowDetails.setFlowState("FLOW_STATE");
flowDetails.setNextFlowState("ENV_CREATION_FINISHED_STATE");
details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("", details.getFlowState());
flowDetails.setFlowState("FLOW_STATE");
flowDetails.setNextFlowState("INIT_STATE");
details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("", details.getFlowState());
flowDetails.setFlowState(null);
flowDetails.setNextFlowState("ENV_CREATION_FAILED_STATE");
details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("", details.getFlowState());
flowDetails.setFlowState(null);
flowDetails.setNextFlowState("DOWNSCALE_FAIL_STATE");
details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("", details.getFlowState());
flowDetails.setFlowState("unknown");
flowDetails.setNextFlowState("ENV_CREATION_FAILED_STATE");
details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("", details.getFlowState());
flowDetails.setFlowState("unknown");
flowDetails.setNextFlowState("DOWNSCALE_FAIL_STATE");
details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("", details.getFlowState());
flowDetails.setFlowState("FLOW_STATE");
flowDetails.setNextFlowState(null);
details = underTest.convert(cdpStructuredFlowEvent, null);
Assertions.assertEquals("", details.getFlowState());
}
Aggregations