Search in sources :

Example 1 with AsduTypeArgumentMatcher

use of org.opensmartgridplatform.simulator.protocol.iec60870.server.AsduTypeArgumentMatcher 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)

Aggregations

Test (org.junit.jupiter.api.Test)1 InOrder (org.mockito.InOrder)1 ASdu (org.openmuc.j60870.ASdu)1 AsduTypeArgumentMatcher (org.opensmartgridplatform.simulator.protocol.iec60870.server.AsduTypeArgumentMatcher)1