use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device in project open-smart-grid-platform by OSGP.
the class LightMeasurementDeviceResponseServiceTest method sendLightSensorStatusResponseShouldDequeueCorrelationUid.
@Test
void sendLightSensorStatusResponseShouldDequeueCorrelationUid() {
final MeasurementReportDto measurementReportDto = MeasurementReportFactory.getMeasurementReportDto();
final ResponseMetadata responseMetadata = new ResponseMetadata.Builder().withCorrelationUid(CORRELATION_UID).withDeviceIdentification(Iec60870DeviceFactory.LMD_1_DEVICE_IDENTIFICATION).withOrganisationIdentification(ORGANISATION_IDENTIFICATION).build();
final Iec60870Device lightMeasurementDevice1 = Iec60870DeviceFactory.getLightMeasurementDevice1();
final Iec60870Device lightMeasurementDevice2 = Iec60870DeviceFactory.getLightMeasurementDevice2();
when(this.iec60870DeviceRepository.findByGatewayDeviceIdentification(Iec60870DeviceFactory.GATEWAY_DEVICE_IDENTIFICATION)).thenReturn(Arrays.asList(lightMeasurementDevice1, lightMeasurementDevice2));
this.lightMeasurementDeviceResponseService.sendLightSensorStatusResponse(measurementReportDto, lightMeasurementDevice1, responseMetadata, "");
verify(this.pendingRequestsQueue).dequeue(eq(Iec60870DeviceFactory.LMD_1_DEVICE_IDENTIFICATION));
}
use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device in project open-smart-grid-platform by OSGP.
the class ClientConnectionServiceTest method testGetConnectionShouldReturnNewConnectionWhenNotInCache.
@Test
void testGetConnectionShouldReturnNewConnectionWhenNotInCache() throws Exception {
// Arrange
final String deviceIdentification = "DA_DVC_1";
final Iec60870Device device = Iec60870DeviceFactory.createDistributionAutomationDevice(deviceIdentification);
when(this.iec60870DeviceRepository.findByDeviceIdentification(deviceIdentification)).thenReturn(Optional.of(device));
final RequestMetadata requestMetadata = RequestMetadataFactory.forDevice(deviceIdentification);
final ClientConnection expectedConnection = ClientConnectionFactory.forDevice(deviceIdentification);
when(this.iec60870Client.connect(eq(expectedConnection.getConnectionParameters()), any(ConnectionEventListener.class))).thenReturn(expectedConnection);
// Act
final ClientConnection actualConnection = this.clientConnectionService.getConnection(requestMetadata);
// Assert
assertThat(actualConnection).isEqualTo(expectedConnection);
}
Aggregations