diff options
Diffstat (limited to 'cps-ncmp-service')
3 files changed, 15 insertions, 14 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 3d1c5237d6..1f9ea11d4f 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 @@ -63,7 +63,7 @@ public class DmiSubJobRequestHandler { final List<SubJobWriteResponse> subJobWriteResponses = new ArrayList<>(dmiWriteOperationsPerProducerKey.size()); dmiWriteOperationsPerProducerKey.forEach((producerKey, dmi3ggpWriteOperations) -> { final SubJobWriteRequest subJobWriteRequest = new SubJobWriteRequest(dataJobMetadata.dataAcceptType(), - dataJobMetadata.dataContentType(), dataJobId, dmi3ggpWriteOperations); + dataJobMetadata.dataContentType(), producerKey.dataProducerIdentifier(), dmi3ggpWriteOperations); final UrlTemplateParameters urlTemplateParameters = getUrlTemplateParameters(dataJobId, producerKey); final ResponseEntity<Object> responseEntity = dmiRestClient.synchronousPostOperationWithJsonData( diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DataSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DataSyncWatchdog.java index 45f6367841..c3973236f0 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DataSyncWatchdog.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DataSyncWatchdog.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation + * Copyright (C) 2022-2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,21 +60,22 @@ public class DataSyncWatchdog { moduleOperationsUtils.getUnsynchronizedReadyCmHandles().forEach(unSynchronizedReadyCmHandle -> { final String cmHandleId = unSynchronizedReadyCmHandle.getId(); if (hasPushedIntoSemaphoreMap(cmHandleId)) { - log.debug("Executing data sync on {}", cmHandleId); + log.info("Executing data sync on {}", cmHandleId); final CompositeState compositeState = inventoryPersistence .getCmHandleState(cmHandleId); final String resourceData = moduleOperationsUtils.getResourceData(cmHandleId); if (resourceData == null) { - log.debug("Error retrieving resource data for Cm-Handle: {}", cmHandleId); + log.error("Error retrieving resource data for Cm-Handle: {}", cmHandleId); } else { cpsDataService.saveData(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, resourceData, OffsetDateTime.now()); setSyncStateToSynchronized().accept(compositeState); inventoryPersistence.saveCmHandleState(cmHandleId, compositeState); updateDataSyncSemaphoreMap(cmHandleId); + log.info("Data sync finished for {}", cmHandleId); } } else { - log.debug("{} already processed by another instance", cmHandleId); + log.info("{} already processed by another instance", cmHandleId); } }); log.debug("No Cm-Handles currently found in READY State and Operational Sync State is UNSYNCHRONIZED"); 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 e07b978482..7005cc6b18 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 @@ -25,16 +25,16 @@ class DmiSubJobRequestHandlerSpec extends Specification { def 'Send a sub-job request to the DMI Plugin.'() { given: 'a data job id, metadata and a map of producer keys and write operations to create a request' def dataJobId = 'some-job-id' - def dataJobMetadata = new DataJobMetadata('', '', '') - def dmiWriteOperation = new DmiWriteOperation('', '', '', null, '', [:]) - def dmiWriteOperationsPerProducerKey = [new ProducerKey('', ''): [dmiWriteOperation]] - def response = new ResponseEntity<>(new SubJobWriteResponse('my-sub-job-id', '', ''), HttpStatus.OK) + def dataJobMetadata = new DataJobMetadata('d1', 't1', 't2') + def dmiWriteOperation = new DmiWriteOperation('p', 'operation', 'tag', null, 'o1', [:]) + def dmiWriteOperationsPerProducerKey = [new ProducerKey('dmi1', 'prod1'): [dmiWriteOperation]] + 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 expectedJson = '{"dataAcceptType":"t1","dataContentType":"t2","dataProducerId":"prod1","data":[{"path":"p","op":"operation","moduleSetTag":"tag","value":null,"operationId":"o1","privateProperties":{}}]}' + mockDmiRestClient.synchronousPostOperationWithJsonData(RequiredDmiService.DATA, _, expectedJson, OperationType.CREATE, NO_AUTH) >> responseEntity when: 'sending request to DMI invoked' objectUnderTest.sendRequestsToDmi(dataJobId, dataJobMetadata, dmiWriteOperationsPerProducerKey) - then: 'the dmi rest client is called' - 1 * mockDmiRestClient.synchronousPostOperationWithJsonData(RequiredDmiService.DATA, _, _, OperationType.CREATE, NO_AUTH) >> response - and: 'the result contains the expected sub-job write responses' - def result = response.body - assert result.subJobId() == 'my-sub-job-id' + then: 'the result contains the expected sub-job id' + assert responseEntity.body.subJobId == 'my-sub-job-id' } } |