Search in sources :

Example 1 with GetAdministrativeStatusAsyncRequest

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

the class GetAdministrativeStatus method theAdministrativeStatusShouldBeReturnedForDevices.

@Then("^the administrative status should be returned for devices$")
public void theAdministrativeStatusShouldBeReturnedForDevices(final List<String> deviceIdentifications) throws Throwable {
    @SuppressWarnings("unchecked") final Map<String, String> correlationUidMap = (Map<String, String>) ScenarioContext.current().get(CORRELATION_UID_BY_DEVICE_IDENTIFICATION);
    final CountDownLatch responseCountDownLatch = new CountDownLatch(deviceIdentifications.size());
    final List<String> responseNotifications = Collections.synchronizedList(new ArrayList<>());
    for (final String deviceIdentification : deviceIdentifications) {
        new Thread(() -> {
            final GetAdministrativeStatusAsyncRequest getAdministrativeStatusAsyncRequest;
            synchronized (correlationUidMap) {
                ScenarioContext.current().put(PlatformKeys.KEY_DEVICE_IDENTIFICATION, deviceIdentification);
                ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, Objects.requireNonNull(correlationUidMap.get(deviceIdentification), "Correlation UID for request with device identification " + deviceIdentification + " must be available"));
                getAdministrativeStatusAsyncRequest = GetAdministrativeStatusRequestFactory.fromScenarioContext();
            }
            try {
                final GetAdministrativeStatusResponse getAdministrativeStatusResponse = GetAdministrativeStatus.this.smartMeteringConfigurationClient.retrieveGetAdministrativeStatusResponse(getAdministrativeStatusAsyncRequest);
                final Instant receivedAt = Instant.now();
                responseNotifications.add(String.format("%s - administrative status %s for device %s", receivedAt, getAdministrativeStatusResponse.getEnabled(), deviceIdentification));
            } catch (final WebServiceSecurityException e) {
                e.printStackTrace();
            } finally {
                responseCountDownLatch.countDown();
            }
        }).start();
    }
    responseCountDownLatch.await();
    LOGGER.info("Received administrative status responses:{}", responseNotifications.stream().sorted().collect(Collectors.joining(System.lineSeparator() + " - ", System.lineSeparator() + " - ", System.lineSeparator())));
}
Also used : Instant(org.joda.time.Instant) CountDownLatch(java.util.concurrent.CountDownLatch) HashMap(java.util.HashMap) Map(java.util.Map) GetAdministrativeStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncRequest) GetAdministrativeStatusResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse) WebServiceSecurityException(org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException) Then(io.cucumber.java.en.Then)

Example 2 with GetAdministrativeStatusAsyncRequest

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

the class FunctionalExceptionsSteps method theGetAdministrativeStatusRequestGeneratingAnErrorIsReceived.

@When("^the get administrative status request generating an error is received$")
public void theGetAdministrativeStatusRequestGeneratingAnErrorIsReceived(final Map<String, String> settings) throws Throwable {
    this.getAdministrativeStatus.theRetrieveAdministrativeStatusRequestIsReceived(settings);
    final GetAdministrativeStatusAsyncRequest getAdministrativeStatusAsyncRequest = GetAdministrativeStatusRequestFactory.fromScenarioContext();
    if (this.useLongWaitTime) {
        this.smartMeteringConfigurationClient.setWaitFailMillis(LONG_WAIT_TIME);
    }
    try {
        this.smartMeteringConfigurationClient.retrieveGetAdministrativeStatusResponse(getAdministrativeStatusAsyncRequest);
    } catch (final Exception exception) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, exception);
    }
}
Also used : GetAdministrativeStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncRequest) When(io.cucumber.java.en.When)

Example 3 with GetAdministrativeStatusAsyncRequest

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

the class AddDeviceSteps method aRequestToTheDeviceCanBePerformedAfterActivation.

@Then("^a request to the device can be performed after activation$")
public void aRequestToTheDeviceCanBePerformedAfterActivation() throws Throwable {
    final Device device = this.activateDevice();
    /*
     * Fire any request that causes communication to the device, and check
     * that the actual response is not an error.
     */
    final GetAdministrativeStatusRequest request = new GetAdministrativeStatusRequest();
    request.setDeviceIdentification(device.getDeviceIdentification());
    final GetAdministrativeStatusAsyncResponse getAdministrativeStatusAsyncResponse = this.smartMeteringConfigurationClient.getAdministrativeStatus(request);
    final GetAdministrativeStatusAsyncRequest asyncRequest = new GetAdministrativeStatusAsyncRequest();
    asyncRequest.setCorrelationUid(getAdministrativeStatusAsyncResponse.getCorrelationUid());
    asyncRequest.setDeviceIdentification(device.getDeviceIdentification());
    final GetAdministrativeStatusResponse getAdministrativeStatusResponse = this.smartMeteringConfigurationClient.retrieveGetAdministrativeStatusResponse(asyncRequest);
    assertThat(getAdministrativeStatusResponse.getEnabled()).as("Administrative status should contain information if it is enabled").isNotNull();
}
Also used : GetAdministrativeStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncResponse) Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) GetAdministrativeStatusRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusRequest) GetAdministrativeStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncRequest) GetAdministrativeStatusResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse) Then(io.cucumber.java.en.Then)

Example 4 with GetAdministrativeStatusAsyncRequest

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

the class GetAdministrativeStatusRequestFactory method fromScenarioContext.

public static GetAdministrativeStatusAsyncRequest fromScenarioContext() {
    final GetAdministrativeStatusAsyncRequest getAdministrativeStatusAsyncRequest = new GetAdministrativeStatusAsyncRequest();
    getAdministrativeStatusAsyncRequest.setCorrelationUid(RequestFactoryHelper.getCorrelationUidFromScenarioContext());
    getAdministrativeStatusAsyncRequest.setDeviceIdentification(RequestFactoryHelper.getDeviceIdentificationFromScenarioContext());
    return getAdministrativeStatusAsyncRequest;
}
Also used : GetAdministrativeStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncRequest)

Example 5 with GetAdministrativeStatusAsyncRequest

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

the class GetAdministrativeStatus method theAdministrativeStatusShouldBeReturned.

@Then("^the administrative status should be returned$")
public void theAdministrativeStatusShouldBeReturned(final Map<String, String> settings) throws Throwable {
    final GetAdministrativeStatusAsyncRequest getAdministrativeStatusAsyncRequest = GetAdministrativeStatusRequestFactory.fromScenarioContext();
    final GetAdministrativeStatusResponse getAdministrativeStatusResponse = this.smartMeteringConfigurationClient.retrieveGetAdministrativeStatusResponse(getAdministrativeStatusAsyncRequest);
    LOGGER.info("The administrative status is: {}", getAdministrativeStatusResponse.getEnabled());
    assertThat(getAdministrativeStatusResponse.getEnabled()).as("Administrative status type is null").isNotNull();
}
Also used : GetAdministrativeStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncRequest) GetAdministrativeStatusResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse) Then(io.cucumber.java.en.Then)

Aggregations

GetAdministrativeStatusAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncRequest)5 Then (io.cucumber.java.en.Then)3 GetAdministrativeStatusResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse)3 When (io.cucumber.java.en.When)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Instant (org.joda.time.Instant)1 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)1 GetAdministrativeStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncResponse)1 GetAdministrativeStatusRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusRequest)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 WebServiceSecurityException (org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException)1