use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse in project open-smart-grid-platform by OSGP.
the class SetLightSteps method theSetLightResponseContains.
/**
* 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 light async response contains$")
public void theSetLightResponseContains(final Map<String, String> expectedResponseData) {
final SetLightAsyncResponse asyncResponse = (SetLightAsyncResponse) 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) + "]");
}
use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse in project open-smart-grid-platform by OSGP.
the class OsgpPublicLightingClientSoapService method setLightRequest.
/**
* Creates a WebServiceTemplate and a SetLightRequest with the parameters deviceId, dimValue and
* LightOn. Sends the SetLightRequest to the platform using the WebServiceTemplate. Returns the
* response (CorrelationId) from the Platform.
*
* @return correlation id
*/
public String setLightRequest(final String deviceId, final int dimValue, final boolean lightOn) {
final SetLightRequest request = new SetLightRequest();
final LightValue lightValue = new LightValue();
lightValue.setDimValue(dimValue);
lightValue.setOn(lightOn);
final WebServiceTemplate template = this.soapRequestHelper.createPublicLightingRequest();
request.setDeviceIdentification(deviceId);
request.getLightValue().add(lightValue);
final SetLightAsyncResponse response = (SetLightAsyncResponse) template.marshalSendAndReceive(request);
return response.getAsyncResponse().getCorrelationUid();
}
use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse in project open-smart-grid-platform by OSGP.
the class PublicLightingAdHocManagementEndpoint method setLight.
// === SET LIGHT ===
@PayloadRoot(localPart = "SetLightRequest", namespace = NAMESPACE)
@ResponsePayload
public SetLightAsyncResponse setLight(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetLightRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Set Light Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final SetLightAsyncResponse response = new SetLightAsyncResponse();
try {
final List<LightValue> lightValues = new ArrayList<>(this.adHocManagementMapper.mapAsList(request.getLightValue(), LightValue.class));
final String correlationUid = this.adHocManagementService.enqueueSetLightRequest(organisationIdentification, request.getDeviceIdentification(), lightValues, MessagePriorityEnum.getMessagePriority(messagePriority));
final AsyncResponse asyncResponse = new AsyncResponse();
asyncResponse.setCorrelationUid(correlationUid);
asyncResponse.setDeviceId(request.getDeviceIdentification());
response.setAsyncResponse(asyncResponse);
} catch (final ConstraintViolationException e) {
LOGGER.error(EXCEPTION_OCCURRED, e);
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, COMPONENT_WS_PUBLIC_LIGHTING, new ValidationException(e.getConstraintViolations()));
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse in project open-smart-grid-platform by OSGP.
the class OsgpPublicLightingClientSoapService method switchLightRequest.
/**
* Creates a SetLight request using the parameters deviceId and lightOn. Sends the request to the
* platform using the WebServiceTemplate.
*
* <p>Returns the CorrelationId response from the Platform.
*/
public String switchLightRequest(final String deviceId, final boolean lightOn) {
final SetLightRequest request = new SetLightRequest();
final LightValue lightValue = new LightValue();
lightValue.setOn(lightOn);
final WebServiceTemplate template = this.soapRequestHelper.createPublicLightingRequest();
request.setDeviceIdentification(deviceId);
request.getLightValue().add(lightValue);
final SetLightAsyncResponse response = (SetLightAsyncResponse) template.marshalSendAndReceive(request);
return response.getAsyncResponse().getCorrelationUid();
}
Aggregations