use of org.opensmartgridplatform.oslp.Oslp.Status in project open-smart-grid-platform by OSGP.
the class OslpDeviceSteps method theDeviceReturnsAGetStatusResponseWithResultOverOslp.
/**
* Setup method to set the status which should be returned by the mock.
*/
@Given("^the device returns a get status response \"([^\"]*)\" over \"([^\"]*)\"$")
public void theDeviceReturnsAGetStatusResponseWithResultOverOslp(final String result, final String protocol, final Map<String, String> requestParameters) {
int eventNotificationTypes = 0;
if (getString(requestParameters, PlatformPubliclightingKeys.KEY_EVENTNOTIFICATIONTYPES, PlatformPubliclightingDefaults.DEFAULT_EVENTNOTIFICATIONTYPES).trim().split(PlatformPubliclightingKeys.SEPARATOR_COMMA).length > 0) {
for (final String eventNotificationType : getString(requestParameters, PlatformPubliclightingKeys.KEY_EVENTNOTIFICATIONTYPES, PlatformPubliclightingDefaults.DEFAULT_EVENTNOTIFICATIONTYPES).trim().split(PlatformPubliclightingKeys.SEPARATOR_COMMA)) {
if (!eventNotificationType.isEmpty()) {
eventNotificationTypes = eventNotificationTypes + Enum.valueOf(EventNotificationType.class, eventNotificationType.trim()).getValue();
}
}
}
final List<LightValue> lightValues = new ArrayList<>();
if (!getString(requestParameters, PlatformPubliclightingKeys.KEY_LIGHTVALUES, PlatformPubliclightingDefaults.DEFAULT_LIGHTVALUES).isEmpty() && getString(requestParameters, PlatformPubliclightingKeys.KEY_LIGHTVALUES, PlatformPubliclightingDefaults.DEFAULT_LIGHTVALUES).split(PlatformPubliclightingKeys.SEPARATOR_SEMICOLON).length > 0) {
for (final String lightValueString : getString(requestParameters, PlatformPubliclightingKeys.KEY_LIGHTVALUES, PlatformPubliclightingDefaults.DEFAULT_LIGHTVALUES).split(PlatformPubliclightingKeys.SEPARATOR_SEMICOLON)) {
final String[] parts = lightValueString.split(PlatformPubliclightingKeys.SEPARATOR_COMMA);
final LightValue lightValue = LightValue.newBuilder().setIndex(OslpUtils.integerToByteString(Integer.parseInt(parts[0]))).setOn(parts[1].toLowerCase().equals("true")).setDimValue(OslpUtils.integerToByteString(Integer.parseInt(parts[2]))).build();
lightValues.add(lightValue);
}
}
final List<LightValue> tariffValues = new ArrayList<>();
if (!getString(requestParameters, PlatformPubliclightingKeys.KEY_TARIFFVALUES, PlatformPubliclightingDefaults.DEFAULT_TARIFFVALUES).isEmpty() && getString(requestParameters, PlatformPubliclightingKeys.KEY_TARIFFVALUES, PlatformPubliclightingDefaults.DEFAULT_TARIFFVALUES).split(PlatformPubliclightingKeys.SEPARATOR_SEMICOLON).length > 0) {
for (final String tariffValueString : getString(requestParameters, PlatformPubliclightingKeys.KEY_TARIFFVALUES, PlatformPubliclightingDefaults.DEFAULT_TARIFFVALUES).split(PlatformPubliclightingKeys.SEPARATOR_SEMICOLON)) {
final String[] parts = tariffValueString.split(PlatformPubliclightingKeys.SEPARATOR_COMMA);
final LightValue tariffValue = LightValue.newBuilder().setIndex(OslpUtils.integerToByteString(Integer.parseInt(parts[0]))).setOn(parts[1].toLowerCase().equals("true")).build();
tariffValues.add(tariffValue);
}
}
this.oslpMockServer.mockGetStatusResponse(this.getDeviceUid(requestParameters), getEnum(requestParameters, PlatformPubliclightingKeys.KEY_PREFERRED_LINKTYPE, LinkType.class, PlatformPubliclightingDefaults.DEFAULT_PREFERRED_LINKTYPE), getEnum(requestParameters, PlatformPubliclightingKeys.KEY_ACTUAL_LINKTYPE, LinkType.class, PlatformPubliclightingDefaults.DEFAULT_ACTUAL_LINKTYPE), getEnum(requestParameters, PlatformPubliclightingKeys.KEY_LIGHTTYPE, LightType.class, PlatformPubliclightingDefaults.DEFAULT_LIGHTTYPE), eventNotificationTypes, Enum.valueOf(Status.class, result), lightValues, tariffValues);
}
use of org.opensmartgridplatform.oslp.Oslp.Status in project open-smart-grid-platform by OSGP.
the class OslpDeviceSteps method theDeviceReturnsAGetConfigurationStatusWithResultOverOslp.
/**
* Setup method to set the configuration status which should be returned by the mock.
*
* @throws UnknownHostException
*/
@Given("^the device returns a get configuration status \"([^\"]*)\" over \"([^\"]*)\"$")
public void theDeviceReturnsAGetConfigurationStatusWithResultOverOslp(final String result, final String protocol, final Map<String, String> requestParameters) throws UnknownHostException {
final String osgpIpAddress = getString(requestParameters, PlatformPubliclightingKeys.OSGP_IP_ADDRESS);
final String osgpIpAddressMock;
if (StringUtils.isEmpty(osgpIpAddress)) {
osgpIpAddressMock = null;
} else {
osgpIpAddressMock = osgpIpAddress;
}
this.oslpMockServer.mockGetConfigurationResponse(this.getDeviceUid(requestParameters), Enum.valueOf(Status.class, result), getEnum(requestParameters, PlatformPubliclightingKeys.KEY_LIGHTTYPE, LightType.class, PlatformPubliclightingDefaults.DEFAULT_LIGHTTYPE), getString(requestParameters, PlatformPubliclightingKeys.DC_LIGHTS, PlatformPubliclightingDefaults.DC_LIGHTS), getString(requestParameters, PlatformPubliclightingKeys.DC_MAP, PlatformPubliclightingDefaults.DEFAULT_DC_MAP), getString(requestParameters, PlatformPubliclightingKeys.RELAY_CONF, PlatformPubliclightingDefaults.DEFAULT_RELAY_CONFIGURATION), getEnum(requestParameters, PlatformPubliclightingKeys.KEY_PREFERRED_LINKTYPE, LinkType.class, PlatformPubliclightingDefaults.DEFAULT_PREFERRED_LINKTYPE), osgpIpAddressMock, getInteger(requestParameters, PlatformPubliclightingKeys.OSGP_PORT, PlatformPubliclightingDefaults.DEFAULT_OSLP_PORT));
}
Aggregations