Search in sources :

Example 6 with Message

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

the class OslpDeviceSteps method anUpdateFirmwareOslpMessageIsSentToTheDevice.

@Then("^an update firmware \"([^\"]*)\" message is sent to device \"([^\"]*)\"$")
public void anUpdateFirmwareOslpMessageIsSentToTheDevice(final String protocol, final String deviceIdentification, final Map<String, String> expectedParameters) throws UnknownHostException, DeviceSimulatorException {
    final Message message = this.oslpMockServer.waitForRequest(this.getDeviceUid(expectedParameters), MessageType.UPDATE_FIRMWARE);
    assertThat(message).isNotNull();
    assertThat(message.hasUpdateFirmwareRequest()).isTrue();
    final UpdateFirmwareRequest request = message.getUpdateFirmwareRequest();
    // Check if the URL is equal to the file path as given by
    // 'firmware.path' property of OSGP.
    assertThat(request.getFirmwareUrl()).isEqualTo(getString(expectedParameters, PlatformPubliclightingKeys.FIRMWARE_URL, PlatformPubliclightingDefaults.FIRMWARE_URL));
}
Also used : Message(org.opensmartgridplatform.oslp.Oslp.Message) UpdateFirmwareRequest(org.opensmartgridplatform.oslp.Oslp.UpdateFirmwareRequest) Then(io.cucumber.java.en.Then)

Example 7 with Message

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

the class OslpDeviceSteps method aGetStatusOslpMessageIsSentToSpecificDevice.

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

Example 8 with Message

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

the class OslpDeviceSteps method aSetTransitionOslpMessageIsSentToDevice.

/**
 * Verify that a set transition OSLP message is sent to the device.
 *
 * @param deviceIdentification The device identification expected in the message to the device.
 */
@Then("^a set transition \"([^\"]*)\" message is sent to device \"([^\"]*)\"$")
public void aSetTransitionOslpMessageIsSentToDevice(final String protocol, final String deviceIdentification, final Map<String, String> expectedResult) throws DeviceSimulatorException {
    final Message message = this.oslpMockServer.waitForRequest(this.getDeviceUid(expectedResult), MessageType.SET_TRANSITION);
    assertThat(message).isNotNull();
    assertThat(message.hasSetTransitionRequest()).isTrue();
    final SetTransitionRequest request = message.getSetTransitionRequest();
    assertThat(request.getTransitionType()).isEqualTo(getEnum(expectedResult, PlatformPubliclightingKeys.KEY_TRANSITION_TYPE, TransitionType.class));
    if (expectedResult.containsKey(PlatformPubliclightingKeys.KEY_TIME)) {
    // TODO: How to check the time?
    // Assert.assertEquals(expectedResult.get(Keys.KEY_TIME),
    // request.getTime());
    }
}
Also used : SetTransitionRequest(org.opensmartgridplatform.oslp.Oslp.SetTransitionRequest) Message(org.opensmartgridplatform.oslp.Oslp.Message) TransitionType(org.opensmartgridplatform.oslp.Oslp.TransitionType) Then(io.cucumber.java.en.Then)

Example 9 with Message

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

the class OslpDeviceSteps method theSetConfigurationResponseContains.

/**
 * Verify that we have received a set configuration response over OSLP/OSLP ELSTER
 */
@Then("^the set configuration response contains$")
public void theSetConfigurationResponseContains(final Map<String, String> expectedResponse) {
    final Message responseMessage = this.oslpMockServer.waitForResponse();
    final SetConfigurationResponse response = responseMessage.getSetConfigurationResponse();
    assertThat(response.getStatus().name()).isEqualTo(getString(expectedResponse, PlatformPubliclightingKeys.KEY_STATUS));
}
Also used : Message(org.opensmartgridplatform.oslp.Oslp.Message) SetConfigurationResponse(org.opensmartgridplatform.oslp.Oslp.SetConfigurationResponse) Then(io.cucumber.java.en.Then)

Example 10 with Message

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

the class OslpDeviceSteps method aSetLightOslpMessageWithOneLightvalueIsSentToTheDevice.

/**
 * Verify that a set light OSLP message is sent to the device.
 *
 * @param expectedParameters The parameters expected in the message of the device.
 */
@Then("^a set light \"([^\"]*)\" message with one light value is sent to the device$")
public void aSetLightOslpMessageWithOneLightvalueIsSentToTheDevice(final String protocol, final Map<String, String> expectedParameters) throws DeviceSimulatorException {
    final Message message = this.oslpMockServer.waitForRequest(this.getDeviceUid(expectedParameters), MessageType.SET_LIGHT);
    assertThat(message).isNotNull();
    assertThat(message.hasSetLightRequest()).isTrue();
    final LightValue lightValue = message.getSetLightRequest().getValues(0);
    assertThat(OslpUtils.byteStringToInteger(lightValue.getIndex())).isEqualTo(getInteger(expectedParameters, PlatformPubliclightingKeys.KEY_INDEX, PlatformPubliclightingDefaults.DEFAULT_INDEX));
    if (expectedParameters.containsKey(PlatformPubliclightingKeys.KEY_DIMVALUE) && !StringUtils.isEmpty(expectedParameters.get(PlatformPubliclightingKeys.KEY_DIMVALUE))) {
        assertThat(OslpUtils.byteStringToInteger(lightValue.getDimValue())).isEqualTo(getInteger(expectedParameters, PlatformPubliclightingKeys.KEY_DIMVALUE, PlatformPubliclightingDefaults.DEFAULT_DIMVALUE));
    }
    assertThat(lightValue.getOn()).isEqualTo(getBoolean(expectedParameters, PlatformPubliclightingKeys.KEY_ON, PlatformPubliclightingDefaults.DEFAULT_ON));
}
Also used : Message(org.opensmartgridplatform.oslp.Oslp.Message) LightValue(org.opensmartgridplatform.oslp.Oslp.LightValue) 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