use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto in project open-smart-grid-platform by OSGP.
the class DataObjectToEventListConverterTest method testEventsWithCodeTimeStampAndCounter.
@Test
void testEventsWithCodeTimeStampAndCounter() throws ProtocolAdapterException {
// GIVEN
final DateTime dateTime1 = new DateTime(2021, 9, 16, 10, 35, 10, DateTimeZone.UTC);
final DateTime dateTime2 = new DateTime(2021, 9, 17, 11, 22, 45, DateTimeZone.UTC);
final DataObject eventDataObject1 = this.createEventDataObject(dateTime1, 1, 11);
final DataObject eventDataObject2 = this.createEventDataObject(dateTime2, 2, 12);
final DataObject source = DataObject.newArrayData(Arrays.asList(eventDataObject1, eventDataObject2));
final EventDto expectedEvent1 = new EventDto(dateTime1, 1, 11, EventLogCategoryDto.COMMUNICATION_SESSION_LOG.name());
final EventDto expectedEvent2 = new EventDto(dateTime2, 2, 12, EventLogCategoryDto.COMMUNICATION_SESSION_LOG.name());
// WHEN
final List<EventDto> events = this.converter.convert(source, EventLogCategoryDto.COMMUNICATION_SESSION_LOG);
// THEN
assertThat(events).usingRecursiveFieldByFieldElementComparator().containsExactly(expectedEvent1, expectedEvent2);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto in project open-smart-grid-platform by OSGP.
the class DataObjectToEventListConverterTest method testEventsWithCodeAndTimeStamp.
@Test
void testEventsWithCodeAndTimeStamp() throws ProtocolAdapterException {
// GIVEN
final DateTime dateTime1 = new DateTime(2021, 9, 16, 10, 35, 10, DateTimeZone.UTC);
final DateTime dateTime2 = new DateTime(2021, 9, 17, 11, 22, 45, DateTimeZone.UTC);
final DataObject eventDataObject1 = this.createEventDataObject(dateTime1, 1);
final DataObject eventDataObject2 = this.createEventDataObject(dateTime2, 2);
final DataObject source = DataObject.newArrayData(Arrays.asList(eventDataObject1, eventDataObject2));
final EventDto expectedEvent1 = new EventDto(dateTime1, 1, null, EventLogCategoryDto.STANDARD_EVENT_LOG.name());
final EventDto expectedEvent2 = new EventDto(dateTime2, 2, null, EventLogCategoryDto.STANDARD_EVENT_LOG.name());
// WHEN
final List<EventDto> events = this.converter.convert(source, EventLogCategoryDto.STANDARD_EVENT_LOG);
// THEN
assertThat(events).usingRecursiveFieldByFieldElementComparator().containsExactly(expectedEvent1, expectedEvent2);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto in project open-smart-grid-platform by OSGP.
the class DataObjectToEventListConverterTest method testEventsWithEventDetails.
@Test
void testEventsWithEventDetails() throws ProtocolAdapterException {
// GIVEN
final DateTime dateTime1 = new DateTime(2021, 9, 16, 10, 35, 10, DateTimeZone.UTC);
final DateTime dateTime2 = new DateTime(2021, 9, 17, 11, 22, 45, DateTimeZone.UTC);
final DataObject eventDataObject1 = this.createEventDataObject(dateTime1, 1, 11, 21);
final DataObject eventDataObject2 = this.createEventDataObject(dateTime2, 2, 12, 22);
final String MAGNITUDE = "magnitude";
final String DURATION = "duration";
final DataObject source = DataObject.newArrayData(Arrays.asList(eventDataObject1, eventDataObject2));
final EventDto expectedEvent1 = new EventDto(dateTime1, 1, null, EventLogCategoryDto.POWER_QUALITY_EXTENDED_EVENT_LOG.name());
expectedEvent1.addEventDetail(new EventDetailDto(MAGNITUDE, "1.1 V"));
expectedEvent1.addEventDetail(new EventDetailDto(DURATION, "2.1 s"));
final EventDto expectedEvent2 = new EventDto(dateTime2, 2, null, EventLogCategoryDto.POWER_QUALITY_EXTENDED_EVENT_LOG.name());
expectedEvent2.addEventDetail(new EventDetailDto(MAGNITUDE, "1.2 V"));
expectedEvent2.addEventDetail(new EventDetailDto(DURATION, "2.2 s"));
// WHEN
final List<EventDto> events = this.converter.convert(source, EventLogCategoryDto.POWER_QUALITY_EXTENDED_EVENT_LOG);
// THEN
assertThat(events).usingRecursiveFieldByFieldElementComparator().containsExactly(expectedEvent1, expectedEvent2);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto in project open-smart-grid-platform by OSGP.
the class EventMessageDataContainerMappingTest method testWithEmptyList.
// Test if mapping with an empty list succeeds
@Test
public void testWithEmptyList() {
// build test data
final EventMessageDataResponseDto containerDto = new EventMessageDataResponseDto(new ArrayList<EventDto>());
// actual mapping
final EventMessagesResponse container = this.managementMapper.map(containerDto, EventMessagesResponse.class);
// test mapping
assertThat(container).isNotNull();
assertThat(container.getEvents()).isNotNull();
assertThat(container.getEvents()).isEmpty();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto in project open-smart-grid-platform by OSGP.
the class EventMessageDataContainerMappingTest method testWithFilledList.
// Test if mapping with a filled List succeeds
@Test
public void testWithFilledList() {
// build test data
final EventDto event = new EventDto(new DateTime(), new Integer(1), new Integer(2), "STANDARD_EVENT_LOG");
event.setEventTypeDto(EventTypeDto.POWER_FAILURE);
final ArrayList<EventDto> events = new ArrayList<>();
events.add(event);
final EventMessageDataResponseDto containerDto = new EventMessageDataResponseDto(events);
// actual mapping
final EventMessagesResponse container = this.managementMapper.map(containerDto, EventMessagesResponse.class);
// test mapping
assertThat(container).isNotNull();
assertThat(container.getEvents()).isNotNull();
assertThat(container.getEvents().get(0).getTimestamp()).isEqualTo(containerDto.getEvents().get(0).getTimestamp());
assertThat(container.getEvents().get(0).getEventCode()).isEqualTo(containerDto.getEvents().get(0).getEventCode());
assertThat(container.getEvents().get(0).getEventType().name()).isEqualTo(containerDto.getEvents().get(0).getEventTypeDto().name());
assertThat(container.getEvents().get(0).getEventCounter()).isEqualTo(containerDto.getEvents().get(0).getEventCounter());
}
Aggregations