use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityValue in project open-smart-grid-platform by OSGP.
the class ActualPowerQualitySteps method theActualPowerQualityResultShouldBeReturned.
@Then("^the actual power quality result should be returned$")
public void theActualPowerQualityResultShouldBeReturned(final Map<String, String> settings) throws Throwable {
final ActualPowerQualityAsyncRequest asyncRequest = ActualPowerQualityRequestFactory.fromScenarioContext();
final ActualPowerQualityResponse response = this.responseClient.getResponse(asyncRequest);
assertThat(response).as("ActualPowerQualityResponseData should not be null").isNotNull();
final int expectedNumberOfPowerQualityObjects = getInteger(settings, "NumberOfPowerQualityObjects", 0);
final List<PowerQualityObject> actualPowerQualityObjects = response.getActualPowerQualityData().getPowerQualityObjects().getPowerQualityObject();
assertThat(actualPowerQualityObjects.size()).as("Number of power quality objects").isEqualTo(expectedNumberOfPowerQualityObjects);
for (int i = 0; i < expectedNumberOfPowerQualityObjects; i++) {
final PowerQualityObject actualPowerQualityObject = actualPowerQualityObjects.get(i);
final Long expectedNameId = SettingsHelper.getLongValue(settings, "PowerQuality_Name", i + 1);
if (expectedNameId != null) {
this.validatePowerQualityObject(actualPowerQualityObject, settings, i + 1);
}
}
final int expectedNumberOfPowerQualityValues = getInteger(settings, "NumberOfPowerQualityValues", 0);
final List<PowerQualityValue> powerQualityValues = response.getActualPowerQualityData().getPowerQualityValues().getPowerQualityValue();
assertThat(powerQualityValues.size()).as("Number of power quality values").isEqualTo(expectedNumberOfPowerQualityValues);
if (expectedNumberOfPowerQualityValues > 0) {
/*
* Expected value equals expectedNumberOfPowerQualityObjects,
* because the number of PowerQualityValues should match the number
* of power quality objects from the buffer.
*/
assertThat(powerQualityValues.size()).as("Number of power quality values").isEqualTo(expectedNumberOfPowerQualityObjects);
}
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityValue in project open-smart-grid-platform by OSGP.
the class PowerQualityValueConverter method convert.
@Override
public PowerQualityValue convert(final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityValue source, final Type<? extends PowerQualityValue> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final PowerQualityValue result = new PowerQualityValue();
if (source.getValue() instanceof Date) {
final XMLGregorianCalendar xmlGregCal = this.mapperFacade.map(source.getValue(), XMLGregorianCalendar.class);
result.setStringValueOrDateValueOrFloatValue(xmlGregCal);
} else {
result.setStringValueOrDateValueOrFloatValue(source.getValue());
}
return result;
}
Aggregations