use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class ClearMBusStatusOnAllChannelsCommandExecutorTest method testExecuteObjectNotFound.
@Test
void testExecuteObjectNotFound() throws ProtocolAdapterException {
when(this.dlmsObjectConfigService.getAttributeAddress(any(), any(), any())).thenThrow(new ProtocolAdapterException("Object not found"));
final DlmsDevice dlmsDevice = new DlmsDevice();
dlmsDevice.setProtocol("SMR", "5.0.0");
assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> {
this.executor.execute(this.connectionManager, dlmsDevice, this.dto, this.messageMetadata);
});
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DeviceConverterTest method converted.
private DlmsDevice converted(final SmartMeteringDeviceDto dto) {
final DlmsDevice dlmsDevice = new DlmsDevice();
dlmsDevice.setDeviceIdentification(dto.getDeviceIdentification());
dlmsDevice.setCommunicationMethod(dto.getCommunicationMethod());
dlmsDevice.setCommunicationProvider(dto.getCommunicationProvider());
dlmsDevice.setIccId(dto.getIccId());
dlmsDevice.setHls3Active(dto.isHls3Active());
dlmsDevice.setHls4Active(dto.isHls4Active());
dlmsDevice.setHls5Active(dto.isHls5Active());
dlmsDevice.setMbusIdentificationNumber(dto.getMbusIdentificationNumber());
dlmsDevice.setMbusManufacturerIdentification(dto.getMbusManufacturerIdentification());
dlmsDevice.setProtocol(dto.getProtocolName(), dto.getProtocolVersion());
return dlmsDevice;
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DeviceKeyProcessingServiceTest method testKeyProcessRunning.
@Test
public void testKeyProcessRunning() throws DeviceKeyProcessAlreadyRunningException {
final DlmsDevice dlmsDevice = new DlmsDevice();
dlmsDevice.setDeviceIdentification(DEVICE_IDENTIFICATION);
dlmsDevice.setKeyProcessingStartTime(Instant.now());
when(this.dlmsDeviceRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(dlmsDevice);
when(this.dlmsDeviceRepository.setProcessingStartTime(eq(DEVICE_IDENTIFICATION), any(Instant.class))).thenReturn(0);
assertThrows(DeviceKeyProcessAlreadyRunningException.class, () -> {
this.deviceKeyProcessingService.startProcessing(DEVICE_IDENTIFICATION);
});
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DeviceKeyProcessingServiceTest method testPreviousKeyProcessTimedOut.
@Test
public void testPreviousKeyProcessTimedOut() {
final DlmsDevice dlmsDevice = new DlmsDevice();
dlmsDevice.setDeviceIdentification(DEVICE_IDENTIFICATION);
dlmsDevice.setKeyProcessingStartTime(Instant.now().minus(this.deviceKeyProcessingService.getDeviceKeyProcessingTimeout()));
when(this.dlmsDeviceRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(dlmsDevice);
when(this.dlmsDeviceRepository.setProcessingStartTime(eq(DEVICE_IDENTIFICATION), any(Instant.class))).thenReturn(1);
assertDoesNotThrow(() -> this.deviceKeyProcessingService.startProcessing(DEVICE_IDENTIFICATION));
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice 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());
}
Aggregations