Search in sources :

Example 6 with AsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest in project open-smart-grid-platform by OSGP.

the class SetConfigurationSteps method thePlatformBufferesASetConfigurationResponseMessageForDevice.

@Then("^the platform buffers a set configuration response message for device \"([^\"]*)\"$")
public void thePlatformBufferesASetConfigurationResponseMessageForDevice(final String deviceIdentification, final Map<String, String> expectedResponseData) throws Throwable {
    final SetConfigurationAsyncRequest request = new SetConfigurationAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    final SetConfigurationResponse response = Wait.untilAndReturn(() -> {
        final SetConfigurationResponse retval = this.client.getSetConfiguration(request);
        assertThat(retval).isNotNull();
        return retval;
    });
    assertThat(response.getResult()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_RESULT, OsgpResultType.class));
}
Also used : SetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest) SetConfigurationResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationResponse) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType) SetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncRequest) Then(io.cucumber.java.en.Then)

Example 7 with AsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest in project open-smart-grid-platform by OSGP.

the class SetConfigurationSteps method thePlatformBufferesASetConfigurationResponseMessageForDeviceContainsSoapFault.

@Then("^the platform buffers a set configuration response message for device \"([^\"]*)\" contains soap fault$")
public void thePlatformBufferesASetConfigurationResponseMessageForDeviceContainsSoapFault(final String deviceIdentification, final Map<String, String> expectedResponseData) throws Throwable {
    final SetConfigurationAsyncRequest request = new SetConfigurationAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    try {
        this.client.getSetConfiguration(request);
    } catch (final SoapFaultClientException ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
        GenericResponseSteps.verifySoapFault(expectedResponseData);
    }
}
Also used : SetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest) SetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncRequest) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) Then(io.cucumber.java.en.Then)

Example 8 with AsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest in project open-smart-grid-platform by OSGP.

the class SetRebootSteps method thenThePlatformBuffersASetRebootResponseMessage.

@Then("^the platform buffers a set reboot response message for device \"([^\"]*)\"$")
public void thenThePlatformBuffersASetRebootResponseMessage(final String deviceIdentification, final Map<String, String> expectedResult) {
    final SetRebootAsyncRequest request = new SetRebootAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    Wait.until(() -> {
        SetRebootResponse response = null;
        try {
            response = this.client.getSetRebootResponse(request);
        } catch (final Exception e) {
        // do nothing
        }
        assertThat(response).isNotNull();
        assertThat(response.getResult()).isEqualTo(Enum.valueOf(OsgpResultType.class, expectedResult.get(PlatformKeys.KEY_RESULT)));
    });
}
Also used : AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest) SetRebootAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncRequest) SetRebootAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncRequest) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType) SetRebootResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootResponse) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) Then(io.cucumber.java.en.Then)

Example 9 with AsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest in project open-smart-grid-platform by OSGP.

the class GetConfigurationSteps method thePlatformBuffersAGetConfigurationResponseMessageForDevice.

