Search in sources :

Example 1 with GetAdministrativeStatusResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse 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 GetAdministrativeStatusResponse

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

the class SmartMeteringConfigurationEndpoint method retrieveGetAdministrativeStatusResponse.

@PayloadRoot(localPart = "GetAdministrativeStatusAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public GetAdministrativeStatusResponse retrieveGetAdministrativeStatusResponse(@RequestPayload final GetAdministrativeStatusAsyncRequest request) throws OsgpException {
    GetAdministrativeStatusResponse response = null;
    try {
        final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
        this.throwExceptionIfResultNotOk(responseData, "retrieving the administrative status");
        response = new GetAdministrativeStatusResponse();
        final AdministrativeStatusType dataRequest = this.configurationMapper.map(responseData.getMessageData(), AdministrativeStatusType.class);
        response.setEnabled(dataRequest);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : AdministrativeStatusType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AdministrativeStatusType) GetKeysResponseData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) GetAdministrativeStatusResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse) IOException(java.io.IOException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 3 with GetAdministrativeStatusResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse 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 GetAdministrativeStatusResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse 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

GetAdministrativeStatusResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse)4 Then (io.cucumber.java.en.Then)3 GetAdministrativeStatusAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncRequest)3 IOException (java.io.IOException)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 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 AdministrativeStatusType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AdministrativeStatusType)1 GetAdministrativeStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncResponse)1 GetAdministrativeStatusRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusRequest)1 GetKeysResponseData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData)1 Device (org.opensmartgridplatform.domain.core.entities.Device)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