use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncResponse in project open-smart-grid-platform by OSGP.
the class ResumeScheduleSteps method theResumeScheduleAsyncResponseContains.
/**
* 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 resume schedule async response contains$")
public void theResumeScheduleAsyncResponseContains(final Map<String, String> expectedResponseData) throws Throwable {
final ResumeScheduleAsyncResponse asyncResponse = (ResumeScheduleAsyncResponse) 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) + "]");
}
use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncResponse in project open-smart-grid-platform by OSGP.
the class PublicLightingAdHocManagementEndpoint method resumeSchedule.
// === RESUME SCHEDULE ===
@PayloadRoot(localPart = "ResumeScheduleRequest", namespace = NAMESPACE)
@ResponsePayload
public ResumeScheduleAsyncResponse resumeSchedule(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ResumeScheduleRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Resume Schedule Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final ResumeScheduleAsyncResponse response = new ResumeScheduleAsyncResponse();
try {
final ResumeScheduleData resumeScheduleData = new ResumeScheduleData();
if (request.getIndex() != null) {
resumeScheduleData.setIndex(request.getIndex());
}
resumeScheduleData.setIsImmediate(request.isIsImmediate());
final String correlationUid = this.adHocManagementService.enqueueResumeScheduleRequest(organisationIdentification, request.getDeviceIdentification(), resumeScheduleData, 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;
}
Aggregations