use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncResponse in project open-smart-grid-platform by OSGP.
the class PublicLightingAdHocManagementEndpoint method setTransition.
// === SET TRANSITION ===
@PayloadRoot(localPart = "SetTransitionRequest", namespace = NAMESPACE)
@ResponsePayload
public SetTransitionAsyncResponse setTransition(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetTransitionRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Set Transition Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final SetTransitionAsyncResponse response = new SetTransitionAsyncResponse();
try {
final TransitionMessageDataContainer transitionMessageDataContainer = new TransitionMessageDataContainer();
if (request.getTransitionType() != null) {
transitionMessageDataContainer.setTransitionType(this.adHocManagementMapper.map(request.getTransitionType(), org.opensmartgridplatform.domain.core.valueobjects.TransitionType.class));
}
DateTime dateTime = null;
if (request.getTime() != null) {
dateTime = new DateTime(request.getTime().toGregorianCalendar().getTime());
}
transitionMessageDataContainer.setDateTime(dateTime);
final String correlationUid = this.adHocManagementService.enqueueTransitionRequest(organisationIdentification, request.getDeviceIdentification(), transitionMessageDataContainer, 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;
}
use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncResponse in project open-smart-grid-platform by OSGP.
the class SetTransitionSteps method theSetTransitionAsyncResponseContains.
/**
* 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.
* @throws Throwable
*/
@Then("^the set transition async response contains$")
public void theSetTransitionAsyncResponseContains(final Map<String, String> expectedResponseData) throws Throwable {
final SetTransitionAsyncResponse asyncResponse = (SetTransitionAsyncResponse) 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) + "]");
}
Aggregations