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