Search in sources :

Example 1 with GetStatusAsyncResponse

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

the class GetStatusSteps method theGetStatusAsyncResponseContains.

/**
 * 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 status async response contains$")
public void theGetStatusAsyncResponseContains(final Map<String, String> expectedResponseData) {
    final GetStatusAsyncResponse asyncResponse = (GetStatusAsyncResponse) ScenarioContext.current().get(PlatformPubliclightingKeys.RESPONSE);
    assertThat(asyncResponse.getAsyncResponse().getCorrelationUid()).isNotNull();
    assertThat(asyncResponse.getAsyncResponse().getDeviceId()).isEqualTo(getString(expectedResponseData, PlatformPubliclightingKeys.KEY_DEVICE_IDENTIFICATION));
    // Save the returned CorrelationUid in the Scenario related context for
    // further use.
    saveCorrelationUidInScenarioContext(asyncResponse.getAsyncResponse().getCorrelationUid(), getString(expectedResponseData, PlatformPubliclightingKeys.KEY_ORGANIZATION_IDENTIFICATION, PlatformPubliclightingDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION));
    LOGGER.info("Got CorrelationUid: [" + ScenarioContext.current().get(PlatformPubliclightingKeys.KEY_CORRELATION_UID) + "]");
}
Also used : GetStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncResponse) Then(io.cucumber.java.en.Then)

Example 2 with GetStatusAsyncResponse

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

the class OsgpPublicLightingClientSoapService method getDeviceStatus.

/**
 * Creates a getDeviceStatus request with the parameter deviceId. Sends it to the Platform using a
 * WebServiceTemplate.
 *
 * <p>Returns the CorrelationId response from the platform.
 */
public String getDeviceStatus(final String deviceId) {
    final WebServiceTemplate requestTemplate = this.soapRequestHelper.createPublicLightingRequest();
    final GetStatusRequest request = new GetStatusRequest();
    request.setDeviceIdentification(deviceId);
    GetStatusAsyncResponse asyncStatusResponse = null;
    asyncStatusResponse = (GetStatusAsyncResponse) requestTemplate.marshalSendAndReceive(request);
    return asyncStatusResponse.getAsyncResponse().getCorrelationUid();
}
Also used : GetStatusRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusRequest) GetStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncResponse) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate)

Example 3 with GetStatusAsyncResponse

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

the class PublicLightingAdHocManagementEndpoint method getStatus.

// === GET STATUS ===
@PayloadRoot(localPart = "GetStatusRequest", namespace = NAMESPACE)
@ResponsePayload
public GetStatusAsyncResponse getStatus(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetStatusRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Get Status received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final GetStatusAsyncResponse response = new GetStatusAsyncResponse();
    try {
        final String correlationUid = this.adHocManagementService.enqueueGetStatusRequest(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 : GetStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncResponse) SetLightAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse) ResumeScheduleAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncResponse) GetStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncResponse) SetTransitionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) 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

GetStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncResponse)3 Then (io.cucumber.java.en.Then)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 GetStatusRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusRequest)1 ResumeScheduleAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncResponse)1 SetLightAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse)1 SetTransitionAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncResponse)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncResponse)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1