Search in sources :

Example 11 with CDPOperationDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails in project cloudbreak by hortonworks.

the class SdxEventsServiceTests method createCDPStructuredNotificationEvent.

private CDPStructuredEvent createCDPStructuredNotificationEvent(Long timestamp) {
    CDPOperationDetails operationDetails = new CDPOperationDetails();
    operationDetails.setResourceCrn("someCrn");
    operationDetails.setResourceType("datalake");
    operationDetails.setTimestamp(timestamp);
    operationDetails.setEventType(StructuredEventType.NOTIFICATION);
    CDPStructuredNotificationEvent cdpStructuredEvent = new CDPStructuredNotificationEvent() {

        @Override
        public String getStatus() {
            return SENT;
        }

        @Override
        public Long getDuration() {
            return 1L;
        }
    };
    cdpStructuredEvent.setOperation(operationDetails);
    return cdpStructuredEvent;
}
Also used : CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Example 12 with CDPOperationDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails in project cloudbreak by hortonworks.

the class SdxEventControllerTest method createCDPStructuredFlowEvent.

private CDPStructuredEvent createCDPStructuredFlowEvent(Long timestamp) {
    CDPOperationDetails operationDetails = new CDPOperationDetails();
    operationDetails.setResourceCrn("someCrn");
    operationDetails.setResourceType("datalake");
    operationDetails.setTimestamp(timestamp);
    operationDetails.setEventType(StructuredEventType.FLOW);
    CDPStructuredFlowEvent cdpStructuredEvent = new CDPStructuredFlowEvent() {

        @Override
        public String getStatus() {
            return SENT;
        }

        @Override
        public Long getDuration() {
            return 1L;
        }
    };
    cdpStructuredEvent.setOperation(operationDetails);
    return cdpStructuredEvent;
}
Also used : CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 13 with CDPOperationDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails in project cloudbreak by hortonworks.

the class CDPStructuredEventEntityToCDPStructuredEventConverterTest method testConvertWhenSuccess.

@Test
public void testConvertWhenSuccess() {
    CDPOperationDetails operationDetails = new CDPOperationDetails();
    operationDetails.setAccountId("accountId");
    FlowDetails flowDetails = new FlowDetails();
    Serializable payload = "payload";
    CDPStructuredEvent event = new CDPStructuredFlowEvent(operationDetails, flowDetails, payload, null, null);
    CDPStructuredEventEntity eventEntity = new CDPStructuredEventEntity();
    eventEntity.setEventType(StructuredEventType.FLOW);
    eventEntity.setStructuredEventJson(new Json(event));
    CDPStructuredFlowEvent<String> actual = (CDPStructuredFlowEvent<String>) underTest.convert(eventEntity);
    Assertions.assertEquals("accountId", operationDetails.getAccountId());
    Assertions.assertEquals("payload", actual.getPayload());
}
Also used : Serializable(java.io.Serializable) CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails) CDPStructuredEventEntity(com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity) CDPStructuredEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent) Json(com.sequenceiq.cloudbreak.common.json.Json) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) Test(org.junit.jupiter.api.Test)

Example 14 with CDPOperationDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails in project cloudbreak by hortonworks.

the class CDPStructuredEventDBServiceTest method testCreateWhenResourceCrnIsNotEmpty.

@Test
public void testCreateWhenResourceCrnIsNotEmpty() {
    CDPStructuredEvent event = new CDPStructuredRestCallEvent();
    CDPOperationDetails operation = new CDPOperationDetails();
    operation.setResourceCrn("crn:cdp:cloudbreak:us-west-1:someone:stack:12345");
    event.setOperation(operation);
    CDPStructuredEventEntity entity = new CDPStructuredEventEntity();
    when(cdpStructuredEventToCDPStructuredEventEntityConverter.convert(event)).thenReturn(entity);
    underTest.create(event);
    verify(cdpStructuredEventToCDPStructuredEventEntityConverter, Mockito.times(1)).convert(event);
    verify(structuredEventRepository, Mockito.times(1)).save(entity);
}
Also used : CDPStructuredRestCallEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredRestCallEvent) CDPStructuredEventEntity(com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity) CDPStructuredEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) Test(org.junit.jupiter.api.Test)

Example 15 with CDPOperationDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails in project cloudbreak by hortonworks.

the class CDPFreeIpaStructuredFlowEventToCDPFreeIpaStatusChangedConverterTest method testConvertingNotEmptyStructuredFlowEvent.

@Test
public void testConvertingNotEmptyStructuredFlowEvent() {
    CDPFreeIpaStructuredFlowEvent cdpStructuredFlowEvent = new CDPFreeIpaStructuredFlowEvent();
    CDPOperationDetails operationDetails = new CDPOperationDetails();
    operationDetails.setEnvironmentCrn("testcrn");
    cdpStructuredFlowEvent.setOperation(operationDetails);
    UsageProto.CDPFreeIPAStatusChanged cdpFreeIPAStatusChanged = underTest.convert(cdpStructuredFlowEvent, UsageProto.CDPFreeIPAStatus.Value.UPSCALE_STARTED);
    Assertions.assertEquals(UsageProto.CDPFreeIPAStatus.Value.UPSCALE_STARTED, cdpFreeIPAStatusChanged.getNewStatus());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getOperationDetails());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getFreeIPADetails());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getStatusDetails());
    Assertions.assertEquals("testcrn", cdpFreeIPAStatusChanged.getEnvironmentCrn());
}
Also used : CDPFreeIpaStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Aggregations

CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)31 Test (org.junit.jupiter.api.Test)8 CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)7 CDPStructuredNotificationEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)6 CDPStructuredEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent)5 FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)4 CDPStructuredRestCallEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredRestCallEvent)4 Json (com.sequenceiq.cloudbreak.common.json.Json)3 CDPStructuredEventEntity (com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity)3 CDPStructuredNotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationDetails)3 CDPEnvironmentStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent)3 EnvironmentDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails)3 RestCallDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestCallDetails)3 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)2 CDPFreeIpaStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent)2 RestRequestDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails)2 RestResponseDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestResponseDetails)2 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)2 Environment (com.sequenceiq.environment.environment.domain.Environment)2