Search in sources :

Example 1 with FindAllOrganisationsResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindAllOrganisationsResponse in project open-smart-grid-platform by OSGP.

the class FindOrganizationsSteps method theGetAllOrganizationsResponseContains.

@Then("^the get all organizations response contains$")
public void theGetAllOrganizationsResponseContains(final Map<String, String> expectedResult) {
    final FindAllOrganisationsResponse response = (FindAllOrganisationsResponse) ScenarioContext.current().get(PlatformCommonKeys.RESPONSE);
    final List<Organisation> organisations = response.getOrganisations();
    final Organisation expected = this.createOrganisation(expectedResult);
    for (final Organisation organisation : organisations) {
        if (this.organisationMatches(expected, organisation)) {
            return;
        }
    }
    Assertions.fail("Expected organization \"" + expected.getOrganisationIdentification() + "\" was not found as one of the " + organisations.size() + " organizations in the response");
}
Also used : Organisation(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Organisation) FindAllOrganisationsResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindAllOrganisationsResponse) Then(io.cucumber.java.en.Then)

Example 2 with FindAllOrganisationsResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindAllOrganisationsResponse in project open-smart-grid-platform by OSGP.

the class DeviceManagementEndpoint method findAllOrganisations.

@PayloadRoot(localPart = "FindAllOrganisationsRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public FindAllOrganisationsResponse findAllOrganisations(@OrganisationIdentification final String organisationIdentification, @RequestPayload final FindAllOrganisationsRequest request) throws OsgpException {
    LOGGER.info("Find all organisations for organisation: {}.", organisationIdentification);
    final FindAllOrganisationsResponse response = new FindAllOrganisationsResponse();
    try {
        final List<Organisation> organisations = this.deviceManagementService.findAllOrganisations(organisationIdentification);
        response.getOrganisations().addAll(this.deviceManagementMapper.mapAsList(organisations, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Organisation.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 : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) FindAllOrganisationsResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindAllOrganisationsResponse) 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 FindAllOrganisationsResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindAllOrganisationsResponse in project open-smart-grid-platform by OSGP.

the class FindOrganizationsSteps method theGetAllOrganizationsResponseContainsOrganization.

@Then("^the get all organizations response contains (\\d++) organizations?$")
public void theGetAllOrganizationsResponseContainsOrganization(final Integer expectedCount) {
    final FindAllOrganisationsResponse response = (FindAllOrganisationsResponse) ScenarioContext.current().get(PlatformCommonKeys.RESPONSE);
    assertThat(response.getOrganisations().size()).isEqualTo((int) expectedCount);
}
Also used : FindAllOrganisationsResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindAllOrganisationsResponse) Then(io.cucumber.java.en.Then)

Aggregations

FindAllOrganisationsResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindAllOrganisationsResponse)3 Then (io.cucumber.java.en.Then)2 ConstraintViolationException (javax.validation.ConstraintViolationException)1 Organisation (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Organisation)1 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1