use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse in project open-smart-grid-platform by OSGP.
the class FindScheduledTasksSteps method whenReceivingAFindScheduledTasksRequests.
@When("receiving a find scheduled tasks request")
public void whenReceivingAFindScheduledTasksRequests() {
final FindScheduledTasksRequest request = new FindScheduledTasksRequest();
try {
final FindScheduledTasksResponse response = this.client.findScheduledTasks(request);
ScenarioContext.current().put(RESPONSE, response);
} catch (final WebServiceSecurityException e) {
ScenarioContext.current().put(RESPONSE, e);
}
}
use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse in project open-smart-grid-platform by OSGP.
the class DeviceManagementEndpoint method findScheduledTasks.
@PayloadRoot(localPart = "FindScheduledTasksRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public FindScheduledTasksResponse findScheduledTasks(@OrganisationIdentification final String organisationIdentification, @RequestPayload final FindScheduledTasksRequest request) throws OsgpException {
LOGGER.info("Finding scheduled tasks for organisation: {}.", organisationIdentification);
final FindScheduledTasksResponse response = new FindScheduledTasksResponse();
try {
final List<ScheduledTaskWithoutData> scheduledTasks;
if (request.getDeviceIdentification() == null) {
scheduledTasks = this.deviceManagementService.findScheduledTasks(organisationIdentification);
} else {
scheduledTasks = this.deviceManagementService.findScheduledTasks(organisationIdentification, request.getDeviceIdentification());
}
response.getScheduledTask().addAll(this.deviceManagementMapper.mapAsList(scheduledTasks, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.ScheduledTask.class));
} catch (final ConstraintViolationException e) {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse in project open-smart-grid-platform by OSGP.
the class FindScheduledTasksSteps method thenTheFindScheduledTasksResponseShouldContain.
@Then("the find scheduled tasks response should contain scheduled tasks")
public void thenTheFindScheduledTasksResponseShouldContain(final DataTable tasks) {
final FindScheduledTasksResponse response = (FindScheduledTasksResponse) ScenarioContext.current().get(RESPONSE);
final List<Map<String, String>> scheduledTasks = tasks.asMaps(String.class, String.class);
assertThat(response.getScheduledTask().size()).as("Lists of scheduled tasks have different sizes.").isEqualTo(scheduledTasks.size());
for (final Map<String, String> map : scheduledTasks) {
final boolean found = response.getScheduledTask().stream().anyMatch(hasOrganizationIdentification(map.get(KEY_ORGANIZATION_IDENTIFICATION)).and(hasDeviceIdentification(map.get(KEY_DEVICE_IDENTIFICATION))).and(hasMessageType(map.get(KEY_MESSAGE_TYPE))).and(hasScheduledTime(map.get(KEY_SCHEDULED_TIME))));
assertThat(found).as("No matching scheduled task found.").isTrue();
}
}
Aggregations