Search in sources :

Example 1 with AddDeviceAsyncResponse

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);
}
Also used : AddDeviceRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceRequest) AddDeviceAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncResponse) When(io.cucumber.java.en.When)

Example 2 with AddDeviceAsyncResponse

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);
    }
}
Also used : AddDeviceAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncRequest) AddDeviceRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceRequest) AddDeviceAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncResponse) When(io.cucumber.java.en.When)

Example 3 with AddDeviceAsyncResponse

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);
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.valueobjects.DeviceModel) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) AddSmartMeterRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AddSmartMeterRequest) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) CoupleMbusDeviceByChannelAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceByChannelAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse) AddDeviceAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncResponse) DecoupleMbusDeviceByChannelAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.DecoupleMbusDeviceByChannelAsyncResponse) DecoupleMbusDeviceAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.DecoupleMbusDeviceAsyncResponse) CoupleMbusDeviceAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceAsyncResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

AddDeviceAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncResponse)3 When (io.cucumber.java.en.When)2 AddDeviceRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceRequest)2 ConstraintViolationException (javax.validation.ConstraintViolationException)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse)1 AddDeviceAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncRequest)1 CoupleMbusDeviceAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceAsyncResponse)1 CoupleMbusDeviceByChannelAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceByChannelAsyncResponse)1 DecoupleMbusDeviceAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.DecoupleMbusDeviceAsyncResponse)1 DecoupleMbusDeviceByChannelAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.DecoupleMbusDeviceByChannelAsyncResponse)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 DeviceModel (org.opensmartgridplatform.domain.core.valueobjects.DeviceModel)1 AddSmartMeterRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AddSmartMeterRequest)1 SmartMeteringDevice (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)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