use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto in project open-smart-grid-platform by OSGP.
the class InstallationServiceTest method addGMeter.
@Test
void addGMeter() throws FunctionalException {
// GIVEN
final SmartMeteringDeviceDto deviceDto = new SmartMeteringDeviceDto();
deviceDto.setDeviceIdentification(this.deviceIdentification);
deviceDto.setMasterKey(new byte[0]);
deviceDto.setAuthenticationKey(new byte[0]);
deviceDto.setGlobalEncryptionUnicastKey(new byte[0]);
deviceDto.setMbusDefaultKey(new byte[16]);
final DlmsDevice dlmsDevice = new DlmsDevice();
when(this.installationMapper.map(deviceDto, DlmsDevice.class)).thenReturn(dlmsDevice);
when(this.dlmsDeviceRepository.save(dlmsDevice)).thenReturn(dlmsDevice);
when(this.rsaEncrypter.decrypt(any())).thenReturn(new byte[16]);
// WHEN
this.testService.addMeter(this.messageMetadata, deviceDto);
// THEN
verify(this.secretManagementService, times(1)).storeNewKeys(eq(this.messageMetadata), eq(this.deviceIdentification), any());
verify(this.secretManagementService, times(1)).activateNewKeys(eq(this.messageMetadata), eq(this.deviceIdentification), any());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto in project open-smart-grid-platform by OSGP.
the class InstallationServiceTest method addEMeter.
@Test
void addEMeter() throws FunctionalException {
// GIVEN
final SmartMeteringDeviceDto deviceDto = new SmartMeteringDeviceDto();
deviceDto.setDeviceIdentification(this.deviceIdentification);
deviceDto.setMasterKey(new byte[16]);
deviceDto.setAuthenticationKey(new byte[16]);
deviceDto.setGlobalEncryptionUnicastKey(new byte[16]);
deviceDto.setMbusDefaultKey(new byte[0]);
final DlmsDevice dlmsDevice = new DlmsDevice();
when(this.installationMapper.map(deviceDto, DlmsDevice.class)).thenReturn(dlmsDevice);
when(this.dlmsDeviceRepository.save(dlmsDevice)).thenReturn(dlmsDevice);
when(this.rsaEncrypter.decrypt(any())).thenReturn(new byte[16]);
// WHEN
this.testService.addMeter(this.messageMetadata, deviceDto);
// THEN
verify(this.secretManagementService, times(1)).storeNewKeys(eq(this.messageMetadata), eq(this.deviceIdentification), any());
verify(this.secretManagementService, times(1)).activateNewKeys(eq(this.messageMetadata), eq(this.deviceIdentification), any());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto in project open-smart-grid-platform by OSGP.
the class InstallationServiceTest method addMeterRedundantKeys.
@Test
void addMeterRedundantKeys() {
// GIVEN
final SmartMeteringDeviceDto deviceDto = new SmartMeteringDeviceDto();
deviceDto.setDeviceIdentification(this.deviceIdentification);
deviceDto.setMasterKey(new byte[16]);
deviceDto.setAuthenticationKey(new byte[16]);
deviceDto.setGlobalEncryptionUnicastKey(new byte[16]);
deviceDto.setMbusDefaultKey(new byte[16]);
// 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 AddMeterRequestMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
this.assertRequestObjectType(SmartMeteringDeviceDto.class, requestObject);
final SmartMeteringDeviceDto smartMeteringDevice = (SmartMeteringDeviceDto) requestObject;
this.installationService.addMeter(messageMetadata, smartMeteringDevice);
// No return object.
return null;
}
Aggregations