public Collection<String> queryCmHandleIds(
final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) {
return executeQueries(cmHandleQueryServiceParameters,
- this::executeCpsPathQuery,
- this::queryCmHandlesByPublicProperties,
- this::executeModuleNameQuery,
+ this::executeCpsPathQuery,
+ this::queryCmHandlesByPublicProperties,
+ this::executeModuleNameQuery,
this::queryCmHandlesByTrustLevel);
}
@Override
public Collection<String> queryCmHandleIdsForInventory(
- final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) {
+ final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) {
return executeQueries(cmHandleQueryServiceParameters,
- this::queryCmHandlesByPublicProperties,
- this::queryCmHandlesByPrivateProperties,
- this::queryCmHandlesByDmiPlugin);
+ this::executeCpsPathQuery,
+ this::queryCmHandlesByPublicProperties,
+ this::queryCmHandlesByPrivateProperties,
+ this::queryCmHandlesByDmiPlugin);
}
@Override
HAS_ALL_PROPERTIES("hasAllProperties"),
HAS_ALL_ADDITIONAL_PROPERTIES("hasAllAdditionalProperties"),
- CM_HANDLE_WITH_DMI_PLUGIN("cmHandleWithDmiPlugin");
+ CM_HANDLE_WITH_DMI_PLUGIN("cmHandleWithDmiPlugin"),
+ WITH_CPS_PATH("cmHandleWithCpsPath");
public static final List<String> ALL_CONDITION_NAMES = Arrays.stream(InventoryQueryConditions.values())
.map(InventoryQueryConditions::getName).collect(Collectors.toList());
assert result == ['some-cmhandle-id'] as Set
}
+ def 'Query cm handle where cps path itself is ancestor axis.'() {
+ given: 'a cmHandleWithCpsPath condition property'
+ def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
+ def conditionProperties = createConditionProperties('cmHandleWithCpsPath', [['cpsPath' : '/some/cps/path']])
+ cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties])
+ and: 'the query get the cm handle data nodes excluding all descendants returns a datanode'
+ cmHandleQueries.queryCmHandleAncestorsByCpsPath('/some/cps/path', FetchDescendantsOption.OMIT_DESCENDANTS) >> [new DataNode(leaves: ['id':'some-cmhandle-id'])]
+ when: 'the query is executed for cm handle ids'
+ def result = objectUnderTest.queryCmHandleIdsForInventory(cmHandleQueryParameters)
+ then: 'the correct expected cm handles ids are returned'
+ assert result == ['some-cmhandle-id'] as Set
+ }
+
def 'Cm handle ids query with error: #scenario.'() {
given: 'a cmHandleWithCpsPath condition property'
def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
/*
* ============LICENSE_START========================================================
- * Copyright (c) 2022 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.
package org.onap.cps.ncmp.impl.inventory.models
-
import spock.lang.Specification
class InventoryQueryConditionsSpec extends Specification {
def 'Inventory query condition names.'() {
- expect: '3 conditions with the correct names'
- assert InventoryQueryConditions.ALL_CONDITION_NAMES.size() == 3
+ expect: '4 conditions with the correct names'
+ assert InventoryQueryConditions.ALL_CONDITION_NAMES.size() == 4
assert InventoryQueryConditions.ALL_CONDITION_NAMES.containsAll('hasAllProperties',
'hasAllAdditionalProperties',
- 'cmHandleWithDmiPlugin')
+ 'cmHandleWithDmiPlugin',
+ 'cmHandleWithCpsPath')
}
-
-
}