Change Datajob Status return value 84/140184/2
authoregernug <gerard.nugent@est.tech>
Tue, 11 Feb 2025 10:45:59 +0000 (10:45 +0000)
committeregernug <gerard.nugent@est.tech>
Wed, 12 Feb 2025 08:47:06 +0000 (08:47 +0000)
- 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>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy
integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy

index a177272..ccda476 100644 (file)
@@ -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()));
     }
 
index 4d47ef1..c968a32 100644 (file)
@@ -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.'() {
index 6e5c0e4..162b518 100644 (file)
@@ -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"}'
     }
 }