Search in sources :

Example 21 with Message

use of org.opensmartgridplatform.oslp.Oslp.Message in project open-smart-grid-platform by OSGP.

the class OslpDeviceSteps method theConfirmRegisterDeviceResponseContains.

/**
 * Verify that we have received a confirm register device response over OSLP/OSLP ELSTER
 */
@Then("^the confirm register device response contains$")
public void theConfirmRegisterDeviceResponseContains(final Map<String, String> expectedResponse) {
    final Exception e = (Exception) ScenarioContext.current().get("Error");
    if (e == null || getString(expectedResponse, PlatformPubliclightingKeys.MESSAGE) == null) {
        final Message responseMessage = this.oslpMockServer.waitForResponse();
        final Oslp.ConfirmRegisterDeviceResponse response = responseMessage.getConfirmRegisterDeviceResponse();
        Assert.assertNotNull(response);
        assertThat(response.getStatus().name()).isEqualTo(getString(expectedResponse, PlatformPubliclightingKeys.KEY_STATUS));
    } else {
        assertThat(e).hasMessage(getString(expectedResponse, PlatformPubliclightingKeys.MESSAGE));
    }
}
Also used : Message(org.opensmartgridplatform.oslp.Oslp.Message) Oslp(org.opensmartgridplatform.oslp.Oslp) ParseException(java.text.ParseException) DeviceSimulatorException(org.opensmartgridplatform.cucumber.platform.publiclighting.mocks.oslpdevice.DeviceSimulatorException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) Then(io.cucumber.java.en.Then)

Example 22 with Message

use of org.opensmartgridplatform.oslp.Oslp.Message in project open-smart-grid-platform by OSGP.

the class OslpDeviceSteps method aGetFirmwareVersionOslpMessageIsSentToSpecificDevice.

/**
 * Verify that a get firmware version OSLP message is sent to the specific device.
 *
 * @param deviceIdentification The device identification expected in the message to the device.
 */
@Then("^a get firmware version \"([^\"]*)\" message is sent to device \"([^\"]*)\" with deviceUid \"([^\"]*)\"$")
public void aGetFirmwareVersionOslpMessageIsSentToSpecificDevice(final String protocol, final String deviceIdentification, final String deviceUid) throws DeviceSimulatorException {
    final Message message = this.oslpMockServer.waitForRequest(deviceUid, MessageType.GET_FIRMWARE_VERSION);
    assertThat(message).isNotNull();
    assertThat(message.hasGetFirmwareVersionRequest()).isTrue();
    message.getGetFirmwareVersionRequest();
}
Also used : Message(org.opensmartgridplatform.oslp.Oslp.Message) Then(io.cucumber.java.en.Then)

Example 23 with Message

use of org.opensmartgridplatform.oslp.Oslp.Message in project open-smart-grid-platform by OSGP.

the class OslpDeviceSteps method aSetRebootOslpMessageIsSentToSpecificDevice.

/**
 * Verify that a set reboot OSLP message is sent to specific device.
 *
 * @param deviceIdentification The device identification expected in the message to the device.
 */
@Then("^a set reboot \"([^\"]*)\" message is sent to device \"([^\"]*)\" with deviceUid \"([^\"]*)\"$")
public void aSetRebootOslpMessageIsSentToSpecificDevice(final String protocol, final String deviceIdentification, final String deviceUid) throws DeviceSimulatorException {
    final Message message = this.oslpMockServer.waitForRequest(deviceUid, MessageType.SET_REBOOT);
    assertThat(message).isNotNull();
    assertThat(message.hasSetRebootRequest()).isTrue();
}
Also used : Message(org.opensmartgridplatform.oslp.Oslp.Message) Then(io.cucumber.java.en.Then)

Example 24 with Message

use of org.opensmartgridplatform.oslp.Oslp.Message in project open-smart-grid-platform by OSGP.

