Search in sources :

Example 1 with GetSpecificAttributeValueResponse

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();
}
Also used : GetSpecificAttributeValueAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueAsyncRequest) GetSpecificAttributeValueResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueResponse) Then(io.cucumber.java.en.Then)

Example 2 with GetSpecificAttributeValueResponse

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();
}
Also used : GetSpecificAttributeValueResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueResponse) SetPushSetupSmsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupSmsResponse) SetPushSetupSmsAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupSmsAsyncRequest) Then(io.cucumber.java.en.Then)

Example 3 with GetSpecificAttributeValueResponse

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;
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) GetSpecificAttributeValueResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueResponse) ScanMbusChannelsResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

GetSpecificAttributeValueResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueResponse)3 Then (io.cucumber.java.en.Then)2 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 GetSpecificAttributeValueAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.GetSpecificAttributeValueAsyncRequest)1 SetPushSetupSmsAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupSmsAsyncRequest)1 SetPushSetupSmsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupSmsResponse)1 ScanMbusChannelsResponseData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1