Search in sources :

Example 1 with GetOutagesResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetOutagesResponse in project open-smart-grid-platform by OSGP.

the class BundledGetOutagesSteps method theBundleResponseShouldContainAGetOutagesResponseWithValues.

@Then("^the bundle response should contain a get outages response with (\\d++) outages$")
public void theBundleResponseShouldContainAGetOutagesResponseWithValues(final int numberOfEvents, final Map<String, String> expectedValues) throws Throwable {
    final Response response = this.getNextBundleResponse();
    assertThat(response instanceof GetOutagesResponse).isTrue();
    final GetOutagesResponse outagesResponse = (GetOutagesResponse) response;
    final List<Outage> outages = outagesResponse.getOutages();
    assertThat(outages.size()).isEqualTo(numberOfEvents);
    final Map<String, String> values = outages.stream().collect(Collectors.toMap(o -> o.getEndTime().toString(), o -> o.getDuration().toString()));
    assertThat(values).containsExactlyInAnyOrderEntriesOf(expectedValues);
}
Also used : Response(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response) GetOutagesResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetOutagesResponse) List(java.util.List) Then(io.cucumber.java.en.Then) Given(io.cucumber.java.en.Given) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Map(java.util.Map) Response(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response) Outage(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.Outage) Collectors(java.util.stream.Collectors) GetOutagesRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetOutagesRequest) GetOutagesResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetOutagesResponse) Outage(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.Outage) GetOutagesResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetOutagesResponse) Then(io.cucumber.java.en.Then)

Aggregations

Given (io.cucumber.java.en.Given)1 Then (io.cucumber.java.en.Then)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 GetOutagesRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetOutagesRequest)1 GetOutagesResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetOutagesResponse)1 Response (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response)1 Outage (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.Outage)1