the class OslpDeviceSteps method aGetConfigurationOslpMessageIsSentToSpecificDevice.

/**
 * Verify that a get configuration OSLP message is sent to the specific device.
 *
 * @param protocol The protocol over which the device communicates. - NOT USED -
 * @param deviceIdentification The device identification expected in the message to the device. -
 *     NOT USED -
 * @param deviceUid The device Uid expected in the message to the device.
 */
@Then("^a get configuration \"([^\"]*)\" message is sent to device \"([^\"]*)\" with deviceUid \"([^\"]*)\"$")
public void aGetConfigurationOslpMessageIsSentToSpecificDevice(final String protocol, final String deviceIdentification, final String deviceUid) throws DeviceSimulatorException {
    final Message message = this.oslpMockServer.waitForRequest(deviceUid, MessageType.GET_CONFIGURATION);
    assertThat(message).isNotNull();
    assertThat(message.hasGetConfigurationRequest()).isTrue();
}
Also used : Message(org.opensmartgridplatform.oslp.Oslp.Message) Then(io.cucumber.java.en.Then)

Example 25 with Message

use of org.opensmartgridplatform.oslp.Oslp.Message in project open-smart-grid-platform by OSGP.

the class OslpDeviceSteps method aResumeScheduleOslpMessageIsSentToDevice.

/**
 * Verify that a resume schedule OSLP message is sent to the device.
 *
 * @param deviceIdentification The device identification expected in the message to the device.
 */
@Then("^a resume schedule \"([^\"]*)\" message is sent to device \"([^\"]*)\"$")
public void aResumeScheduleOslpMessageIsSentToDevice(final String protocol, final String deviceIdentification, final Map<String, String> expectedRequest) throws DeviceSimulatorException {
    final Message message = this.oslpMockServer.waitForRequest(this.getDeviceUid(expectedRequest), MessageType.RESUME_SCHEDULE);
    assertThat(message).isNotNull();
    assertThat(message.hasResumeScheduleRequest()).isTrue();
    final ResumeScheduleRequest request = message.getResumeScheduleRequest();
    /*
     * resumeScheduleRequest { index: "\000" immediate: false }
     */
    assertThat(OslpUtils.byteStringToInteger(request.getIndex())).isEqualTo(getInteger(expectedRequest, PlatformPubliclightingKeys.KEY_INDEX));
    assertThat(request.getImmediate()).isEqualTo(getBoolean(expectedRequest, PlatformPubliclightingKeys.KEY_ISIMMEDIATE));
}
Also used : ResumeScheduleRequest(org.opensmartgridplatform.oslp.Oslp.ResumeScheduleRequest) Message(org.opensmartgridplatform.oslp.Oslp.Message) Then(io.cucumber.java.en.Then)

Aggregations

Message (org.opensmartgridplatform.oslp.Oslp.Message)28 Then (io.cucumber.java.en.Then)18 ByteString (com.google.protobuf.ByteString)5 IOException (java.io.IOException)4 Oslp (org.opensmartgridplatform.oslp.Oslp)4 ParseException (java.text.ParseException)3 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)3 OslpEnvelope (org.opensmartgridplatform.oslp.OslpEnvelope)3 UnknownHostException (java.net.UnknownHostException)2 Test (org.junit.jupiter.api.Test)2 DeviceSimulatorException (org.opensmartgridplatform.cucumber.platform.publiclighting.mocks.oslpdevice.DeviceSimulatorException)2 EventNotificationResponse (org.opensmartgridplatform.oslp.Oslp.EventNotificationResponse)2 Given (io.cucumber.java.en.Given)1 When (io.cucumber.java.en.When)1 Bootstrap (io.netty.bootstrap.Bootstrap)1 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelFutureListener (io.netty.channel.ChannelFutureListener)1 Sharable (io.netty.channel.ChannelHandler.Sharable)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelId (io.netty.channel.ChannelId)1