use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.
the class StructuredSyncEventFactoryTest method createCDPStructuredSyncEvent.
@Test
public void createCDPStructuredSyncEvent() {
Stack stack = TestUtil.stack();
stack.setResourceCrn("crn");
Cluster cluster = TestUtil.cluster();
Blueprint blueprint = TestUtil.blueprint();
cluster.setBlueprint(blueprint);
stack.setCluster(cluster);
BlueprintDetails blueprintDetails = new BlueprintDetails();
blueprintDetails.setBlueprintName("testBpName");
when(stackToStackDetailsConverter.convert(any())).thenReturn(null);
when(blueprintToBlueprintDetailsConverter.convert(blueprint)).thenReturn(blueprintDetails);
when(stackService.getByIdWithTransaction(1L)).thenReturn(stack);
when(nodeConfig.getId()).thenReturn("cbid");
StructuredSyncEvent result = underTest.createStructuredSyncEvent(1L);
assertNull(result.getStack());
assertEquals(CloudbreakEventService.DATAHUB_RESOURCE_TYPE, result.getOperation().getResourceType());
assertEquals("crn", result.getOperation().getResourceCrn());
assertEquals("cbid", result.getOperation().getCloudbreakId());
assertEquals("testBpName", result.getBlueprintDetails().getBlueprintName());
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.
the class StructuredEventToCDPOperationDetailsConverterTest method testEnvironmentTypeSetCorrectly.
@Test
public void testEnvironmentTypeSetCorrectly() {
StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
StackDetails flowStackDetails = new StackDetails();
flowStackDetails.setCloudPlatform(CloudPlatform.AWS.name());
structuredFlowEvent.setStack(flowStackDetails);
UsageProto.CDPOperationDetails flowOperationDetails = underTest.convert(structuredFlowEvent);
Assert.assertEquals(UsageProto.CDPEnvironmentsEnvironmentType.Value.AWS, flowOperationDetails.getEnvironmentType());
StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
StackDetails syncStackDetails = new StackDetails();
syncStackDetails.setCloudPlatform(CloudPlatform.AWS.name());
structuredSyncEvent.setStack(syncStackDetails);
UsageProto.CDPOperationDetails syncOperationDetails = underTest.convert(structuredSyncEvent);
Assert.assertEquals(UsageProto.CDPEnvironmentsEnvironmentType.Value.AWS, syncOperationDetails.getEnvironmentType());
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.
the class StructuredEventToCDPOperationDetailsConverterTest method testConversionWithNullOperation.
@Test
public void testConversionWithNullOperation() {
StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
UsageProto.CDPOperationDetails flowOperationDetails = underTest.convert(structuredFlowEvent);
Assert.assertEquals("", flowOperationDetails.getAccountId());
Assert.assertEquals("", flowOperationDetails.getResourceCrn());
Assert.assertEquals("", flowOperationDetails.getResourceName());
Assert.assertEquals("", flowOperationDetails.getInitiatorCrn());
Assert.assertEquals("", flowOperationDetails.getCorrelationId());
Assert.assertEquals(UsageProto.CDPRequestProcessingStep.Value.UNSET, flowOperationDetails.getCdpRequestProcessingStep());
Assert.assertEquals("", flowOperationDetails.getFlowId());
Assert.assertEquals("", flowOperationDetails.getFlowChainId());
Assert.assertEquals("", flowOperationDetails.getFlowState());
Assert.assertEquals(UsageProto.CDPEnvironmentsEnvironmentType.Value.UNSET, flowOperationDetails.getEnvironmentType());
Assert.assertEquals("version-1234", flowOperationDetails.getApplicationVersion());
StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
UsageProto.CDPOperationDetails syncOperationDetails = underTest.convert(structuredSyncEvent);
Assert.assertEquals("", syncOperationDetails.getAccountId());
Assert.assertEquals("", syncOperationDetails.getResourceCrn());
Assert.assertEquals("", syncOperationDetails.getResourceName());
Assert.assertEquals("", syncOperationDetails.getInitiatorCrn());
Assert.assertEquals("", syncOperationDetails.getCorrelationId());
Assert.assertEquals(UsageProto.CDPRequestProcessingStep.Value.SYNC, syncOperationDetails.getCdpRequestProcessingStep());
Assert.assertEquals("", syncOperationDetails.getFlowId());
Assert.assertEquals("", syncOperationDetails.getFlowChainId());
Assert.assertEquals("", syncOperationDetails.getFlowState());
Assert.assertEquals(UsageProto.CDPEnvironmentsEnvironmentType.Value.UNSET, syncOperationDetails.getEnvironmentType());
Assert.assertEquals("version-1234", syncOperationDetails.getApplicationVersion());
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.
the class StructuredEventToCDPStatusDetailsConverterTest method testConversionWithEmptyStructuredEvent.
@Test
public void testConversionWithEmptyStructuredEvent() {
StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
UsageProto.CDPStatusDetails flowStatusDetails = underTest.convert(structuredFlowEvent);
Assert.assertEquals("", flowStatusDetails.getStackStatus());
Assert.assertEquals("", flowStatusDetails.getStackDetailedStatus());
Assert.assertEquals("", flowStatusDetails.getStackStatusReason());
Assert.assertEquals("", flowStatusDetails.getClusterStatus());
Assert.assertEquals("", flowStatusDetails.getClusterStatusReason());
StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
UsageProto.CDPStatusDetails syncStatusDetails = underTest.convert(structuredSyncEvent);
Assert.assertEquals("", syncStatusDetails.getStackStatus());
Assert.assertEquals("", syncStatusDetails.getStackDetailedStatus());
Assert.assertEquals("", syncStatusDetails.getStackStatusReason());
Assert.assertEquals("", syncStatusDetails.getClusterStatus());
Assert.assertEquals("", syncStatusDetails.getClusterStatusReason());
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.
the class StructuredEventToCDPVersionDetailsConverterTest method testConversionFileldOutValues.
@Test
public void testConversionFileldOutValues() {
StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
structuredFlowEvent.setStack(createStackDetails());
UsageProto.CDPVersionDetails flowVersionDetails = underTest.convert(structuredFlowEvent);
Assert.assertEquals("7.3.0-11", flowVersionDetails.getCmVersion());
Assert.assertEquals("7.2.7-22", flowVersionDetails.getCdpdVersion());
Assert.assertEquals("7.2.7", flowVersionDetails.getCrVersion());
Assert.assertEquals("2021-02-04", flowVersionDetails.getOsPatchLevel());
Assert.assertEquals("3000.5", flowVersionDetails.getSaltVersion());
Assert.assertEquals("bootstrap=something, cdh-build-number=22, cm-build-number=11, cm=7.3.0, date=2021-02-04," + " salt=3000.5, stack=7.2.7", flowVersionDetails.getAll());
StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
structuredSyncEvent.setStack(createStackDetails());
UsageProto.CDPVersionDetails syncVersionDetails = underTest.convert(structuredSyncEvent);
Assert.assertEquals("7.3.0-11", syncVersionDetails.getCmVersion());
Assert.assertEquals("7.2.7-22", syncVersionDetails.getCdpdVersion());
Assert.assertEquals("7.2.7", syncVersionDetails.getCrVersion());
Assert.assertEquals("2021-02-04", syncVersionDetails.getOsPatchLevel());
Assert.assertEquals("3000.5", syncVersionDetails.getSaltVersion());
Assert.assertEquals("bootstrap=something, cdh-build-number=22, cm-build-number=11, cm=7.3.0, date=2021-02-04," + " salt=3000.5, stack=7.2.7", syncVersionDetails.getAll());
}
Aggregations