use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto in project open-smart-grid-platform by OSGP.
the class InstallationServiceTest method addMeterNoKeys.
@Test
void addMeterNoKeys() {
// GIVEN
final SmartMeteringDeviceDto deviceDto = new SmartMeteringDeviceDto();
deviceDto.setDeviceIdentification(this.deviceIdentification);
// WHEN
Assertions.assertThatExceptionOfType(FunctionalException.class).isThrownBy(() -> this.testService.addMeter(this.messageMetadata, deviceDto));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto 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.dto.valueobjects.smartmetering.SmartMeteringDeviceDto in project open-smart-grid-platform by OSGP.
the class InstallationMapperTest method testSmartMeteringDeviceToSmartMeteringDeviceDtoMapping.
@Test
public void testSmartMeteringDeviceToSmartMeteringDeviceDtoMapping() {
final SmartMeteringDevice smartMeteringDevice = new SmartMeteringDevice();
smartMeteringDevice.setDeviceIdentification("device1");
smartMeteringDevice.setDeviceType("typeA");
smartMeteringDevice.setCommunicationMethod("skype");
smartMeteringDevice.setCommunicationProvider("theInternet");
smartMeteringDevice.setIccId("value");
smartMeteringDevice.setProtocolName("protocolName");
smartMeteringDevice.setProtocolVersion("latestVersion");
smartMeteringDevice.setMasterKey("masterKey".getBytes());
smartMeteringDevice.setGlobalEncryptionUnicastKey("globalEncryptionUnicastKey".getBytes());
smartMeteringDevice.setAuthenticationKey("authenticationKey".getBytes());
smartMeteringDevice.setSupplier("supplier");
smartMeteringDevice.setHls3Active(true);
smartMeteringDevice.setHls4Active(true);
smartMeteringDevice.setHls5Active(true);
smartMeteringDevice.setDeliveryDate(new Date());
smartMeteringDevice.setMbusIdentificationNumber("12345678");
smartMeteringDevice.setMbusManufacturerIdentification("XYZ");
smartMeteringDevice.setMbusVersion((short) 112);
smartMeteringDevice.setMbusDeviceTypeIdentification((short) 3);
smartMeteringDevice.setMbusDefaultKey("mbusDefaultKey".getBytes());
final SmartMeteringDeviceDto smartMeteringDeviceDto = this.mapperFactory.getMapperFacade().map(smartMeteringDevice, SmartMeteringDeviceDto.class);
assertThat(smartMeteringDevice).isNotNull();
assertThat(smartMeteringDeviceDto).isNotNull();
assertThat(smartMeteringDeviceDto).isEqualToIgnoringGivenFields(smartMeteringDevice, "hls3Active", "hls4Active", "hls5Active");
assertThat(smartMeteringDeviceDto.isHls3Active()).isEqualTo(smartMeteringDevice.isHls3Active());
assertThat(smartMeteringDeviceDto.isHls4Active()).isEqualTo(smartMeteringDevice.isHls4Active());
assertThat(smartMeteringDeviceDto.isHls5Active()).isEqualTo(smartMeteringDevice.isHls5Active());
assertThat(smartMeteringDeviceDto).isNotNull().isEqualToIgnoringGivenFields(smartMeteringDevice, "ipAddress", "btsId", "cellId");
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto in project open-smart-grid-platform by OSGP.
the class InstallationService method addMeter.
public void addMeter(final MessageMetadata messageMetadata, final AddSmartMeterRequest addSmartMeterRequest) throws FunctionalException {
final String organisationId = messageMetadata.getOrganisationIdentification();
final String deviceId = messageMetadata.getDeviceIdentification();
LOGGER.debug("addMeter for organisationIdentification: {} for deviceIdentification: {}", organisationId, deviceId);
final SmartMeteringDevice smartMeteringDevice = addSmartMeterRequest.getDevice();
final String deviceIdentification = messageMetadata.getDeviceIdentification();
this.smartMeterService.validateSmartMeterDoesNotExist(deviceIdentification);
final SmartMeter smartMeter = this.smartMeterService.convertSmartMeter(smartMeteringDevice);
this.smartMeterService.storeMeter(organisationId, addSmartMeterRequest, smartMeter);
final SmartMeteringDeviceDto requestDto = this.mapperFactory.getMapperFacade().map(smartMeteringDevice, SmartMeteringDeviceDto.class);
this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto in project open-smart-grid-platform by OSGP.
the class InstallationServiceTest method addMeterNoDeviceIdentification.
@Test
void addMeterNoDeviceIdentification() {
// GIVEN
final SmartMeteringDeviceDto deviceDto = new SmartMeteringDeviceDto();
deviceDto.setMbusDefaultKey(new byte[16]);
// WHEN
Assertions.assertThatExceptionOfType(FunctionalException.class).isThrownBy(() -> this.testService.addMeter(this.messageMetadata, deviceDto));
}
Aggregations