use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DeviceConverterTest method convertsSmartMeteringDtoToDlmsDevice.
@Test
public void convertsSmartMeteringDtoToDlmsDevice() {
final SmartMeteringDeviceDto dto = new SmartMeteringDeviceDtoBuilder().build();
final DlmsDevice result = this.converter.convertTo(dto, null, null);
final DlmsDevice expected = this.converted(dto);
Assertions.assertThat(result).isEqualToIgnoringGivenFields(expected, "creationTime", "modificationTime", "version");
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessor method processMessageTasks.
@SuppressWarnings(// SilentException cannot be caught since it does not extend Exception.
"squid:S1193")
void processMessageTasks(final Serializable messageObject, final MessageMetadata messageMetadata, final DlmsConnectionManager conn) throws OsgpException {
try {
final DlmsDevice device = this.domainHelperService.findDlmsDevice(messageMetadata);
LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification());
final Serializable response;
response = this.handleMessage(conn, device, messageObject);
// Send response
this.sendResponseMessage(messageMetadata, ResponseMessageResultType.OK, null, this.responseMessageSender, response);
} catch (final Exception exception) {
// Return original request + exception
if (!(exception instanceof SilentException)) {
LOGGER.error("Unexpected exception during {}", this.messageType.name(), exception);
}
this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, exception, this.responseMessageSender, this.createUpdateFirmwareRequestDto(messageObject));
} finally {
final DlmsDevice device = this.domainHelperService.findDlmsDevice(messageMetadata);
this.doConnectionPostProcessing(device, conn, messageMetadata);
}
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class BundleServiceTest method shouldHandleActionsWithoutPreviousResult.
@Test
public void shouldHandleActionsWithoutPreviousResult() {
final BundleMessagesRequestDto bundleMessagesRequest = new BundleMessagesRequestDto(Arrays.asList(this.createAction(this.builder.makePeriodicMeterReadsRequestDataDto(), null)));
final BundleMessagesRequestDto result = this.bundleService.callExecutors(null, new DlmsDevice(), bundleMessagesRequest, this.messageMetadata);
verify(this.bundleCommandExecutorMap).getCommandExecutor(PeriodicMeterReadsRequestDataDto.class);
assertThat(result.getAllResponses().size()).isOne();
assertThat(result.getAllResponses().get(0)).isNotNull();
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method getDeviceIpAddressFromSessionProviderReturnsAddressFromProviderIfDeviceIsInSession.
@Test
void getDeviceIpAddressFromSessionProviderReturnsAddressFromProviderIfDeviceIsInSession() throws Exception {
final String communicationProvider = "comm-prov";
final String iccId = "icc-id";
final String ipAddress = IP_ADDRESS;
this.whenSessionProviderReturnsIpAddress(communicationProvider, iccId, ipAddress);
final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withCommunicationProvider(communicationProvider).setIccId(iccId).build();
final String actualIpAddress = this.domainHelperService.getDeviceIpAddressFromSessionProvider(dlmsDevice);
assertThat(actualIpAddress).isEqualTo(ipAddress);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method getDeviceIpAddressFromSessionProviderReturnsIpAddressOnlyAfterWakeUp.
@Test
void getDeviceIpAddressFromSessionProviderReturnsIpAddressOnlyAfterWakeUp() throws Exception {
final String communicationProvider = "comm-prov";
final String iccId = "icc-id";
final String ipAddress = IP_ADDRESS;
this.whenSessionProviderReturnsIpAddressAfterWakeUp(communicationProvider, iccId, ipAddress);
final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withCommunicationProvider(communicationProvider).setIccId(iccId).build();
final String actualIpAddress = this.domainHelperService.getDeviceIpAddressFromSessionProvider(dlmsDevice);
assertThat(actualIpAddress).isEqualTo(ipAddress);
verify(this.jasperWirelessSmsClient).sendWakeUpSMS(iccId);
}
Aggregations