Search in sources :

Example 1 with SetLightRequest

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest in project open-smart-grid-platform by OSGP.

the class SetLightSteps method receivingAsetLightRequestWithValidLightValuesAndInvalidLightValues.

@When("^receiving a set light request with \"([^\"]*)\" valid lightvalues and \"([^\"]*)\" invalid lightvalues$")
public void receivingAsetLightRequestWithValidLightValuesAndInvalidLightValues(final Integer nofValidLightValues, final Integer nofInvalidLightValues, final Map<String, String> requestParameters) throws Throwable {
    final SetLightRequest request = new SetLightRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    for (int i = 0; i < nofValidLightValues; i++) {
        final LightValue lightValue = new LightValue();
        lightValue.setIndex(i + 2);
        lightValue.setDimValue(getInteger(requestParameters, PlatformKeys.KEY_DIMVALUE, PlatformDefaults.DEFAULT_DIMVALUE));
        lightValue.setOn(getBoolean(requestParameters, PlatformKeys.KEY_ON, PlatformDefaults.DEFAULT_ON));
        request.getLightValue().add(lightValue);
    }
    for (int i = 0; i < nofInvalidLightValues; i++) {
        final LightValue lightValue = new LightValue();
        lightValue.setIndex(i + 2 + nofValidLightValues);
        lightValue.setDimValue(50);
        lightValue.setOn(false);
        request.getLightValue().add(lightValue);
    }
    try {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.setLight(request));
    } catch (final SoapFaultClientException ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
    }
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) SetLightRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest) When(io.cucumber.java.en.When)

Example 2 with SetLightRequest

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest in project open-smart-grid-platform by OSGP.

the class OsgpPublicLightingClientSoapService method setLightRequest.

/**
 * Creates a WebServiceTemplate and a SetLightRequest with the parameters deviceId, dimValue and
 * LightOn. Sends the SetLightRequest to the platform using the WebServiceTemplate. Returns the
 * response (CorrelationId) from the Platform.
 *
 * @return correlation id
 */
public String setLightRequest(final String deviceId, final int dimValue, final boolean lightOn) {
    final SetLightRequest request = new SetLightRequest();
    final LightValue lightValue = new LightValue();
    lightValue.setDimValue(dimValue);
    lightValue.setOn(lightOn);
    final WebServiceTemplate template = this.soapRequestHelper.createPublicLightingRequest();
    request.setDeviceIdentification(deviceId);
    request.getLightValue().add(lightValue);
    final SetLightAsyncResponse response = (SetLightAsyncResponse) template.marshalSendAndReceive(request);
    return response.getAsyncResponse().getCorrelationUid();
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) SetLightRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest) SetLightAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse)

Example 3 with SetLightRequest

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest in project open-smart-grid-platform by OSGP.

the class SetLightSteps method receivingASetLightRequest.

/**
 * Sends a Set Light request to the platform for a given device identification.
 *
 * @param requestParameters The table with the request parameters.
 * @throws Throwable when an error occurs
 */
@When("^receiving a set light request$")
public void receivingASetLightRequest(final Map<String, String> requestParameters) throws Throwable {
    final SetLightRequest request = new SetLightRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    final LightValue lightValue = new LightValue();
    lightValue.setIndex(getInteger(requestParameters, PlatformKeys.KEY_INDEX, PlatformDefaults.DEFAULT_INDEX));
    if (requestParameters.containsKey(PlatformKeys.KEY_DIMVALUE) && !StringUtils.isEmpty(requestParameters.get(PlatformKeys.KEY_DIMVALUE))) {
        lightValue.setDimValue(getInteger(requestParameters, PlatformKeys.KEY_DIMVALUE, PlatformDefaults.DEFAULT_DIMVALUE));
    }
    lightValue.setOn(getBoolean(requestParameters, PlatformKeys.KEY_ON, PlatformDefaults.DEFAULT_ON));
    request.getLightValue().add(lightValue);
    try {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.setLight(request));
    } catch (final SoapFaultClientException ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
    }
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) SetLightRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest) When(io.cucumber.java.en.When)

Example 4 with SetLightRequest

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest in project open-smart-grid-platform by OSGP.

the class SetLightSteps method receivingASetLightRequestWithLightValues.

@When("^receiving a set light request with \"([^\"]*)\" light values$")
public void receivingASetLightRequestWithLightValues(final Integer nofLightValues, final Map<String, String> requestParameters) throws Throwable {
    final SetLightRequest request = new SetLightRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    for (int i = 0; i < nofLightValues; i++) {
        final LightValue lightValue = new LightValue();
        lightValue.setIndex(i + 2);
        lightValue.setDimValue(getInteger(requestParameters, PlatformKeys.KEY_DIMVALUE, PlatformDefaults.DEFAULT_DIMVALUE));
        lightValue.setOn(getBoolean(requestParameters, PlatformKeys.KEY_ON, PlatformDefaults.DEFAULT_ON));
        request.getLightValue().add(lightValue);
    }
    try {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.setLight(request));
    } catch (final SoapFaultClientException ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
    }
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) SetLightRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest) When(io.cucumber.java.en.When)

Example 5 with SetLightRequest

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest in project open-smart-grid-platform by OSGP.

the class AuthorizeDeviceFunctionsSteps method setLight.

private void setLight(final Map<String, String> requestParameters) throws WebServiceSecurityException, GeneralSecurityException, IOException {
    final SetLightRequest request = new SetLightRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformPubliclightingKeys.KEY_DEVICE_IDENTIFICATION, PlatformPubliclightingDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    final LightValue lightValue = new LightValue();
    lightValue.setIndex(0);
    lightValue.setDimValue(100);
    lightValue.setOn(true);
    request.getLightValue().add(lightValue);
    ScenarioContext.current().put(PlatformPubliclightingKeys.RESPONSE, this.publicLightingAdHocManagementClient.setLight(request));
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) SetLightRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest)

Aggregations

LightValue (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue)6 SetLightRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest)6 When (io.cucumber.java.en.When)3 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)3 SetLightAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse)2 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)2