Search in sources :

Example 1 with GetFirmwareVersionAsyncResponse

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

the class GetFirmwareVersionSteps method theGetFirmwareVersionResponseContains.

/**
 * The check for the response from the Platform.
 *
 * @param expectedResponseData The table with the expected fields in the response.
 * @apiNote The response will contain the correlation uid, so store that in the current scenario
 *     context for later use.
 */
@Then("^the get firmware version async response contains$")
public void theGetFirmwareVersionResponseContains(final Map<String, String> expectedResponseData) {
    final GetFirmwareVersionAsyncResponse asyncResponse = (GetFirmwareVersionAsyncResponse) ScenarioContext.current().get(PlatformKeys.RESPONSE);
    assertThat(asyncResponse.getAsyncResponse().getDeviceId()).isEqualTo(getString(expectedResponseData, PlatformKeys.KEY_DEVICE_IDENTIFICATION));
    assertThat(asyncResponse.getAsyncResponse().getCorrelationUid()).isNotNull();
    // Save the returned CorrelationUid in the Scenario related context for
    // further use.
    saveCorrelationUidInScenarioContext(asyncResponse.getAsyncResponse().getCorrelationUid(), getString(expectedResponseData, PlatformKeys.KEY_ORGANIZATION_IDENTIFICATION, PlatformDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION));
    LOGGER.info("Got CorrelationUid: [" + ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID) + "]");
}
Also used : GetFirmwareVersionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionAsyncResponse) Then(io.cucumber.java.en.Then)

Example 2 with GetFirmwareVersionAsyncResponse

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

the class FirmwareManagementEndpoint method getFirmwareVersion.

// === GET FIRMWARE VERSION ===
@PayloadRoot(localPart = "GetFirmwareVersionRequest", namespace = NAMESPACE)
@ResponsePayload
public GetFirmwareVersionAsyncResponse getFirmwareVersion(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetFirmwareVersionRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("GetFirmwareVersion Request received from organisation {} for device {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final GetFirmwareVersionAsyncResponse response = new GetFirmwareVersionAsyncResponse();
    try {
        final AsyncResponse asyncResponse = new AsyncResponse();
        final String correlationUid = this.firmwareManagementService.enqueueGetFirmwareRequest(organisationIdentification, request.getDeviceIdentification(), MessagePriorityEnum.getMessagePriority(messagePriority));
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final ConstraintViolationException e) {
        LOGGER.error("Exception getting firmware version", e);
        this.handleException(e);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : GetFirmwareVersionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionAsyncResponse) ConstraintViolationException(javax.validation.ConstraintViolationException) SwitchFirmwareAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.SwitchFirmwareAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) GetFirmwareVersionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionAsyncResponse) UpdateFirmwareAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.UpdateFirmwareAsyncResponse) 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

GetFirmwareVersionAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionAsyncResponse)2 Then (io.cucumber.java.en.Then)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse)1 SwitchFirmwareAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.SwitchFirmwareAsyncResponse)1 UpdateFirmwareAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.UpdateFirmwareAsyncResponse)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