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);
}
}
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);
}
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));
}
}
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));
}
Aggregations