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;
}
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());
}
Aggregations