use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationResponse in project open-smart-grid-platform by OSGP.
the class GetConfigurationSteps method thePlatformBuffersAGetConfigurationResponseMessageForDeviceContainsSoapFault.
@Then("^the platform buffers a get configuration response message for device \"([^\"]*)\" contains soap fault$")
public void thePlatformBuffersAGetConfigurationResponseMessageForDeviceContainsSoapFault(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);
Wait.until(() -> {
GetConfigurationResponse response = null;
try {
response = this.client.getGetConfiguration(request);
} catch (final Exception e) {
// do nothing
}
assertThat(response).isNotNull();
});
}
use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationResponse in project open-smart-grid-platform by OSGP.
the class ConfigurationManagementEndpoint method getGetConfigurationResponse.
@PayloadRoot(localPart = "GetConfigurationAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetConfigurationResponse getGetConfigurationResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetConfigurationAsyncRequest request) throws OsgpException {
LOGGER.info("GetConfigurationRequest received from organisation: {} for device: {}.", organisationIdentification, request.getAsyncRequest().getDeviceId());
final GetConfigurationResponse response = new GetConfigurationResponse();
try {
final ResponseMessage responseMessage = this.getResponseMessage(request.getAsyncRequest());
if (responseMessage != null) {
throwExceptionIfResultNotOk(responseMessage, "getting configuration");
response.setResult(OsgpResultType.fromValue(responseMessage.getResult().getValue()));
if (responseMessage.getDataObject() != null) {
final Configuration configuration = (Configuration) responseMessage.getDataObject();
response.setConfiguration(this.configurationManagementMapper.map(configuration, org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration.class));
}
} else {
LOGGER.debug("Get Configuration data is null");
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationResponse 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));
}
}
Aggregations