@Then("^the platform buffers a get configuration response message for device \"([^\"]*)\"$")
public void thePlatformBuffersAGetConfigurationResponseMessageForDevice(final String deviceIdentification, final Map<String, String> expectedResponseData) throws Throwable {
    final GetConfigurationAsyncRequest request = new GetConfigurationAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    final GetConfigurationResponse response = Wait.untilAndReturn(() -> {
        final GetConfigurationResponse retval = this.client.getGetConfiguration(request);
        assertThat(retval).isNotNull();
        assertThat(retval.getResult()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_RESULT, OsgpResultType.class));
        return retval;
    });
    final Configuration configuration = response.getConfiguration();
    assertThat(configuration).isNotNull();
    if (expectedResponseData.containsKey(PlatformKeys.KEY_LIGHTTYPE) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.KEY_LIGHTTYPE)) && configuration.getLightType() != null) {
        assertThat(configuration.getLightType()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_LIGHTTYPE, LightType.class));
    }
    final DaliConfiguration daliConfiguration = configuration.getDaliConfiguration();
    if (daliConfiguration != null) {
        if (expectedResponseData.containsKey(PlatformKeys.DC_LIGHTS) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.DC_LIGHTS)) && daliConfiguration.getNumberOfLights() != 0) {
            assertThat(daliConfiguration.getNumberOfLights()).isEqualTo((int) getInteger(expectedResponseData, PlatformKeys.DC_LIGHTS));
        }
        if (expectedResponseData.containsKey(PlatformKeys.DC_MAP) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.DC_MAP)) && daliConfiguration.getIndexAddressMap() != null) {
            final List<IndexAddressMap> indexAddressMapList = daliConfiguration.getIndexAddressMap();
            final String[] dcMapArray = getString(expectedResponseData, PlatformKeys.DC_MAP).split(";");
            for (int i = 0; i < dcMapArray.length; i++) {
                final String[] dcMapArrayElements = dcMapArray[i].split(",");
                assertThat(indexAddressMapList.get(i).getIndex()).isEqualTo(Integer.parseInt(dcMapArrayElements[0]));
                assertThat(indexAddressMapList.get(i).getAddress()).isEqualTo(Integer.parseInt(dcMapArrayElements[1]));
            }
        }
    }
    final RelayConfiguration relayConfiguration = configuration.getRelayConfiguration();
    if (relayConfiguration != null) {
        if (expectedResponseData.containsKey(PlatformKeys.RELAY_CONF) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.RELAY_CONF)) && relayConfiguration.getRelayMap() != null) {
            final List<RelayMap> relayMapList = relayConfiguration.getRelayMap();
            final String[] rcMapArray = getString(expectedResponseData, PlatformKeys.RELAY_CONF).split(";");
            for (int i = 0; i < rcMapArray.length; i++) {
                final String[] rcMapArrayElements = rcMapArray[i].split(",");
                if (rcMapArrayElements.length > 0 && relayMapList.size() > 0) {
                    assertThat(relayMapList.get(i).getIndex()).isEqualTo(Integer.parseInt(rcMapArrayElements[0]));
                    assertThat(relayMapList.get(i).getAddress()).isEqualTo(Integer.parseInt(rcMapArrayElements[1]));
                    if (expectedResponseData.containsKey(PlatformKeys.KEY_RELAY_TYPE) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.KEY_RELAY_TYPE)) && relayMapList.get(i).getRelayType() != null) {
                        assertThat(relayMapList.get(i).getRelayType()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_RELAY_TYPE, RelayType.class));
                    }
                }
            }
        }
    }
    if (expectedResponseData.containsKey(PlatformKeys.KEY_PREFERRED_LINKTYPE) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.KEY_PREFERRED_LINKTYPE)) && configuration.getPreferredLinkType() != null) {
        assertThat(configuration.getPreferredLinkType()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_PREFERRED_LINKTYPE, LinkType.class));
    }
    if (expectedResponseData.containsKey(PlatformKeys.OSGP_IP_ADDRESS) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.OSGP_IP_ADDRESS))) {
        assertThat(configuration.getOsgpIpAddress()).isEqualTo(getString(expectedResponseData, PlatformKeys.OSGP_IP_ADDRESS));
    }
    if (expectedResponseData.containsKey(PlatformKeys.OSGP_PORT) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.OSGP_PORT))) {
        assertThat(configuration.getOsgpPortNumber()).isEqualTo(getInteger(expectedResponseData, PlatformKeys.OSGP_PORT));
    }
}
Also used : LightType(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LightType) GetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest) DaliConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration) DaliConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration) RelayConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayConfiguration) Configuration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) GetConfigurationResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationResponse) IndexAddressMap(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.IndexAddressMap) GetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncRequest) RelayType(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayType) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType) RelayConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayConfiguration) RelayMap(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayMap) LinkType(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LinkType) Then(io.cucumber.java.en.Then)

Example 10 with AsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest in project open-smart-grid-platform by OSGP.

the class GetStatusSteps method thePlatformBuffersADeviceInstallationGetStatusResponseMessageForDevice.

