use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponse in project open-smart-grid-platform by OSGP.
the class GetKeys method theGetKeysResponseIsReturned.
@Then("^the get keys response should return the requested keys$")
public void theGetKeysResponseIsReturned(final Map<String, String> expectedValues) throws Throwable {
final GetKeysAsyncRequest asyncRequest = GetKeysRequestFactory.fromScenarioContext();
final GetKeysResponse response = this.smartMeteringConfigurationClient.retrieveGetKeysResponse(asyncRequest);
assertThat(response).isNotNull();
assertThat(response.getResult()).as(OPERATION + ", Checking result:").isEqualTo(OsgpResultType.OK);
final List<GetKeysResponseData> responseDataList = response.getGetKeysResponseData();
assertThat(responseDataList).noneMatch(getKeysResponseData -> ArrayUtils.isEmpty(getKeysResponseData.getSecretValue()));
final List<SecretType> secretTypesInResponse = responseDataList.stream().map(GetKeysResponseData::getSecretType).collect(Collectors.toList());
final List<SecretType> expectedSecretTypes = getSecretTypesFromParameterMap(expectedValues);
assertThat(secretTypesInResponse).containsExactlyInAnyOrderElementsOf(expectedSecretTypes);
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringConfigurationEndpoint method getGetKeysResponse.
@PayloadRoot(localPart = "GetKeysAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public GetKeysResponse getGetKeysResponse(@RequestPayload final GetKeysAsyncRequest request) throws OsgpException {
GetKeysResponse response = null;
try {
response = new GetKeysResponse();
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
this.throwExceptionIfResultNotOk(responseData, "getting keys");
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
if (responseData.getMessageData() != null) {
final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponse getKeysResponse = (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponse) responseData.getMessageData();
final List<GetKeysResponseData> keysEncryptedWithGxfKey = this.configurationMapper.mapAsList(getKeysResponse.getKeys(), GetKeysResponseData.class);
final List<GetKeysResponseData> keysEncryptedForApplication = this.reencryptKeysInGetKeysResponse(keysEncryptedWithGxfKey, responseData.getOrganisationIdentification());
response.getGetKeysResponseData().addAll(keysEncryptedForApplication);
} else {
log.info("Get keys response is null");
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations