Search in sources :

Example 1 with Configuration

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

the class SetConfigurationSteps method receivingASetConfigurationRequest.

/**
 * Sends a Set Configuration request to the platform for a given device identification.
 *
 * @param requestParameters The table with the request parameters.
 * @throws Throwable
 */
@When("^receiving a set configuration request$")
public void receivingASetConfigurationRequest(final Map<String, String> requestParameters) throws Throwable {
    final SetConfigurationRequest request = new SetConfigurationRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformCommonDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    final Configuration config = new Configuration();
    if (StringUtils.isNotEmpty(requestParameters.get(PlatformCommonKeys.KEY_LIGHTTYPE))) {
        final LightType lightType = getEnum(requestParameters, PlatformKeys.KEY_LIGHTTYPE, LightType.class);
        config.setLightType(lightType);
    }
    if (StringUtils.isNotEmpty(getString(requestParameters, PlatformCommonKeys.DC_LIGHTS)) || StringUtils.isNotEmpty(getString(requestParameters, PlatformCommonKeys.DC_MAP))) {
        this.addFilledDaliConfigurationToConfiguration(requestParameters, config);
    }
    if (StringUtils.isNotEmpty(getString(requestParameters, PlatformCommonKeys.RC_TYPE)) || StringUtils.isNotEmpty(getString(requestParameters, PlatformCommonKeys.RELAY_CONF))) {
        this.addFilledRelayConfigurationToConfiguration(requestParameters, config);
    }
    final LinkType preferredLinkType = getEnum(requestParameters, PlatformKeys.KEY_PREFERRED_LINKTYPE, LinkType.class);
    config.setPreferredLinkType(preferredLinkType);
    if (requestParameters.containsKey(PlatformKeys.OSGP_IP_ADDRESS) && StringUtils.isNotEmpty(requestParameters.get(PlatformKeys.OSGP_IP_ADDRESS))) {
        config.setOsgpIpAddress(requestParameters.get(PlatformKeys.OSGP_IP_ADDRESS));
    }
    if (requestParameters.containsKey(PlatformKeys.OSGP_PORT) && StringUtils.isNotEmpty(requestParameters.get(PlatformKeys.OSGP_PORT))) {
        config.setOsgpPortNumber(getInteger(requestParameters, PlatformKeys.OSGP_PORT));
    }
    request.setConfiguration(config);
    try {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.setConfiguration(request));
    } catch (final SoapFaultClientException ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
    }
}
Also used : LightType(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LightType) 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) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) LinkType(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LinkType) SetConfigurationRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationRequest) When(io.cucumber.java.en.When)

Example 2 with Configuration

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

the class ConfigurationManagementMapperTest method mapsWsConfigurationToDomainConfiguration.