@Then("the platform buffers a device installation get status response message for device {string}")
public void thePlatformBuffersADeviceInstallationGetStatusResponseMessageForDevice(final String deviceIdentification, final Map<String, String> expectedResult) throws Throwable {
    final GetStatusAsyncRequest request = new GetStatusAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    final GetStatusResponse response = Wait.untilAndReturn(() -> {
        final GetStatusResponse retval = this.client.getStatusResponse(request);
        assertThat(retval).isNotNull();
        assertThat(retval.getResult()).isEqualTo(Enum.valueOf(OsgpResultType.class, expectedResult.get(PlatformKeys.KEY_RESULT)));
        return retval;
    });
    final DeviceStatus deviceStatus = response.getDeviceStatus();
    assertThat(deviceStatus.getPreferredLinkType()).isEqualTo(getEnum(expectedResult, PlatformKeys.KEY_PREFERRED_LINKTYPE, LinkType.class));
    assertThat(deviceStatus.getActualLinkType()).isEqualTo(getEnum(expectedResult, PlatformKeys.KEY_ACTUAL_LINKTYPE, LinkType.class));
    assertThat(deviceStatus.getLightType()).isEqualTo(getEnum(expectedResult, PlatformKeys.KEY_LIGHTTYPE, LightType.class));
    if (expectedResult.containsKey(PlatformKeys.KEY_EVENTNOTIFICATIONTYPES) && StringUtils.isNotBlank(expectedResult.get(PlatformKeys.KEY_EVENTNOTIFICATIONTYPES))) {
        assertThat(deviceStatus.getEventNotifications().size()).isEqualTo(getString(expectedResult, PlatformKeys.KEY_EVENTNOTIFICATIONS, PlatformDefaults.DEFAULT_EVENTNOTIFICATIONS).split(PlatformKeys.SEPARATOR_COMMA).length);
        for (final String eventNotification : getString(expectedResult, PlatformKeys.KEY_EVENTNOTIFICATIONS, PlatformDefaults.DEFAULT_EVENTNOTIFICATIONS).split(PlatformKeys.SEPARATOR_COMMA)) {
            final EventNotificationType eventNotificationType = Enum.valueOf(EventNotificationType.class, eventNotification);
            assertThat(deviceStatus.getEventNotifications().contains(eventNotificationType)).isTrue();
        }
    }
    if (expectedResult.containsKey(PlatformKeys.KEY_LIGHTVALUES) && StringUtils.isNotBlank(expectedResult.get(PlatformKeys.KEY_LIGHTVALUES))) {
        assertThat(deviceStatus.getLightValues().size()).isEqualTo(getString(expectedResult, PlatformKeys.KEY_LIGHTVALUES, PlatformDefaults.DEFAULT_LIGHTVALUES).split(PlatformKeys.SEPARATOR_COMMA).length);
        for (final String lightValues : getString(expectedResult, PlatformKeys.KEY_LIGHTVALUES, PlatformDefaults.DEFAULT_LIGHTVALUES).split(PlatformKeys.SEPARATOR_COMMA)) {
            final String[] parts = lightValues.split(PlatformKeys.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.core.deviceinstallation.LightType) GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.GetStatusAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest) GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.GetStatusAsyncRequest) GetStatusResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.GetStatusResponse) LightValue(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightValue) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType) DeviceStatus(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.DeviceStatus) EventNotificationType(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.EventNotificationType) LinkType(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LinkType) Then(io.cucumber.java.en.Then)

Aggregations

Then (io.cucumber.java.en.Then)12 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest)12 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType)9 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)8 IOException (java.io.IOException)2 GeneralSecurityException (java.security.GeneralSecurityException)2 GetConfigurationAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncRequest)2 GetConfigurationResponse (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationResponse)2 SetConfigurationAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncRequest)2 StartDeviceTestAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StartDeviceTestAsyncRequest)2 StartDeviceTestResponse (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StartDeviceTestResponse)2 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)2 WebServiceSecurityException (org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException)2 SetRebootAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncRequest)1 SetRebootResponse (org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootResponse)1 Configuration (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration)1 DaliConfiguration (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration)1 IndexAddressMap (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.IndexAddressMap)1 LightType (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LightType)1 LinkType (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LinkType)1