Search in sources :

Example 1 with SetRebootAsyncResponse

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

the class SetRebootSteps method theSetRebootAsyncResponseContains.

/**
 * 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 set reboot async response contains$")
public void theSetRebootAsyncResponseContains(final Map<String, String> expectedResponseData) {
    final SetRebootAsyncResponse asyncResponse = (SetRebootAsyncResponse) ScenarioContext.current().get(PlatformKeys.RESPONSE);
    assertThat(asyncResponse.getAsyncResponse().getCorrelationUid()).isNotNull();
    assertThat(asyncResponse.getAsyncResponse().getDeviceId()).isEqualTo(getString(expectedResponseData, PlatformKeys.KEY_DEVICE_IDENTIFICATION));
    // 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 : SetRebootAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncResponse) Then(io.cucumber.java.en.Then)

Example 2 with SetRebootAsyncResponse

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

the class AdHocManagementEndpoint method setReboot.

// === SET REBOOT ===
@PayloadRoot(localPart = "SetRebootRequest", namespace = NAMESPACE)
@ResponsePayload
public SetRebootAsyncResponse setReboot(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetRebootRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Set Reboot received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final SetRebootAsyncResponse response = new SetRebootAsyncResponse();
    try {
        final String correlationUid = this.adHocManagementService.enqueueSetRebootRequest(organisationIdentification, request.getDeviceIdentification(), MessagePriorityEnum.getMessagePriority(messagePriority));
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SetRebootAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncResponse) SetRebootAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

SetRebootAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncResponse)2 Then (io.cucumber.java.en.Then)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse)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