use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncResponse in project open-smart-grid-platform by OSGP.
the class AddDeviceSteps method receivingASmartmeteringAddDeviceRequest.
@When("^receiving a smartmetering add device request$")
public void receivingASmartmeteringAddDeviceRequest(final Map<String, String> settings) throws Throwable {
final String deviceIdentification = settings.get(PlatformKeys.KEY_DEVICE_IDENTIFICATION);
ScenarioContext.current().put(PlatformKeys.KEY_DEVICE_IDENTIFICATION, deviceIdentification);
this.putKeyInScenarioContext(settings, PlatformKeys.KEY_DEVICE_MASTERKEY);
this.putKeyInScenarioContext(settings, PlatformKeys.KEY_DEVICE_AUTHENTICATIONKEY);
this.putKeyInScenarioContext(settings, PlatformKeys.KEY_DEVICE_ENCRYPTIONKEY);
this.putKeyInScenarioContext(settings, PlatformSmartmeteringKeys.MBUS_DEFAULT_KEY);
final AddDeviceRequest request = AddDeviceRequestFactory.fromParameterMap(settings);
final AddDeviceAsyncResponse asyncResponse = this.smartMeteringInstallationClient.addDevice(request);
this.checkAndSaveCorrelationId(asyncResponse.getCorrelationUid());
assertThat(asyncResponse.getDeviceIdentification()).as("Device identification in response").isEqualTo(deviceIdentification);
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncResponse in project open-smart-grid-platform by OSGP.
the class FunctionalExceptionsSteps method receivingASmartmeteringAddDeviceRequestWithAnInvalidDsmrVersion.
@When("^receiving a smartmetering add device request with an invalid DSMR version$")
public void receivingASmartmeteringAddDeviceRequestWithAnInvalidDsmrVersion(final Map<String, String> settings) throws Throwable {
final AddDeviceRequest request = AddDeviceRequestFactory.fromParameterMap(settings);
try {
final AddDeviceAsyncResponse asyncResponse = this.smartMeteringInstallationClient.addDevice(request);
final AddDeviceAsyncRequest addDeviceAsyncRequest = new AddDeviceAsyncRequest();
addDeviceAsyncRequest.setCorrelationUid(asyncResponse.getCorrelationUid());
addDeviceAsyncRequest.setDeviceIdentification(asyncResponse.getDeviceIdentification());
this.smartMeteringInstallationClient.getAddDeviceResponse(addDeviceAsyncRequest);
} catch (final Exception exception) {
ScenarioContext.current().put(PlatformKeys.RESPONSE, exception);
}
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringInstallationEndpoint method addDevice.
@PayloadRoot(localPart = "AddDeviceRequest", namespace = SMARTMETER_INSTALLATION_NAMESPACE)
@ResponsePayload
public AddDeviceAsyncResponse addDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final AddDeviceRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
log.info("Incoming AddDeviceRequest for meter: {}.", request.getDevice().getDeviceIdentification());
AsyncResponse asyncResponse = null;
try {
final SmartMeteringDevice device = this.installationMapper.map(request.getDevice(), SmartMeteringDevice.class);
final DeviceModel deviceModel = new DeviceModel(request.getDeviceModel().getManufacturer(), request.getDeviceModel().getModelCode(), "");
final AddSmartMeterRequest addSmartMeterRequest = new AddSmartMeterRequest(device, deviceModel);
final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(device.getDeviceIdentification()).withDeviceFunction(null).withMessageType(MessageType.ADD_METER).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, addSmartMeterRequest);
this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
} catch (final ConstraintViolationException e) {
log.error("Exception: {} while adding device: {} for organisation {}.", e.getMessage(), request.getDevice().getDeviceIdentification(), organisationIdentification, e);
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
} catch (final Exception e) {
log.error("Exception: {} while adding device: {} for organisation {}.", e.getMessage(), request.getDevice().getDeviceIdentification(), organisationIdentification, e);
this.handleException(e);
}
return this.installationMapper.map(asyncResponse, AddDeviceAsyncResponse.class);
}
Aggregations