Search in sources :

Example 1 with FindScheduledTasksResponse

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);
    }
}
Also used : FindScheduledTasksResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse) FindScheduledTasksRequest(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksRequest) WebServiceSecurityException(org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException) When(io.cucumber.java.en.When)

Example 2 with FindScheduledTasksResponse

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;
}
Also used : FindScheduledTasksResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ScheduledTaskWithoutData(org.opensmartgridplatform.domain.core.entities.ScheduledTaskWithoutData) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 3 with FindScheduledTasksResponse

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();
    }
}
Also used : FindScheduledTasksResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse) Map(java.util.Map) Then(io.cucumber.java.en.Then)

Aggregations

FindScheduledTasksResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse)3 Then (io.cucumber.java.en.Then)1 When (io.cucumber.java.en.When)1 Map (java.util.Map)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 FindScheduledTasksRequest (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksRequest)1 ScheduledTaskWithoutData (org.opensmartgridplatform.domain.core.entities.ScheduledTaskWithoutData)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 WebServiceSecurityException (org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1