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