use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectCommandExecutorDsmr4IT method captureSetParameterStructureData.
private List<DataObject> captureSetParameterStructureData() throws IOException {
verify(this.dlmsConnection).set(this.setParameterArgumentCaptor.capture());
final SetParameter setParameter = this.setParameterArgumentCaptor.getValue();
final DataObject setParameterData = setParameter.getData();
return setParameterData.getValue();
}
use of org.openmuc.jdlms.datatypes.DataObject 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.openmuc.jdlms.datatypes.DataObject 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.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class DataObjectToEventListConverterTest method testWrongEventElementListSize.
@Test
void testWrongEventElementListSize() {
final DataObject source = DataObject.newArrayData(Collections.singletonList(DataObject.newArrayData(Collections.singletonList(this.getDataObject(1)))));
final Throwable thrown = catchThrowable(() -> this.converter.convert(source, EventLogCategoryDto.STANDARD_EVENT_LOG));
assertThat(thrown).isInstanceOf(ProtocolAdapterException.class).hasMessage("eventData size should be 2");
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class DlmsHelper method readSendDestinationAndMethod.
public SendDestinationAndMethodDto readSendDestinationAndMethod(final DataObject resultData, final String description) throws ProtocolAdapterException {
final List<DataObject> sendDestinationAndMethodElements = this.readList(resultData, description);
if (sendDestinationAndMethodElements == null) {
return null;
}
final TransportServiceTypeDto transportService = this.readTransportServiceType(sendDestinationAndMethodElements.get(0), "Transport Service from " + description);
final String destination = this.readString(sendDestinationAndMethodElements.get(1), "Destination from " + description);
final MessageTypeDto message = this.readMessageType(sendDestinationAndMethodElements.get(2), "Message from " + description);
return new SendDestinationAndMethodDto(transportService, destination, message);
}
Aggregations