Search in sources :

Example 21 with Iec60870Device

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));
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device) ResponseMetadata(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata) Test(org.junit.jupiter.api.Test)

Example 22 with Iec60870Device

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);
}
Also used : Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device) RequestMetadata(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.RequestMetadata) ConnectionEventListener(org.openmuc.j60870.ConnectionEventListener) Test(org.junit.jupiter.api.Test)

Aggregations

Iec60870Device (org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device)21 Test (org.junit.jupiter.api.Test)6 RequestMetadata (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.RequestMetadata)4 ResponseMetadata (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata)4 ConnectionEventListener (org.openmuc.j60870.ConnectionEventListener)3 ClientConnectionAlreadyInCacheException (org.opensmartgridplatform.adapter.protocol.iec60870.domain.exceptions.ClientConnectionAlreadyInCacheException)2 ConnectionParameters (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ConnectionParameters)2 DomainInfo (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DomainInfo)2 MeasurementReportDto (org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 Given (io.cucumber.java.en.Given)1 When (io.cucumber.java.en.When)1 ClientConnectionEventListener (org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnectionEventListener)1 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection)1 DeviceType (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceType)1 LightSensorStatusDto (org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto)1 ConnectionFailureException (org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException)1