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())));
}
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);
}
}
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();
}
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;
}
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();
}
Aggregations