use of org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataSystemIdentifier in project open-smart-grid-platform by OSGP.
the class GetDataSteps method assertSystemResponse.
private void assertSystemResponse(final Map<String, String> responseParameters, final List<GetDataSystemIdentifier> systemIdentifiers, final int systemIndex) {
final int numberOfSystems = systemIdentifiers.size();
final String indexPostfix = "_" + (systemIndex + 1);
final String systemDescription = "System[" + (systemIndex + 1) + "/" + numberOfSystems + "]";
final GetDataSystemIdentifier systemIdentifier = systemIdentifiers.get(systemIndex);
if (responseParameters.containsKey(PlatformKeys.KEY_SYSTEM_TYPE.concat(indexPostfix))) {
final String expectedType = responseParameters.get(PlatformKeys.KEY_SYSTEM_TYPE.concat(indexPostfix));
try {
assertThat(systemIdentifier.getType()).as(systemDescription + " type").isEqualTo(expectedType);
} catch (final AssertionFailedError e) {
// Work around for OSGP's restore connection scheduled task. If
// the type is not as expected it can be equal to RTU.
assertThat(systemIdentifier.getType()).as(systemDescription + " type").isEqualTo("RTU");
}
}
if (responseParameters.containsKey(PlatformKeys.KEY_NUMBER_OF_MEASUREMENTS.concat(indexPostfix))) {
this.assertMeasurements(responseParameters, systemIdentifier.getMeasurement(), numberOfSystems, systemIndex, systemDescription, indexPostfix);
}
if (responseParameters.containsKey(PlatformKeys.KEY_NUMBER_OF_PROFILES.concat(indexPostfix))) {
this.assertProfiles(responseParameters, systemIdentifier.getProfile(), numberOfSystems, systemIndex, systemDescription, indexPostfix);
}
}
use of org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataSystemIdentifier in project open-smart-grid-platform by OSGP.
the class GetDataSteps method theGetDataResponseShouldBeReturned.
@Then("^the get data response should be returned$")
public void theGetDataResponseShouldBeReturned(final Map<String, String> responseParameters) throws Throwable {
final String correlationUid = (String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID);
final Map<String, String> extendedParameters = SettingsHelper.addDefault(responseParameters, PlatformKeys.KEY_CORRELATION_UID, correlationUid);
final GetDataAsyncRequest getDataAsyncRequest = GetDataRequestBuilder.fromParameterMapAsync(extendedParameters);
final GetDataResponse response = this.client.getData(getDataAsyncRequest);
final String expectedResult = responseParameters.get(PlatformKeys.KEY_RESULT);
assertThat(response.getResult()).as("Result").isNotNull();
assertThat(response.getResult().name()).as("Result").isEqualTo(expectedResult);
if (!responseParameters.containsKey(PlatformKeys.KEY_NUMBER_OF_SYSTEMS)) {
throw new AssertionError("The Step DataTable must contain the expected number of systems with key \"" + PlatformKeys.KEY_NUMBER_OF_SYSTEMS + "\" when confirming a returned get data response.");
}
final int expectedNumberOfSystems = Integer.parseInt(responseParameters.get(PlatformKeys.KEY_NUMBER_OF_SYSTEMS));
final List<GetDataSystemIdentifier> systemIdentifiers = response.getSystem();
assertThat(systemIdentifiers.size()).as("Number of Systems").isEqualTo(expectedNumberOfSystems);
for (int i = 0; i < expectedNumberOfSystems; i++) {
this.assertSystemResponse(responseParameters, systemIdentifiers, i);
}
}
Aggregations