Search in sources :

Example 1 with GetStatusAsyncRequest

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

the class GetStatusSteps method thePlatformBuffersAGetStatusResponseMessageForDevice.

@Then("^the platform buffers a get status response message for device \"([^\"]*)\"$")
public void thePlatformBuffersAGetStatusResponseMessageForDevice(final String deviceIdentification, final Map<String, String> expectedResult) {
    final GetStatusAsyncRequest request = this.getGetStatusAsyncRequest(deviceIdentification);
    final GetStatusResponse response = Wait.untilAndReturn(() -> {
        final GetStatusResponse retval = this.publicLightingClient.getGetStatusResponse(request);
        assertThat(retval).isNotNull();
        assertThat(retval.getResult()).isEqualTo(Enum.valueOf(OsgpResultType.class, expectedResult.get(PlatformPubliclightingKeys.KEY_RESULT)));
        return retval;
    });
    final DeviceStatus deviceStatus = (DeviceStatus) response.getStatus();
    assertThat(deviceStatus.getPreferredLinkType()).isEqualTo(getEnum(expectedResult, PlatformPubliclightingKeys.KEY_PREFERRED_LINKTYPE, LinkType.class));
    assertThat(deviceStatus.getActualLinkType()).isEqualTo(getEnum(expectedResult, PlatformPubliclightingKeys.KEY_ACTUAL_LINKTYPE, LinkType.class));
    assertThat(deviceStatus.getLightType()).isEqualTo(getEnum(expectedResult, PlatformPubliclightingKeys.KEY_LIGHTTYPE, LightType.class));
    if (expectedResult.containsKey(PlatformPubliclightingKeys.KEY_EVENTNOTIFICATIONTYPES) && !expectedResult.get(PlatformPubliclightingKeys.KEY_EVENTNOTIFICATIONTYPES).isEmpty()) {
        assertThat(deviceStatus.getEventNotifications().size()).isEqualTo(getString(expectedResult, PlatformPubliclightingKeys.KEY_EVENTNOTIFICATIONS, PlatformPubliclightingDefaults.DEFAULT_EVENTNOTIFICATIONS).split(PlatformPubliclightingKeys.SEPARATOR_COMMA).length);
        for (final String eventNotification : getString(expectedResult, PlatformPubliclightingKeys.KEY_EVENTNOTIFICATIONS, PlatformPubliclightingDefaults.DEFAULT_EVENTNOTIFICATIONS).split(PlatformPubliclightingKeys.SEPARATOR_COMMA)) {
            assertThat(deviceStatus.getEventNotifications().contains(Enum.valueOf(EventNotificationType.class, eventNotification))).isTrue();
        }
    }
    if (expectedResult.containsKey(PlatformPubliclightingKeys.KEY_LIGHTVALUES) && !expectedResult.get(PlatformPubliclightingKeys.KEY_LIGHTVALUES).isEmpty()) {
        assertThat(deviceStatus.getLightValues().size()).isEqualTo(getString(expectedResult, PlatformPubliclightingKeys.KEY_LIGHTVALUES, PlatformPubliclightingDefaults.DEFAULT_LIGHTVALUES).split(PlatformPubliclightingKeys.SEPARATOR_COMMA).length);
        for (final String lightValues : getString(expectedResult, PlatformPubliclightingKeys.KEY_LIGHTVALUES, PlatformPubliclightingDefaults.DEFAULT_LIGHTVALUES).split(PlatformPubliclightingKeys.SEPARATOR_COMMA)) {
            final String[] parts = lightValues.split(PlatformPubliclightingKeys.SEPARATOR_SEMICOLON);
            final Integer index = Integer.parseInt(parts[0]);
            final Boolean on = Boolean.parseBoolean(parts[1]);
            final Integer dimValue = Integer.parseInt(parts[2]);
            boolean found = false;
            for (final LightValue lightValue : deviceStatus.getLightValues()) {
                if (Objects.equals(lightValue.getIndex(), index) && lightValue.isOn() == on && Objects.equals(lightValue.getDimValue(), dimValue)) {
                    found = true;
                    break;
                }
            }
            assertThat(found).isTrue();
        }
    }
}
Also used : LightType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightType) GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest) GetStatusResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusResponse) LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType) DeviceStatus(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.DeviceStatus) EventNotificationType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.EventNotificationType) LinkType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LinkType) Then(io.cucumber.java.en.Then)

Example 2 with GetStatusAsyncRequest

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

the class GetStatusSteps method getGetStatusAsyncRequest.

private GetStatusAsyncRequest getGetStatusAsyncRequest(final String deviceIdentification) {
    final GetStatusAsyncRequest request = new GetStatusAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformPubliclightingKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    return request;
}
Also used : GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest) GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest)

Example 3 with GetStatusAsyncRequest

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

the class OsgpPublicLightingClientSoapService method getGetStatusResponse.

/**
 * Async request. Sends a GetStatusAsyncRequest to the platform using the deviceId and
 * correlationId parameters.
 *
 * <p>Returns the response from the Platform.
 */
public GetStatusResponse getGetStatusResponse(final String deviceId, final String correlationId) {
    final AsyncRequest asyncRequest = new AsyncRequest();
    final GetStatusAsyncRequest asyncStatusRequest = new GetStatusAsyncRequest();
    asyncRequest.setCorrelationUid(correlationId);
    asyncRequest.setDeviceId(deviceId);
    asyncStatusRequest.setAsyncRequest(asyncRequest);
    final WebServiceTemplate template = this.soapRequestHelper.createPublicLightingRequest();
    return (GetStatusResponse) template.marshalSendAndReceive(asyncStatusRequest);
}
Also used : GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest) GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest) GetStatusResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusResponse) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate)

Aggregations

GetStatusAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest)3 GetStatusResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusResponse)2 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest)2 Then (io.cucumber.java.en.Then)1 DeviceStatus (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.DeviceStatus)1 EventNotificationType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.EventNotificationType)1 LightType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightType)1 LightValue (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue)1 LinkType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LinkType)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)1