summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java10
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java10
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy10
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy12
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy13
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy25
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy15
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy11
11 files changed, 74 insertions, 62 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java
index 159d8f345a..a0aeac3e89 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java
@@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.utils.YangDataConverter;
@@ -48,7 +48,7 @@ import org.springframework.stereotype.Component;
public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements InventoryPersistence {
private final CpsModuleService cpsModuleService;
- private final CpsAdminService cpsAdminService;
+ private final CpsAnchorService cpsAnchorService;
private final CpsValidator cpsValidator;
/**
@@ -58,14 +58,14 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
* @param cpsDataService cps data service instance
* @param cpsModuleService cps module service instance
* @param cpsValidator cps validation service instance
- * @param cpsAdminService cps admin service instance
+ * @param cpsAnchorService cps anchor service instance
*/
public InventoryPersistenceImpl(final JsonObjectMapper jsonObjectMapper, final CpsDataService cpsDataService,
final CpsModuleService cpsModuleService, final CpsValidator cpsValidator,
- final CpsAdminService cpsAdminService) {
+ final CpsAnchorService cpsAnchorService) {
super(jsonObjectMapper, cpsDataService, cpsModuleService, cpsValidator);
this.cpsModuleService = cpsModuleService;
- this.cpsAdminService = cpsAdminService;
+ this.cpsAnchorService = cpsAnchorService;
this.cpsValidator = cpsValidator;
}
@@ -160,7 +160,7 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
@Override
public Collection<String> getCmHandleIdsWithGivenModules(final Collection<String> moduleNamesForQuery) {
- return cpsAdminService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery);
+ return cpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery);
}
private static String createCmHandleXPath(final String cmHandleId) {
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java
index a6b85a5cab..b21a2f1f85 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java
@@ -35,7 +35,7 @@ import java.util.Optional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.inventory.CmHandleQueries;
@@ -59,9 +59,9 @@ public class ModuleSyncService {
private final DmiModelOperations dmiModelOperations;
private final CpsModuleService cpsModuleService;
- private final CpsAdminService cpsAdminService;
private final CmHandleQueries cmHandleQueries;
private final CpsDataService cpsDataService;
+ private final CpsAnchorService cpsAnchorService;
private final JsonObjectMapper jsonObjectMapper;
private final Map<String, Collection<ModuleReference>> moduleSetTagCache;
private static final Map<String, String> NO_NEW_MODULES = Collections.emptyMap();
@@ -105,7 +105,7 @@ public class ModuleSyncService {
}
}
if (!inUpgrade) {
- cpsAdminService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, cmHandleId);
+ cpsAnchorService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, cmHandleId);
}
setCmHandleModuleSetTag(yangModelCmHandle, moduleSetTag);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java
index fd5f2b0ed6..bd8dec4dc8 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java
@@ -29,8 +29,9 @@ import java.util.Map;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
+import org.onap.cps.api.CpsDataspaceService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException;
import org.onap.cps.spi.CascadeDeleteAllowed;
@@ -44,9 +45,10 @@ import org.springframework.boot.context.event.ApplicationReadyEvent;
@RequiredArgsConstructor
abstract class AbstractModelLoader implements ModelLoader {
- private final CpsAdminService cpsAdminService;
+ private final CpsDataspaceService cpsDataspaceService;
private final CpsModuleService cpsModuleService;
private final CpsDataService cpsDataService;
+ private final CpsAnchorService cpsAnchorService;
private static final int EXIT_CODE_ON_ERROR = 1;
@@ -71,7 +73,7 @@ abstract class AbstractModelLoader implements ModelLoader {
void waitUntilDataspaceIsAvailable(final String dataspaceName) {
log.info("Model Loader start-up, waiting for database to be ready");
int attemptCount = 0;
- while (cpsAdminService.getDataspace(dataspaceName) == null) {
+ while (cpsDataspaceService.getDataspace(dataspaceName) == null) {
if (attemptCount < maximumAttemptCount) {
try {
Thread.sleep(attemptCount * retryTimeMs);
@@ -111,7 +113,7 @@ abstract class AbstractModelLoader implements ModelLoader {
void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) {
try {
- cpsAdminService.createAnchor(dataspaceName, schemaSetName, anchorName);
+ cpsAnchorService.createAnchor(dataspaceName, schemaSetName, anchorName);
} catch (final AlreadyDefinedException alreadyDefinedException) {
log.warn("Creating new anchor failed as anchor already exists");
} catch (final Exception exception) {
@@ -134,7 +136,7 @@ abstract class AbstractModelLoader implements ModelLoader {
void updateAnchorSchemaSet(final String dataspaceName, final String anchorName, final String schemaSetName) {
try {
- cpsAdminService.updateAnchorSchemaSet(dataspaceName, anchorName, schemaSetName);
+ cpsAnchorService.updateAnchorSchemaSet(dataspaceName, anchorName, schemaSetName);
} catch (final Exception exception) {
log.error("Updating schema set failed: {}", exception.getMessage());
throw new NcmpStartUpException("Updating schema set failed", exception.getMessage());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
index ade31e9ce6..c0f0279ad4 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
@@ -23,8 +23,9 @@ package org.onap.cps.ncmp.init;
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
+import org.onap.cps.api.CpsDataspaceService;
import org.onap.cps.api.CpsModuleService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -45,10 +46,11 @@ public class CmDataSubscriptionModelLoader extends AbstractModelLoader {
- public CmDataSubscriptionModelLoader(final CpsAdminService cpsAdminService,
+ public CmDataSubscriptionModelLoader(final CpsDataspaceService cpsDataspaceService,
final CpsModuleService cpsModuleService,
- final CpsDataService cpsDataService) {
- super(cpsAdminService, cpsModuleService, cpsDataService);
+ final CpsDataService cpsDataService,
+ final CpsAnchorService cpsAnchorService) {
+ super(cpsDataspaceService, cpsModuleService, cpsDataService, cpsAnchorService);
}
@Value("${ncmp.model-loader.subscription:true}")
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
index a27eb6f7ce..0e562cdd8b 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
@@ -24,8 +24,9 @@ import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DA
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
+import org.onap.cps.api.CpsDataspaceService;
import org.onap.cps.api.CpsModuleService;
import org.springframework.stereotype.Service;
@@ -36,10 +37,11 @@ public class InventoryModelLoader extends AbstractModelLoader {
private static final String NEW_MODEL_FILE_NAME = "dmi-registry@2023-11-27.yang";
private static final String NEW_SCHEMA_SET_NAME = "dmi-registry-2023-11-27";
- public InventoryModelLoader(final CpsAdminService cpsAdminService,
+ public InventoryModelLoader(final CpsDataspaceService cpsDataspaceService,
final CpsModuleService cpsModuleService,
- final CpsDataService cpsDataService) {
- super(cpsAdminService, cpsModuleService, cpsDataService);
+ final CpsDataService cpsDataService,
+ final CpsAnchorService cpsAnchorService) {
+ super(cpsDataspaceService, cpsModuleService, cpsDataService, cpsAnchorService);
}
@Override
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
index 013341f4bc..f565ede394 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
@@ -210,12 +210,10 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
}
and: 'state handler is invoked with the expected parameters'
1 * mockLcmEventsCmHandleStateHandler.initiateStateAdvised(_) >> {
- args ->
- {
- def cmHandleStatePerCmHandle = (args[0] as List)
- cmHandleStatePerCmHandle.each {
- assert (it.id == 'cmhandle' && it.dmiServiceName == 'my-server')
- }
+ args -> {
+ def yangModelCmHandles = args[0]
+ assert yangModelCmHandles.id == ['cmhandle']
+ assert yangModelCmHandles.dmiServiceName == ['my-server']
}
}
where:
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy
index bb4eebd40e..297f18c989 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy
@@ -22,6 +22,8 @@
package org.onap.cps.ncmp.api.impl.inventory
+import org.onap.cps.api.CpsAnchorService
+
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR
@@ -30,12 +32,8 @@ import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NO_TIME
import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
-import org.onap.cps.ncmp.api.impl.inventory.CmHandleState
-import org.onap.cps.ncmp.api.impl.inventory.CompositeState
-import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistenceImpl
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import org.onap.cps.spi.CascadeDeleteAllowed
import org.onap.cps.spi.FetchDescendantsOption
@@ -58,12 +56,12 @@ class InventoryPersistenceImplSpec extends Specification {
def mockCpsModuleService = Mock(CpsModuleService)
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsAnchorService = Mock(CpsAnchorService)
def mockCpsValidator = Mock(CpsValidator)
def objectUnderTest = new InventoryPersistenceImpl(spiedJsonObjectMapper, mockCpsDataService, mockCpsModuleService,
- mockCpsValidator, mockCpsAdminService)
+ mockCpsValidator, mockCpsAnchorService)
def formattedDateAndTime = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.format(OffsetDateTime.of(2022, 12, 31, 20, 30, 40, 1, ZoneOffset.UTC))
@@ -284,7 +282,7 @@ class InventoryPersistenceImplSpec extends Specification {
when: 'the method to get cm handles is called'
objectUnderTest.getCmHandleIdsWithGivenModules(['sample-module-name'])
then: 'the admin persistence service method to query anchors is invoked once with the same parameter'
- 1 * mockCpsAdminService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name'])
+ 1 * mockCpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name'])
}
def 'Replace list content'() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
index 2ded84fac1..de783ed2ca 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
@@ -20,13 +20,14 @@
package org.onap.cps.ncmp.api.impl.inventory.sync
+import org.onap.cps.api.CpsAnchorService
+
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.inventory.LockReasonCategory.MODULE_UPGRADE
import org.onap.cps.ncmp.api.impl.inventory.CmHandleState
import org.onap.cps.spi.FetchDescendantsOption
import org.onap.cps.spi.model.DataNode
-import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.model.DataNodeBuilder
@@ -45,14 +46,14 @@ class ModuleSyncServiceSpec extends Specification {
def mockCpsModuleService = Mock(CpsModuleService)
def mockDmiModelOperations = Mock(DmiModelOperations)
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsAnchorService = Mock(CpsAnchorService)
def mockCmHandleQueries = Mock(CmHandleQueries)
def mockCpsDataService = Mock(CpsDataService)
def mockJsonObjectMapper = Mock(JsonObjectMapper)
def mockModuleSetTagCache = [:]
- def objectUnderTest = new ModuleSyncService(mockDmiModelOperations, mockCpsModuleService, mockCpsAdminService,
- mockCmHandleQueries, mockCpsDataService, mockJsonObjectMapper, mockModuleSetTagCache)
+ def objectUnderTest = new ModuleSyncService(mockDmiModelOperations, mockCpsModuleService,
+ mockCmHandleQueries, mockCpsDataService, mockCpsAnchorService, mockJsonObjectMapper, mockModuleSetTagCache)
def expectedDataspaceName = NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME
def static cmHandleWithModuleSetTag = new DataNodeBuilder().withXpath("//cm-handles[@module-set-tag='tag-1'][@id='otherId']").withAnchor('otherId').build()
@@ -78,7 +79,7 @@ class ModuleSyncServiceSpec extends Specification {
then: 'create schema set from module is invoked with correct parameters'
1 * mockCpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', newModuleNameContentToMap, moduleReferences)
and: 'anchor is created with the correct parameters'
- 1 * mockCpsAdminService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', 'ch-1')
+ 1 * mockCpsAnchorService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', 'ch-1')
where: 'the following parameters are used'
scenario | existingModuleResourcesInCps | identifiedNewModuleReferences | newModuleNameContentToMap | moduleSetTag
'one new module' | [['module2': '2'], ['module3': '3']] | [['module1': '1']] | [module1: 'some yang source'] | ''
@@ -115,7 +116,7 @@ class ModuleSyncServiceSpec extends Specification {
and: 'create schema set from module is invoked for the upgraded cm handle'
expectedCallsToCeateSchemaSet * mockCpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'upgraded-ch', [:], moduleReferences)
and: 'No anchor is created for the upgraded cm handle'
- 0 * mockCpsAdminService.createAnchor(*_)
+ 0 * mockCpsAnchorService.createAnchor(*_)
where: 'the following parameters are used'
scenario | populateCache | existingCmHandlesWithSameTag || expectedCallsToUpgradeSchemaSet | expectedCallsToCeateSchemaSet
'new' | false | [] || 0 | 1
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy
index e5ed21f1c4..3b1c25ba6a 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy
@@ -23,7 +23,8 @@ package org.onap.cps.ncmp.init
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.api.CpsAdminService
+import org.onap.cps.api.CpsDataspaceService
+import org.onap.cps.api.CpsAnchorService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException
@@ -37,10 +38,11 @@ import spock.lang.Specification
class AbstractModelLoaderSpec extends Specification {
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsDataspaceService = Mock(CpsDataspaceService)
def mockCpsModuleService = Mock(CpsModuleService)
def mockCpsDataService = Mock(CpsDataService)
- def objectUnderTest = Spy(new TestModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService))
+ def mockCpsAnchorService = Mock(CpsAnchorService)
+ def objectUnderTest = Spy(new TestModelLoader(mockCpsDataspaceService, mockCpsModuleService, mockCpsDataService, mockCpsAnchorService))
def applicationContext = new AnnotationConfigApplicationContext()
@@ -141,12 +143,12 @@ class AbstractModelLoaderSpec extends Specification {
when: 'creating an anchor'
objectUnderTest.createAnchor('some dataspace','some schema set','new name')
then: 'the operation is delegated to the admin service'
- 1 * mockCpsAdminService.createAnchor('some dataspace','some schema set', 'new name')
+ 1 * mockCpsAnchorService.createAnchor('some dataspace','some schema set', 'new name')
}
def 'Create anchor with already defined exception.'() {
given: 'the admin service throws an already defined exception'
- mockCpsAdminService.createAnchor(*_)>> { throw AlreadyDefinedException.forAnchor('name','context',null) }
+ mockCpsAnchorService.createAnchor(*_)>> { throw AlreadyDefinedException.forAnchor('name','context',null) }
when: 'attempt to create anchor'
objectUnderTest.createAnchor('some dataspace','some schema set','new name')
then: 'the exception is ignored i.e. no exception thrown up'
@@ -158,7 +160,7 @@ class AbstractModelLoaderSpec extends Specification {
def 'Create anchor with any other exception.'() {
given: 'the admin service throws a exception'
- mockCpsAdminService.createAnchor(*_)>> { throw new RuntimeException('test message') }
+ mockCpsAnchorService.createAnchor(*_)>> { throw new RuntimeException('test message') }
when: 'attempt to create anchor'
objectUnderTest.createAnchor('some dataspace','some schema set','new name')
then: 'a startup exception with correct message and details is thrown'
@@ -201,12 +203,12 @@ class AbstractModelLoaderSpec extends Specification {
when: 'a schema set for an anchor is updated'
objectUnderTest.updateAnchorSchemaSet('some dataspace', 'anchor', 'new schema set')
then: 'the request is delegated to the admin service'
- 1 * mockCpsAdminService.updateAnchorSchemaSet('some dataspace', 'anchor', 'new schema set')
+ 1 * mockCpsAnchorService.updateAnchorSchemaSet('some dataspace', 'anchor', 'new schema set')
}
def 'Update anchor schema set with exception.'() {
given: 'the admin service throws an exception'
- mockCpsAdminService.updateAnchorSchemaSet(*_) >> { throw new RuntimeException('test message') }
+ mockCpsAnchorService.updateAnchorSchemaSet(*_) >> { throw new RuntimeException('test message') }
when: 'a schema set for an anchor is updated'
objectUnderTest.updateAnchorSchemaSet('some dataspace', 'anchor', 'new schema set')
then: 'a startup exception with correct message and details is thrown'
@@ -217,10 +219,11 @@ class AbstractModelLoaderSpec extends Specification {
class TestModelLoader extends AbstractModelLoader {
- TestModelLoader(final CpsAdminService cpsAdminService,
+ TestModelLoader(final CpsDataspaceService cpsDataspaceService,
final CpsModuleService cpsModuleService,
- final CpsDataService cpsDataService) {
- super(cpsAdminService, cpsModuleService, cpsDataService)
+ final CpsDataService cpsDataService,
+ final CpsAnchorService cpsAnchorService) {
+ super(cpsDataspaceService, cpsModuleService, cpsDataService, cpsAnchorService)
super.maximumAttemptCount = 2
super.retryTimeMs = 1
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
index 06627129a9..aed495ec45 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
@@ -20,12 +20,14 @@
package org.onap.cps.ncmp.init
+import org.onap.cps.api.CpsAnchorService
+
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.api.CpsAdminService
+import org.onap.cps.api.CpsDataspaceService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.model.Dataspace
@@ -36,10 +38,11 @@ import spock.lang.Specification
class CmDataSubscriptionModelLoaderSpec extends Specification {
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsDataspaceService = Mock(CpsDataspaceService)
def mockCpsModuleService = Mock(CpsModuleService)
def mockCpsDataService = Mock(CpsDataService)
- def objectUnderTest = new CmDataSubscriptionModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService)
+ def mockCpsAnchorService = Mock(CpsAnchorService)
+ def objectUnderTest = new CmDataSubscriptionModelLoader(mockCpsDataspaceService, mockCpsModuleService, mockCpsDataService, mockCpsAnchorService)
def applicationContext = new AnnotationConfigApplicationContext()
@@ -65,13 +68,13 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
given:'model loader is enabled'
objectUnderTest.subscriptionModelLoaderEnabled = true
and: 'dataspace is ready for use'
- mockCpsAdminService.getDataspace(NCMP_DATASPACE_NAME) >> new Dataspace('')
+ mockCpsDataspaceService.getDataspace(NCMP_DATASPACE_NAME) >> new Dataspace('')
when: 'the application is ready'
objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
then: 'the module service to create schema set is called once'
1 * mockCpsModuleService.createSchemaSet(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', expectedYangResourcesToContentMap)
and: 'the admin service to create an anchor set is called once'
- 1 * mockCpsAdminService.createAnchor(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', 'cm-data-subscriptions')
+ 1 * mockCpsAnchorService.createAnchor(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', 'cm-data-subscriptions')
and: 'the data service to create a top level datanode is called once'
1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '{"datastores":{}}', _)
}
@@ -82,7 +85,7 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
when: 'application is ready'
objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
then: 'no interaction with admin service'
- 0 * mockCpsAdminService.getDataspace(_)
+ 0 * mockCpsDataspaceService.getDataspace(_)
then: 'a message is logged that the function is disabled'
def logs = loggingListAppender.list.toString()
assert logs.contains('Subscription Model Loader is disabled')
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
index 4eb2ca3c73..5557993abd 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
@@ -20,13 +20,15 @@
package org.onap.cps.ncmp.init
+import org.onap.cps.api.CpsAnchorService
+
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.api.CpsAdminService
+import org.onap.cps.api.CpsDataspaceService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.model.Dataspace
@@ -37,10 +39,11 @@ import spock.lang.Specification
class InventoryModelLoaderSpec extends Specification {
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsAdminService = Mock(CpsDataspaceService)
def mockCpsModuleService = Mock(CpsModuleService)
def mockCpsDataService = Mock(CpsDataService)
- def objectUnderTest = new InventoryModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService)
+ def mockCpsAnchorService = Mock(CpsAnchorService)
+ def objectUnderTest = new InventoryModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService, mockCpsAnchorService)
def applicationContext = new AnnotationConfigApplicationContext()
@@ -70,7 +73,7 @@ class InventoryModelLoaderSpec extends Specification {
then: 'the module service is used to create the new schema set from the correct resource'
1 * mockCpsModuleService.createSchemaSet(NCMP_DATASPACE_NAME, 'dmi-registry-2023-11-27', expectedYangResourceToContentMap)
and: 'the admin service is used to update the anchor'
- 1 * mockCpsAdminService.updateAnchorSchemaSet(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'dmi-registry-2023-11-27')
+ 1 * mockCpsAnchorService.updateAnchorSchemaSet(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'dmi-registry-2023-11-27')
and: 'No schema sets are being removed by the module service (yet)'
0 * mockCpsModuleService.deleteSchemaSet(NCMP_DATASPACE_NAME, _, _)
}