Search in sources :

Example 1 with ScanMbusChannelsResponse

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

the class SmartMeteringAdhocEndpoint method getScanMbusChannelsResponse.

@PayloadRoot(localPart = "ScanMbusChannelsAsyncRequest", namespace = SMARTMETER_ADHOC_NAMESPACE)
@ResponsePayload
public ScanMbusChannelsResponse getScanMbusChannelsResponse(@RequestPayload final ScanMbusChannelsAsyncRequest request) throws OsgpException {
    ScanMbusChannelsResponse response = null;
    try {
        response = new ScanMbusChannelsResponse();
        final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
        this.throwExceptionIfResultNotOk(responseData, "retrieving the scan m-bus channels response");
        response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
        final ScanMbusChannelsResponseData scanMbusChannelsResponse = (ScanMbusChannelsResponseData) responseData.getMessageData();
        if (ResponseMessageResultType.OK == responseData.getResultType()) {
            final List<MbusChannelShortEquipmentIdentifier> channelShortIds = response.getChannelShortIds();
            channelShortIds.addAll(this.adhocMapper.mapAsList(scanMbusChannelsResponse.getChannelShortIds(), MbusChannelShortEquipmentIdentifier.class));
        } 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: Scan M-Bus Channels", (Exception) responseData.getMessageData());
        } else {
            throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Scan M-Bus Channels", null);
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) MbusChannelShortEquipmentIdentifier(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.MbusChannelShortEquipmentIdentifier) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ScanMbusChannelsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ScanMbusChannelsResponse) ScanMbusChannelsResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) ScanMbusChannelsResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData) 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)

Example 2 with ScanMbusChannelsResponse

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

the class ScanMbusChannelsSteps method theFoundMBusDevicesAreInTheResponse.

@Then("^the found M-bus devices are in the response$")
public void theFoundMBusDevicesAreInTheResponse(final Map<String, String> settings) throws Throwable {
    final ScanMbusChannelsAsyncRequest asyncRequest = ScanMbusChannelsRequestFactory.fromScenarioContext();
    final ScanMbusChannelsResponse response = this.responseClient.getResponse(asyncRequest);
    assertThat(response.getResult().name()).as("Result is not as expected.").isEqualTo(settings.get(PlatformSmartmeteringKeys.RESULT));
    this.assertChannelShortIds(settings, response.getChannelShortIds());
}
Also used : ScanMbusChannelsAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ScanMbusChannelsAsyncRequest) ScanMbusChannelsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ScanMbusChannelsResponse) Then(io.cucumber.java.en.Then)

Aggregations

ScanMbusChannelsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ScanMbusChannelsResponse)2 Then (io.cucumber.java.en.Then)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 MbusChannelShortEquipmentIdentifier (org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.MbusChannelShortEquipmentIdentifier)1 ScanMbusChannelsAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ScanMbusChannelsAsyncRequest)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