use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueResponse in project open-smart-grid-platform by OSGP.
the class SpecificAttributeValue method thenAGetSpecificAttributeValueResponseShouldBeReturned.
@Then("^a get specific attribute value response should be returned$")
public void thenAGetSpecificAttributeValueResponseShouldBeReturned(final Map<String, String> settings) throws Throwable {
final GetSpecificAttributeValueAsyncRequest asyncRequest = SpecificAttributeValueRequestFactory.fromScenarioContext();
final GetSpecificAttributeValueResponse response = this.responseClient.getResponse(asyncRequest);
assertThat(response.getResult().name()).as("Result is not as expected.").isEqualTo(settings.get(PlatformSmartmeteringKeys.RESULT));
final String actual = response.getAttributeValueData();
assertThat(StringUtils.isNotBlank(actual)).as("Result contains no data.").isTrue();
final String expected = settings.get(PlatformSmartmeteringKeys.RESPONSE_PART);
assertThat(actual.contains(expected)).as("Result data is not as expected; expected '" + expected + "' to be part of '" + actual + "'").isTrue();
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueResponse in project open-smart-grid-platform by OSGP.
the class SetPushSetupSms method thePushSetupSmsShouldBeSetOnTheDevice.
@Then("^the PushSetupSms should be set on the device$")
public void thePushSetupSmsShouldBeSetOnTheDevice(final Map<String, String> settings) throws Throwable {
final SetPushSetupSmsAsyncRequest setPushSetupSmsAsyncRequest = SetPushSetupSmsRequestFactory.fromScenarioContext();
final SetPushSetupSmsResponse setPushSetupSmsResponse = this.smartMeteringConfigurationClient.getSetPushSetupSmsResponse(setPushSetupSmsAsyncRequest);
assertThat(setPushSetupSmsResponse).as("SetPushSetupSmsResponse was null").isNotNull();
assertThat(setPushSetupSmsResponse.getResult()).as("SetPushSetupSmsResponse result was null").isNotNull();
assertThat(setPushSetupSmsResponse.getResult()).as("SetPushSetupSmsResponse should be OK").isEqualTo(OsgpResultType.OK);
final GetSpecificAttributeValueResponse specificAttributeValues = this.getSpecificAttributeValues(settings);
assertThat(specificAttributeValues).as("GetSpecificAttributeValuesResponse was null").isNotNull();
assertThat(specificAttributeValues.getResult()).as("GetSpecificAttributeValuesResponse result was null").isNotNull();
assertThat(specificAttributeValues.getResult()).as("GetSpecificAttributeValuesResponse should be OK").isEqualTo(OsgpResultType.OK);
final String hostAndPort = ScenarioContext.current().get(PlatformSmartmeteringKeys.HOSTNAME) + ":" + ScenarioContext.current().get(PlatformSmartmeteringKeys.PORT);
final byte[] expectedBytes = (hostAndPort.getBytes(StandardCharsets.US_ASCII));
final String expected = Arrays.toString(expectedBytes);
final String actual = specificAttributeValues.getAttributeValueData();
assertThat(actual.contains(expected)).as("PushSetupSms was not set on device").isTrue();
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringAdhocEndpoint method getSpecificAttributeValueResponse.
@PayloadRoot(localPart = "GetSpecificAttributeValueAsyncRequest", namespace = SMARTMETER_ADHOC_NAMESPACE)
@ResponsePayload
public GetSpecificAttributeValueResponse getSpecificAttributeValueResponse(@RequestPayload final GetSpecificAttributeValueAsyncRequest request) throws OsgpException {
GetSpecificAttributeValueResponse response = null;
try {
response = new GetSpecificAttributeValueResponse();
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
if (ResponseMessageResultType.OK == responseData.getResultType()) {
response.setAttributeValueData((String) responseData.getMessageData());
} else if (responseData.getMessageData() instanceof OsgpException) {
throw (OsgpException) responseData.getMessageData();
} else if (responseData.getMessageData() instanceof Exception) {
throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Get specific attribute value", (Exception) responseData.getMessageData());
} else {
throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Get specific attribute value", null);
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations