Search in sources :

Example 1 with UpdateDeviceCdmaSettingsAsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse in project open-smart-grid-platform by OSGP.

the class UpdateDeviceCdmaSettingsSteps method receiveAnUpdateDeviceCdmaSettingsRequest.

@When("^an update device CDMA settings request is received$")
public void receiveAnUpdateDeviceCdmaSettingsRequest(final Map<String, String> requestParameters) throws Throwable {
    final String deviceIdentification = getString(requestParameters, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION);
    final String mastSegment = getString(requestParameters, PlatformKeys.KEY_CDMA_MAST_SEGMENT);
    final Short batchNumber = getShort(requestParameters, PlatformKeys.KEY_CDMA_BATCH_NUMBER);
    LOGGER.info("WHEN: Receive UpdateDeviceCdmaSettingsRequest [deviceIdentification={}, mastSegment={}, batchNumber={}]", deviceIdentification, mastSegment, batchNumber);
    final UpdateDeviceCdmaSettingsRequest request = new UpdateDeviceCdmaSettingsRequest();
    request.setDeviceIdentification(deviceIdentification);
    if (!StringUtils.isBlank(mastSegment)) {
        request.setMastSegment(mastSegment);
    }
    if (batchNumber != null) {
        request.setBatchNumber(batchNumber);
    }
    final UpdateDeviceCdmaSettingsAsyncResponse asyncResponse = this.client.updateDeviceCdmaSettings(request);
    ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, asyncResponse.getCorrelationUid());
    ScenarioContext.current().put(PlatformKeys.KEY_DEVICE_IDENTIFICATION, asyncResponse.getDeviceId());
}
Also used : UpdateDeviceCdmaSettingsRequest(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsRequest) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) UpdateDeviceCdmaSettingsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse) ReadSettingsHelper.getShort(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getShort) When(io.cucumber.java.en.When)

Example 2 with UpdateDeviceCdmaSettingsAsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse in project open-smart-grid-platform by OSGP.

the class DeviceManagementEndpoint method updateDeviceCdmaSettingsRequest.

@PayloadRoot(localPart = "UpdateDeviceCdmaSettingsRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public UpdateDeviceCdmaSettingsAsyncResponse updateDeviceCdmaSettingsRequest(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateDeviceCdmaSettingsRequest request) throws OsgpException {
    LOGGER.info("UpdateDeviceCdmaSettingsRequest received for device: {} and organisation: {}.", request.getDeviceIdentification(), organisationIdentification);
    final UpdateDeviceCdmaSettingsAsyncResponse asyncResponse = new UpdateDeviceCdmaSettingsAsyncResponse();
    try {
        final CdmaSettings cdmaSettings = new CdmaSettings(request.getMastSegment(), request.getBatchNumber());
        final String correlationUid = this.deviceManagementService.enqueueUpdateDeviceCdmaSettingsRequest(organisationIdentification, request.getDeviceIdentification(), cdmaSettings);
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
    } catch (final Exception e) {
        this.handleException(e);
    }
    return asyncResponse;
}
Also used : UpdateDeviceCdmaSettingsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse) CdmaSettings(org.opensmartgridplatform.domain.core.valueobjects.CdmaSettings) 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

UpdateDeviceCdmaSettingsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse)2 When (io.cucumber.java.en.When)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 UpdateDeviceCdmaSettingsRequest (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsRequest)1 ReadSettingsHelper.getShort (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getShort)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 CdmaSettings (org.opensmartgridplatform.domain.core.valueobjects.CdmaSettings)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