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