@Test
void mapsWsConfigurationToDomainConfiguration() throws DatatypeConfigurationException {
    final Configuration source = new Configuration();
    source.setLightType(LightType.DALI);
    source.setDaliConfiguration(this.aSourceDaliConfiguration(123, 124, 125, 126, 127));
    source.setRelayConfiguration(this.aSourceRelayConfiguration(128, 129, 130, 131));
    source.setPreferredLinkType(LinkType.CDMA);
    source.setTimeSyncFrequency(134);
    source.setDeviceFixedIp(this.aSourceDeviceFixedIp("ipAddress1", "netMask1", "gateWay1"));
    source.setDhcpEnabled(true);
    source.setCommunicationTimeout(135);
    source.setCommunicationNumberOfRetries(136);
    source.setCommunicationPauseTimeBetweenConnectionTrials(137);
    source.setOsgpIpAddress("osgpIpAddress1");
    source.setOsgpPortNumber(138);
    source.setNtpHost("ntpHost1");
    source.setNtpEnabled(true);
    source.setNtpSyncInterval(139);
    source.setTestButtonEnabled(true);
    source.setAutomaticSummerTimingEnabled(true);
    source.setAstroGateSunRiseOffset(140);
    source.setAstroGateSunSetOffset(141);
    source.getSwitchingDelays().addAll(asList(142, 142));
    source.getRelayLinking().addAll(asList(this.aSourceRelayMatrix(143, true), this.aSourceRelayMatrix(144, false)));
    final DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    source.setSummerTimeDetails(datatypeFactory.newXMLGregorianCalendar("2010-06-30T01:20:30+02:00"));
    source.setWinterTimeDetails(datatypeFactory.newXMLGregorianCalendar("2011-06-30T01:20:30+02:00"));
    source.setRelayRefreshing(true);
    final org.opensmartgridplatform.domain.core.valueobjects.Configuration result = this.mapper.map(source, org.opensmartgridplatform.domain.core.valueobjects.Configuration.class);
    final org.opensmartgridplatform.domain.core.valueobjects.Configuration expected = new org.opensmartgridplatform.domain.core.valueobjects.Configuration.Builder().withLightType(org.opensmartgridplatform.domain.core.valueobjects.LightType.DALI).withDaliConfiguration(this.aTargetDaliConfiguration(123, 124, 125, 126, 127)).withRelayConfiguration(this.aTargetRelayConfiguration(128, 129, 130, 131)).withPreferredLinkType(org.opensmartgridplatform.domain.core.valueobjects.LinkType.CDMA).withTimeSyncFrequency(134).withDeviceFixedIp(new org.opensmartgridplatform.domain.core.valueobjects.DeviceFixedIp("ipAddress1", "netMask1", "gateWay1")).withDhcpEnabled(true).withCommunicationTimeout(135).withCommunicationNumberOfRetries(136).withCommunicationPauseTimeBetweenConnectionTrials(137).withOsgpIpAddress("osgpIpAddress1").withOsgpPortNumber(138).withNtpHost("ntpHost1").withNtpEnabled(true).withNtpSyncInterval(139).withTestButtonEnabled(true).withAutomaticSummerTimingEnabled(true).withAstroGateSunRiseOffset(140).withAstroGateSunSetOffset(141).withSwitchingDelays(asList(142, 142)).withRelayLinking(asList(this.aTargetRelayMatrix(143, true), this.aTargetRelayMatrix(144, false))).withRelayRefreshing(true).withSummerTimeDetails(DateTime.parse("2010-06-30T01:20:30+02:00")).withWinterTimeDetails(DateTime.parse("2011-06-30T01:20:30+02:00")).build();
    assertThat(result).usingRecursiveComparison().isEqualTo(expected);
}
Also used : DeviceFixedIp(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DeviceFixedIp) RelayConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayConfiguration) DaliConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration) Configuration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration) DatatypeFactory(javax.xml.datatype.DatatypeFactory) Test(org.junit.jupiter.api.Test)

Example 3 with Configuration

use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration 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 4 with Configuration

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

the class AuthorizeDeviceFunctionsSteps method setConfiguration.

private void setConfiguration(final Map<String, String> requestParameters) throws WebServiceSecurityException, GeneralSecurityException, IOException {
    final SetConfigurationRequest request = new SetConfigurationRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformCommonKeys.KEY_DEVICE_IDENTIFICATION, PlatformCommonDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    final Configuration config = new Configuration();
    config.setLightType(PlatformCommonDefaults.CONFIGURATION_LIGHTTYPE);
    config.setPreferredLinkType(PlatformCommonDefaults.CONFIGURATION_PREFERRED_LINKTYPE);
    request.setConfiguration(config);
    ScenarioContext.current().put(PlatformCommonKeys.RESPONSE, this.coreConfigurationManagementClient.setConfiguration(request));
}
Also used : Configuration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration) SetConfigurationRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationRequest)

Aggregations

Configuration (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration)4 DaliConfiguration (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration)3 RelayConfiguration (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayConfiguration)3 LightType (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LightType)2 LinkType (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LinkType)2 SetConfigurationRequest (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationRequest)2 Then (io.cucumber.java.en.Then)1 When (io.cucumber.java.en.When)1 DatatypeFactory (javax.xml.datatype.DatatypeFactory)1 Test (org.junit.jupiter.api.Test)1 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType)1 DeviceFixedIp (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DeviceFixedIp)1 GetConfigurationAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncRequest)1 GetConfigurationResponse (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationResponse)1 IndexAddressMap (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.IndexAddressMap)1 RelayMap (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayMap)1 RelayType (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayType)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)1