use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetEventNotificationsAsyncResponse in project open-smart-grid-platform by OSGP.
the class SetEventNotificationsSteps method theSetEventNotificationAsyncResponseContains.
/**
* 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 event notification async response contains$")
public void theSetEventNotificationAsyncResponseContains(final Map<String, String> expectedResponseData) throws Throwable {
final SetEventNotificationsAsyncResponse asyncResponse = (SetEventNotificationsAsyncResponse) 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.core.devicemanagement.SetEventNotificationsAsyncResponse in project open-smart-grid-platform by OSGP.
the class DeviceManagementEndpoint method setEventNotifications.
@PayloadRoot(localPart = "SetEventNotificationsRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public SetEventNotificationsAsyncResponse setEventNotifications(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetEventNotificationsRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Set EventNotifications Request received from organisation: {} for event device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final SetEventNotificationsAsyncResponse response = new SetEventNotificationsAsyncResponse();
try {
final List<EventNotificationType> eventNotifications = new ArrayList<>(this.deviceManagementMapper.mapAsList(request.getEventNotifications(), EventNotificationType.class));
final String correlationUid = this.deviceManagementService.enqueueSetEventNotificationsRequest(organisationIdentification, request.getDeviceIdentification(), eventNotifications, 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;
}
Aggregations