Search in sources :

Example 1 with Iec60870InterrogationCommandAsduHandler

use of org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler in project open-smart-grid-platform by OSGP.

the class ScenarioHooks method initMockServerLightMeasurement.

@Before("@Iec60870MockServerLightMeasurement")
public void initMockServerLightMeasurement() {
    ScenarioContext.current().put(PROFILE, Iec60870ProfileType.LIGHT_MEASUREMENT_DEVICE);
    final Iec60870AsduFactory factory = new LightMeasurementDeviceAsduFactory("UTC");
    factory.setIec60870Server(this.mockServer.getRtuSimulator());
    this.mockServer.addIec60870ASduHandler(ASduType.C_IC_NA_1, new Iec60870InterrogationCommandAsduHandler(factory));
}
Also used : Iec60870AsduFactory(org.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduFactory) Iec60870InterrogationCommandAsduHandler(org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler) LightMeasurementDeviceAsduFactory(org.opensmartgridplatform.simulator.protocol.iec60870.domain.lightmeasurementdevice.LightMeasurementDeviceAsduFactory) Before(io.cucumber.java.Before)

Example 2 with Iec60870InterrogationCommandAsduHandler

use of org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler in project open-smart-grid-platform by OSGP.

the class Iec60870InterrogationCommandAsduHandlerTest method testSendingOrder.

@Test
void testSendingOrder() throws IOException {
    // Arrange
    doNothing().when(this.connection).sendConfirmation(any(ASdu.class));
    final ASdu responseAsdu = this.getAsdu(ASduType.M_SP_NA_1, CauseOfTransmission.INTERROGATED_BY_STATION);
    when(this.iec60870AsduFactory.createInterrogationCommandResponseAsdu()).thenReturn(responseAsdu);
    final ASdu terminationAsdu = this.getAsdu(ASduType.C_IC_NA_1, CauseOfTransmission.ACTIVATION_TERMINATION);
    when(this.iec60870AsduFactory.createActivationTerminationResponseAsdu()).thenReturn(terminationAsdu);
    doNothing().when(this.connection).send(any(ASdu.class));
    final InOrder inOrder = inOrder(this.connection);
    // Act
    final Iec60870InterrogationCommandAsduHandler interrogationCommandHandler = new Iec60870InterrogationCommandAsduHandler(this.iec60870AsduFactory);
    interrogationCommandHandler.handleAsdu(this.connection, responseAsdu);
    // Assert
    inOrder.verify(this.connection).sendConfirmation(any(ASdu.class));
    inOrder.verify(this.connection).send(argThat(new AsduTypeArgumentMatcher(ASduType.M_SP_NA_1)));
    inOrder.verify(this.connection).send(argThat(new AsduTypeArgumentMatcher(ASduType.C_IC_NA_1, CauseOfTransmission.ACTIVATION_TERMINATION)));
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) AsduTypeArgumentMatcher(org.opensmartgridplatform.simulator.protocol.iec60870.server.AsduTypeArgumentMatcher) ASdu(org.openmuc.j60870.ASdu) Test(org.junit.jupiter.api.Test)

Example 3 with Iec60870InterrogationCommandAsduHandler

use of org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler in project open-smart-grid-platform by OSGP.

the class ScenarioHooks method initMockServerDefaultControlledStation.

@Before("@Iec60870MockServerDefaultControlledStation")
public void initMockServerDefaultControlledStation() {
    ScenarioContext.current().put(PROFILE, Iec60870ProfileType.DEFAULT_CONTROLLED_STATION);
    final Iec60870AsduFactory factory = new DefaultControlledStationAsduFactory();
    factory.setIec60870Server(this.mockServer.getRtuSimulator());
    this.mockServer.addIec60870ASduHandler(ASduType.C_IC_NA_1, new Iec60870InterrogationCommandAsduHandler(factory));
}
Also used : Iec60870AsduFactory(org.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduFactory) Iec60870InterrogationCommandAsduHandler(org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler) DefaultControlledStationAsduFactory(org.opensmartgridplatform.simulator.protocol.iec60870.domain.defaultcontrolledstation.DefaultControlledStationAsduFactory) Before(io.cucumber.java.Before)

Example 4 with Iec60870InterrogationCommandAsduHandler

use of org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler in project open-smart-grid-platform by OSGP.

the class Iec60870AsduHandlerRegistryTest method registryShouldReturnInterrogationCommandHandlerForInterrogationCommandAsduType.

@Test
public void registryShouldReturnInterrogationCommandHandlerForInterrogationCommandAsduType() throws Exception {
    // arrange
    final ASduType asduType = ASduType.C_IC_NA_1;
    final Iec60870InterrogationCommandAsduHandler expected = this.iec60870InterrogationCommandAsduHandler;
    // act
    final Iec60870AsduHandler actual = this.iec60870AsduHandlerRegistry.getHandler(asduType);
    // assert
    assertThat(actual).isEqualTo(expected);
}
Also used : ASduType(org.openmuc.j60870.ASduType) Iec60870AsduHandler(org.opensmartgridplatform.iec60870.Iec60870AsduHandler) Iec60870InterrogationCommandAsduHandler(org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Iec60870InterrogationCommandAsduHandler (org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler)3 Before (io.cucumber.java.Before)2 Test (org.junit.jupiter.api.Test)2 Iec60870AsduFactory (org.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduFactory)2 InOrder (org.mockito.InOrder)1 ASdu (org.openmuc.j60870.ASdu)1 ASduType (org.openmuc.j60870.ASduType)1 Iec60870AsduHandler (org.opensmartgridplatform.iec60870.Iec60870AsduHandler)1 DefaultControlledStationAsduFactory (org.opensmartgridplatform.simulator.protocol.iec60870.domain.defaultcontrolledstation.DefaultControlledStationAsduFactory)1 LightMeasurementDeviceAsduFactory (org.opensmartgridplatform.simulator.protocol.iec60870.domain.lightmeasurementdevice.LightMeasurementDeviceAsduFactory)1 AsduTypeArgumentMatcher (org.opensmartgridplatform.simulator.protocol.iec60870.server.AsduTypeArgumentMatcher)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1