aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoregernug <gerard.nugent@est.tech>2025-02-11 10:45:59 +0000
committeregernug <gerard.nugent@est.tech>2025-02-12 08:47:06 +0000
commit743b2b01ddf44aca499ade1ac5a8fccf80ce3b5e (patch)
treed28683f9c0dd4d114b7e4bd2b6c30400593b0b73
parent4f72ab6fe7d81a350616bb54e195b19c63a898e7 (diff)
Change Datajob Status return value
- Change to return entire JSON object instead of status string Issue-ID: CPS-2613 Change-Id: I63d8a9d078f003fc06e301bf9921f7942b3603ab Signed-off-by: egernug <gerard.nugent@est.tech>
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy9
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy2
3 files changed, 8 insertions, 10 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java
index a177272dff..ccda476081 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2024 Nordix Foundation
+ * Copyright (C) 2021-2025 Nordix Foundation
* Modifications Copyright (C) 2022 Bell Canada
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -150,7 +150,7 @@ public class DmiRestClient {
*
* @param urlTemplateParameters The URL template parameters for the DMI data job status endpoint.
* @param authorization The authorization token to be added to the request headers.
- * @return A Mono emitting the status of the data job as a String.
+ * @return A Mono emitting the status of the data job in JSON format.
* @throws DmiClientRequestException If there is an error during the DMI request.
*/
public Mono<String> getDataJobStatus(final UrlTemplateParameters urlTemplateParameters,
@@ -160,8 +160,7 @@ public class DmiRestClient {
.uri(urlTemplateParameters.urlTemplate(), urlTemplateParameters.urlVariables())
.headers(httpHeaders -> configureHttpHeaders(httpHeaders, authorization))
.retrieve()
- .bodyToMono(JsonNode.class)
- .map(jsonNode -> jsonNode.path("status").asText())
+ .bodyToMono(String.class)
.onErrorMap(throwable -> handleDmiClientException(throwable, OperationType.READ.getOperationName()));
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy
index 4d47ef14a0..c968a32b3c 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2024 Nordix Foundation
+ * Copyright (C) 2021-2025 Nordix Foundation
* Modifications Copyright (C) 2022 Bell Canada
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -168,13 +168,12 @@ class DmiRestClientSpec extends Specification {
def 'DMI GET Operation for DMI Data Service '() {
given: 'the Data web client returns a valid response entity for the expected parameters'
mockDataServicesWebClient.get() >> mockRequestBody
- def jsonNode = jsonObjectMapper.convertJsonString('{"status":"some status"}', JsonNode.class)
- ((ObjectNode) jsonNode).put('status', 'some status')
- mockResponse.bodyToMono(JsonNode.class) >> Mono.just(jsonNode)
+ def result = '{"status":"some status"}'
+ mockResponse.bodyToMono(String.class) >> Mono.just(result)
when: 'GET operation is invoked for Data Service'
def response = objectUnderTest.getDataJobStatus(urlTemplateParameters, NO_AUTH_HEADER).block()
then: 'the response equals to the expected value'
- assert response == 'some status'
+ assert response == '{"status":"some status"}'
}
def 'Get data job result from DMI.'() {
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy
index 6e5c0e40c2..162b51844c 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy
@@ -18,6 +18,6 @@ class DataJobStatusServiceSpec extends CpsIntegrationSpecBase {
when: 'the data job status checked'
def result = dataJobStatusService.getDataJobStatus(authorization, dmiServiceName, dataProducerId, dataProducerJobId)
then: 'the status is that defined in the mock service.'
- assert result == 'status details from mock service'
+ assert result == '{"status":"status details from mock service"}'
}
}