Search in sources :

Example 1 with SetPushSetupSmsResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupSmsResponse in project open-smart-grid-platform by OSGP.

the class SmartMeteringConfigurationEndpoint method getSetPushSetupSmsResponse.

@PayloadRoot(localPart = "SetPushSetupSmsAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public SetPushSetupSmsResponse getSetPushSetupSmsResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetPushSetupSmsAsyncRequest request) throws OsgpException {
    log.info("Incoming SetPushSetupAlarmAsyncRequest for organisation {} for meter: {}.", organisationIdentification, request.getDeviceIdentification());
    SetPushSetupSmsResponse response = null;
    try {
        response = new SetPushSetupSmsResponse();
        final ResponseData meterResponseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
        response.setResult(OsgpResultType.fromValue(meterResponseData.getResultType().getValue()));
        if (meterResponseData.getMessageData() instanceof String) {
            response.setDescription((String) meterResponseData.getMessageData());
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : GetKeysResponseData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) SetPushSetupSmsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupSmsResponse) IOException(java.io.IOException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with SetPushSetupSmsResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupSmsResponse 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)

Aggregations

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