import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.inventory.models.YangResource;
import org.onap.cps.ncmp.impl.dmi.DmiProperties;
import org.onap.cps.ncmp.impl.dmi.DmiRestClient;
/**
* Operations class for DMI Model.
*/
-@Slf4j
@RequiredArgsConstructor
@Service
public class DmiModelOperations {
def yangModelCmHandle = createAdvisedCmHandle(moduleSetTag)
and: 'the service returns a list of module references when queried with the specified attributes'
mockCpsModuleService.getModuleReferencesByAttribute(*_) >> [new ModuleReference('module1', '1')]
- and: 'exception occurs when try to store result'
+ and: 'exception occurs when trying to store result'
def testException = new RuntimeException('test')
mockCpsModuleService.createSchemaSetFromModules(*_) >> { throw testException }
when: 'module sync is triggered'
def 'Sync models for a cm handle with previously cached module set tag.'() {
given: 'a cm handle to be synced'
def yangModelCmHandle = createAdvisedCmHandle('cached-tag')
- and: 'The module set tag exist in the private cache'
+ and: 'The module set tag exists in the private cache'
def moduleReferences = [ new ModuleReference('module1','1') ]
def cachedModuleDelta = new ModuleDelta(moduleReferences, [:])
objectUnderTest.privateModuleSetCache.put('cached-tag', cachedModuleDelta)
def 'Attempt to sync using a module set tag already being processed by a different instance or thread.'() {
given: 'a cm handle to be synced'
def yangModelCmHandle = createAdvisedCmHandle('duplicateTag')
- and: 'The module set tag already exist in the processing semaphore set'
+ and: 'The module set tag already exists in the processing semaphore set'
mockModuleSetTagsBeingProcessed.add('duplicate-processing-tag') > false
when: 'module sync is triggered'
objectUnderTest.syncAndCreateSchemaSetAndAnchor(yangModelCmHandle)
def registerSequenceOfCmHandlesWithManyModuleReferencesButDoNotWaitForReady(dmiPlugin, moduleSetTag, numberOfCmHandles, offset) {
def cmHandles = []
def id = offset
- def moduleReferences = (1..200).collect { moduleSetTag + '_Module_' + it.toString() }
+ def moduleReferences = (1..200).collect { "${moduleSetTag}Module${it}" }
(1..numberOfCmHandles).each {
- def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: 'ch-'+id, moduleSetTag: moduleSetTag, alternateId: NO_ALTERNATE_ID)
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: "ch-${id}", moduleSetTag: moduleSetTag, alternateId: NO_ALTERNATE_ID)
cmHandles.add(ncmpServiceCmHandle)
dmiDispatcher1.moduleNamesPerCmHandleId[ncmpServiceCmHandle.cmHandleId] = moduleReferences
dmiDispatcher2.moduleNamesPerCmHandleId[ncmpServiceCmHandle.cmHandleId] = moduleReferences
}
def logInstrumentation(timer, description) {
- System.out.println('*** CPS-2478, ' + description + ' : ' + timer.count()+ ' times, total ' + timer.totalTime(TimeUnit.MILLISECONDS) + ' ms')
+ println "*** CPS-2478, $description : Invoked ${timer.count()} times, Total Time: ${timer.totalTime(TimeUnit.MILLISECONDS)} ms, Mean Time: ${timer.mean(TimeUnit.MILLISECONDS)} ms"
return true
}