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));
}
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();
}
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));
}
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);
}
Aggregations