Search in sources :

Example 6 with SmartMeteringDeviceDto

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());
}
Also used : SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Test(org.junit.jupiter.api.Test)

Example 7 with SmartMeteringDeviceDto

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());
}
Also used : SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Test(org.junit.jupiter.api.Test)

Example 8 with SmartMeteringDeviceDto

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));
}
Also used : SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Test(org.junit.jupiter.api.Test)

Example 9 with SmartMeteringDeviceDto

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;
}
Also used : SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto)

Aggregations

SmartMeteringDeviceDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto)9 Test (org.junit.jupiter.api.Test)7 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)3 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)3 SmartMeteringDevice (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice)2 Date (java.util.Date)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 SmartMeteringDeviceDtoBuilder (org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDtoBuilder)1