summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Anjella Macabuhay <lee.anjella.macabuhay@est.tech>2025-01-29 15:59:30 +0000
committerGerrit Code Review <gerrit@onap.org>2025-01-29 15:59:30 +0000
commit3dcceca0fb4db5d794ecbd86d1653c16eaf721bc (patch)
tree290468b95efb7cf0c95e9fd046b3cfb651e7ed58
parenta6a90c010bbfd80304b6d443912affa5fe850bf4 (diff)
parent4f72ab6fe7d81a350616bb54e195b19c63a898e7 (diff)
Merge "Add "dataProducerId" and "dmiServiceName" values to SubJobWriteResponse in sendRequestsToDmi method"
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java9
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandlerSpec.groovy5
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy2
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy4
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/WriteSubJobSpec.groovy8
5 files changed, 16 insertions, 12 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java
index a118d53e7e..d74863a710 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,8 +79,11 @@ public class DmiSubJobRequestHandler {
jsonObjectMapper.asJsonString(subJobWriteRequest),
OperationType.CREATE,
authorization);
- final SubJobWriteResponse subJobWriteResponse = jsonObjectMapper
- .convertToValueType(responseEntity.getBody(), SubJobWriteResponse.class);
+ final Map<String, String> responseAsKeyValuePairs = jsonObjectMapper
+ .convertToValueType(responseEntity.getBody(), Map.class);
+ final String subJobId = responseAsKeyValuePairs.get("subJobId");
+ final SubJobWriteResponse subJobWriteResponse = new SubJobWriteResponse(subJobId,
+ producerKey.dmiServiceName(), producerKey.dataProducerIdentifier());
log.debug("Sub job write response: {}", subJobWriteResponse);
subJobWriteResponses.add(subJobWriteResponse);
});
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandlerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandlerSpec.groovy
index 041fbd95ee..93362f23be 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandlerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandlerSpec.groovy
@@ -29,12 +29,13 @@ class DmiSubJobRequestHandlerSpec extends Specification {
def dmiWriteOperationsPerProducerKey = [new ProducerKey('dmi1', 'prod1'): [dmiWriteOperation]]
def authorization = 'my authorization header'
and: 'the dmi rest client will return a response (for the correct parameters)'
- def responseEntity = new ResponseEntity<>(new SubJobWriteResponse('my-sub-job-id', 'dmi1', 'prod1'), HttpStatus.OK)
+ def responseAsKeyValuePairs = [subJobId:'my-sub-job-id']
+ def responseEntity = new ResponseEntity<>(responseAsKeyValuePairs, HttpStatus.OK)
def expectedJson = '{"destination":"d1","dataAcceptType":"t1","dataContentType":"t2","dataProducerId":"prod1","dataJobId":"some-job-id","data":[{"path":"p","op":"operation","moduleSetTag":"tag","value":null,"operationId":"o1","privateProperties":{}}]}'
mockDmiRestClient.synchronousPostOperationWithJsonData(RequiredDmiService.DATA, _, expectedJson, OperationType.CREATE, authorization) >> responseEntity
when: 'sending request to DMI invoked'
objectUnderTest.sendRequestsToDmi(authorization, dataJobId, dataJobMetadata, dmiWriteOperationsPerProducerKey)
then: 'the result contains the expected sub-job id'
- assert responseEntity.body.subJobId == 'my-sub-job-id'
+ assert responseEntity.body.get('subJobId') == 'my-sub-job-id'
}
}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
index 75cb3cd7a2..3f7b25d2fa 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
@@ -261,7 +261,7 @@ abstract class CpsIntegrationSpecBase extends Specification {
}
def registerCmHandleWithoutWaitForReady(dmiPlugin, cmHandleId, moduleSetTag, alternateId) {
- def cmHandleToCreate = new NcmpServiceCmHandle(cmHandleId: cmHandleId, moduleSetTag: moduleSetTag, alternateId: alternateId)
+ def cmHandleToCreate = new NcmpServiceCmHandle(cmHandleId: cmHandleId, moduleSetTag: moduleSetTag, alternateId: alternateId, dataProducerIdentifier: 'some data producer id')
networkCmProxyInventoryFacade.updateDmiRegistration(new DmiPluginRegistration(dmiPlugin: dmiPlugin, createdCmHandles: [cmHandleToCreate]))
}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy
index 35a7b6a7c2..c790521627 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ class DmiDispatcher extends Dispatcher {
def destination = Matcher.lastMatcher[0][1]
def subJobWriteRequest = jsonSlurper.parseText(request.getBody().readUtf8())
this.receivedSubJobs.put(destination, subJobWriteRequest)
- def response = '{"subJobId":"some sub job id", "dmiServiceName":"some dmi service name", "dataProducerId":"some data producer id"}'
+ def response = '{"subJobId":"some sub job id"}'
return mockResponseWithBody(HttpStatus.OK, response)
}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/WriteSubJobSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/WriteSubJobSpec.groovy
index 834e1399e3..5d3ea1919a 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/WriteSubJobSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/WriteSubJobSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
@@ -59,9 +59,9 @@ class WriteSubJobSpec extends CpsIntegrationSpecBase {
then: 'each DMI received the expected sub-jobs and the response has the expected values'
assert response.size() == 2
assert response[0].class == SubJobWriteResponse.class
- assert response[0].subJobId == "some sub job id"
- assert response[0].dmiServiceName == "some dmi service name"
- assert response[0].dataProducerId == "some data producer id"
+ assert response[0].subJobId == 'some sub job id'
+ assert response[0].dmiServiceName.startsWith('http://localhost:')
+ assert response[0].dataProducerId == 'some data producer id'
and: 'dmi 1 received the correct job details'
def receivedSubJobsForDispatcher1 = dmiDispatcher1.receivedSubJobs['?destination=d1']['data'].collect()
assert receivedSubJobsForDispatcher1.size() == 2