RA: New criteria for querying allocated resources 19/70819/2
authorStan Bonev <sb5356@att.com>
Fri, 19 Oct 2018 14:24:06 +0000 (10:24 -0400)
committerDan Timoney <dtimoney@att.com>
Thu, 25 Oct 2018 13:25:55 +0000 (13:25 +0000)
Change-Id: Ia3a4b162ea4eca51ba7c500ad5daaa3865e26314
Issue-ID: CCSDK-620
Signed-off-by: Stan Bonev <sb5356@att.com>
12 files changed:
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocator.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocatorImpl.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManager.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/ResourceDao.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/AllocationItemJdbcDao.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/AllocationItemJdbcDaoImpl.java
resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/dao/jdbc/ResourceDaoImpl.java
resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java
resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java [new file with mode: 0644]

index 385dae7..5dab173 100644 (file)
@@ -110,13 +110,17 @@ public class ResourceAllocator implements SvcLogicResource {
         String resourceTargetType = getParam(ctx, new String[] { "reservation-target-type", "resource-target-type" },
                 false, null);
         String resourceName = getParam(ctx, "resource-name", false, null);
+        String resourceEntityTypeFilter = getParam(ctx, "resource-entity-type-filter", false, null);
+        String resourceEntityIdFilter = getParam(ctx, "resource-entity-id-filter", false, null);
+        String resourceShareGroupFilter = getParam(ctx, "resource-share-group-filter", false, null);
 
         if (resourceEntityId != null && resourceEntityType != null) {
             List<ResourceData> rdlist = endPointAllocator.getResourcesForEntity(resourceEntityType, resourceEntityId,
                     resourceEntityVersion);
             setResourceDataInContext(ctx, prefix, rdlist);
         } else if (resourceTargetId != null && resourceTargetType != null && resourceName != null) {
-            ResourceData rd = endPointAllocator.getResource(resourceTargetType, resourceTargetId, resourceName);
+            ResourceData rd = endPointAllocator.getResource(resourceTargetType, resourceTargetId, resourceName,
+                    resourceEntityTypeFilter, resourceEntityIdFilter, resourceShareGroupFilter);
             setResourceDataInContext(ctx, prefix, Collections.singletonList(rd));
         }
 
@@ -126,13 +130,14 @@ public class ResourceAllocator implements SvcLogicResource {
     public AllocationStatus query(ResourceEntity sd, ResourceTarget rt, ResourceRequest rr,
             List<ResourceResponse> rsList) throws Exception {
 
-        if (sd.resourceEntityId != null && sd.resourceEntityType != null) {
+        if (sd != null && sd.resourceEntityId != null && sd.resourceEntityType != null) {
             List<ResourceData> rdlist = endPointAllocator.getResourcesForEntity(sd.resourceEntityType,
                     sd.resourceEntityId, sd.resourceEntityVersion);
             setResourceDataInResponse(rdlist, rsList);
-        } else if (rt.resourceTargetId != null && rt.resourceTargetType != null && rr.resourceName != null) {
-            ResourceData rd = endPointAllocator.getResource(rt.resourceTargetType, rt.resourceTargetId,
-                    rr.resourceName);
+        } else if (rt != null && rt.resourceTargetId != null && rt.resourceTargetType != null && rr != null
+                && rr.resourceName != null) {
+            ResourceData rd = endPointAllocator.getResource(rt.resourceTargetType, rt.resourceTargetId, rr.resourceName,
+                    rr.resourceEntityTypeFilter, rr.resourceEntityIdFilter, rr.resourceShareGroupFilter);
             setResourceDataInResponse(Collections.singletonList(rd), rsList);
         }
 
@@ -232,8 +237,8 @@ public class ResourceAllocator implements SvcLogicResource {
                 resourceManager.releaseResourceSet(resourceSet);
 
             } else {
-                String resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::"
-                        + sd.resourceEntityVersion;
+                String resourceSet =
+                        sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + sd.resourceEntityVersion;
                 log.info(START_RELEASE_LC, resourceSet);
                 resourceManager.releaseResourceSet(resourceSet);
             }
index c6461d4..dbc2a31 100644 (file)
@@ -31,5 +31,6 @@ public interface EndPointAllocator {
     List<ResourceData> getResourcesForEntity(String resourceEntityType, String resourceEntityId,
             String resourceEntityVersion);
 
-    ResourceData getResource(String resourceTargetType, String resourceTargetId, String resourceName);
+    ResourceData getResource(String resourceTargetType, String resourceTargetId, String resourceName,
+            String resourceEntityTypeFilter, String resourceEntityIdFilter, String resourceShareGroupFilter);
 }
index 952ceb6..36891fe 100644 (file)
@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
 public class EndPointAllocatorImpl implements EndPointAllocator {
 
     private static final Logger log = LoggerFactory.getLogger(EndPointAllocatorImpl.class);
-    
+
     private ResourceManager resourceManager;
 
     private Map<String, List<AllocationRule>> allocationRuleMap;
@@ -204,10 +204,27 @@ public class EndPointAllocatorImpl implements EndPointAllocator {
     }
 
     @Override
-    public ResourceData getResource(String resourceTargetType, String resourceTargetId, String resourceName) {
-        ResourceData rd = new ResourceData();;
+    public ResourceData getResource(String resourceTargetType, String resourceTargetId, String resourceName,
+            String resourceEntityTypeFilter, String resourceEntityIdFilter, String resourceShareGroupFilter) {
+        ResourceData rd = new ResourceData();
         String assetId = resourceTargetType + "::" + resourceTargetId;
-        Resource r = resourceManager.getResource(resourceName, assetId);
+
+        String resourceUnionFilter = null;
+        if (resourceEntityTypeFilter != null && resourceEntityIdFilter != null) {
+            resourceUnionFilter = resourceEntityTypeFilter + "::" + resourceEntityIdFilter;
+        } else if (resourceEntityTypeFilter != null) {
+            resourceUnionFilter = resourceEntityTypeFilter;
+        } else if (resourceEntityIdFilter != null) {
+            resourceUnionFilter = resourceEntityIdFilter;
+        }
+
+        Resource r = null;
+        if (resourceUnionFilter != null || resourceShareGroupFilter != null) {
+            r = resourceManager.queryResource(resourceName, assetId, resourceUnionFilter, resourceShareGroupFilter);
+        } else {
+            r = resourceManager.getResource(resourceName, assetId);
+        }
+
         if (r != null) {
             log.info("ResourceName:" + r.resourceKey.resourceName + " assetId:" + r.resourceKey.assetId);
 
index 36a1379..e8bc5ad 100644 (file)
@@ -22,7 +22,6 @@
 package org.onap.ccsdk.sli.adaptors.ra.comp;
 
 import java.util.List;
-
 import org.onap.ccsdk.sli.adaptors.rm.data.Range;
 import org.onap.ccsdk.sli.adaptors.rm.data.ResourceType;
 
@@ -44,4 +43,7 @@ public class ResourceRequest {
     public String endPointPosition;
     public ResourceType resourceType;
     public List<Range> rangeOverrideList;
+    public String resourceEntityTypeFilter;
+    public String resourceEntityIdFilter;
+    public String resourceShareGroupFilter;
 }
index 8aaa286..b40e475 100644 (file)
@@ -8,9 +8,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +22,6 @@
 package org.onap.ccsdk.sli.adaptors.rm.comp;
 
 import java.util.List;
-
 import org.onap.ccsdk.sli.adaptors.rm.data.AllocationOutcome;
 import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
 import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
@@ -38,4 +37,6 @@ public interface ResourceManager {
     void releaseResourceSet(String resourceSetId);
 
     void releaseResourceUnion(String resourceUnionId);
+
+    Resource queryResource(String resourceName, String assetId, String resourceUnionFilter, String resourceShareGroupFilter);
 }
index 77d8a68..d5225b1 100644 (file)
@@ -105,6 +105,14 @@ public class ResourceManagerImpl implements ResourceManager {
         releaseFunction.exec();
     }
 
+    @Override
+    public Resource queryResource(String resourceName, String assetId, String resourceUnionFilter,
+            String resourceShareGroupFilter) {
+        Resource r = resourceDao.query(assetId, resourceName, resourceUnionFilter, resourceShareGroupFilter);
+        ResourceUtil.recalculate(r);
+        return r;
+    }
+
     private Set<String> getLockNames(List<Resource> resourceList) {
         Set<String> lockNames = new HashSet<>();
         for (Resource r : resourceList) {
index 18d6d45..bb4b645 100644 (file)
@@ -8,9 +8,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +22,6 @@
 package org.onap.ccsdk.sli.adaptors.rm.dao;
 
 import java.util.List;
-
 import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
 
 public interface ResourceDao {
@@ -36,4 +35,6 @@ public interface ResourceDao {
     List<Resource> getResourceSet(String resourceSetId);
 
     List<Resource> getResourceUnion(String resourceUnionId);
+
+    Resource query(String assetId, String resourceName, String resourceUnionFilter, String resourceShareGroupFilter);
 }
index fab61b3..8e3a129 100644 (file)
@@ -8,9 +8,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,4 +32,6 @@ public interface AllocationItemJdbcDao {
     void update(AllocationItem ai);
 
     void delete(long id);
+
+    List<AllocationItem> queryAllocationItems(long resourceId, String resourceUnionFilter, String resourceShareGroupFilter);
 }
index 354dd4e..fcde0f8 100644 (file)
@@ -8,9 +8,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
 package org.onap.ccsdk.sli.adaptors.rm.dao.jdbc;
 
-import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Timestamp;
 import java.util.Collections;
 import java.util.List;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -59,22 +57,18 @@ public class AllocationItemJdbcDaoImpl implements AllocationItemJdbcDao {
 
     @Override
     public void add(final AllocationItem ai) {
-        PreparedStatementCreator psc = new PreparedStatementCreator() {
-
-            @Override
-            public PreparedStatement createPreparedStatement(Connection dbc) throws SQLException {
-                PreparedStatement ps = dbc.prepareStatement(INSERT_SQL, new String[] { "allocation_item_id" });
-                ps.setLong(1, ai.resourceId);
-                ps.setString(2, ai.applicationId);
-                ps.setString(3, ai.resourceSetId);
-                ps.setString(4, ai.resourceUnionId);
-                ps.setString(5, ai.resourceShareGroupList);
-                ps.setLong(6, ai.ltUsed);
-                ps.setString(7, ai.llLabel);
-                ps.setString(8, ai.rrUsed);
-                ps.setTimestamp(9, new Timestamp(ai.allocationTime.getTime()));
-                return ps;
-            }
+        PreparedStatementCreator psc = dbc -> {
+            PreparedStatement ps = dbc.prepareStatement(INSERT_SQL, new String[] { "allocation_item_id" });
+            ps.setLong(1, ai.resourceId);
+            ps.setString(2, ai.applicationId);
+            ps.setString(3, ai.resourceSetId);
+            ps.setString(4, ai.resourceUnionId);
+            ps.setString(5, ai.resourceShareGroupList);
+            ps.setLong(6, ai.ltUsed);
+            ps.setString(7, ai.llLabel);
+            ps.setString(8, ai.rrUsed);
+            ps.setTimestamp(9, new Timestamp(ai.allocationTime.getTime()));
+            return ps;
         };
         KeyHolder keyHolder = new GeneratedKeyHolder();
         jdbcTemplate.update(psc, keyHolder);
@@ -95,12 +89,37 @@ public class AllocationItemJdbcDaoImpl implements AllocationItemJdbcDao {
 
     @Override
     public List<AllocationItem> getAllocationItems(long resourceId) {
-        if (resourceId <= 0)
+        if (resourceId <= 0) {
             return Collections.emptyList();
+        }
 
         return jdbcTemplate.query(GET_SQL, new Object[] { resourceId }, allocationItemRowMapper);
     }
 
+    @Override
+    public List<AllocationItem> queryAllocationItems(long resourceId, String resourceUnionFilter,
+            String resourceShareGroupFilter) {
+        if (resourceId <= 0) {
+            return Collections.emptyList();
+        }
+
+        String sql = GET_SQL;
+
+        if (resourceUnionFilter != null) {
+            sql += " AND resource_union_id LIKE '" + resourceUnionFilter + "'";
+        }
+
+        if (resourceShareGroupFilter != null) {
+            if (resourceShareGroupFilter.equalsIgnoreCase("null")) {
+                sql += " AND resource_share_group_list IS NULL";
+            } else {
+                sql += " AND resource_share_group_list LIKE '" + resourceShareGroupFilter + "'";
+            }
+        }
+
+        return jdbcTemplate.query(sql, new Object[] { resourceId }, allocationItemRowMapper);
+    }
+
     private static class AllocationItemRowMapper implements RowMapper<AllocationItem> {
 
         @Override
index e202de7..7deec92 100644 (file)
@@ -65,6 +65,32 @@ public class ResourceDaoImpl implements ResourceDao {
         return r;
     }
 
+    @Override
+    public org.onap.ccsdk.sli.adaptors.rm.data.Resource query(String assetId, String resourceName,
+            String resourceUnionFilter, String resourceShareGroupFilter) {
+        Resource rEntity = resourceJdbcDao.getResource(assetId, resourceName);
+        org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResource(rEntity);
+
+        if (r != null) {
+            List<AllocationItem> aiEntityList = allocationItemJdbcDao.queryAllocationItems(rEntity.id,
+                    resourceUnionFilter, resourceShareGroupFilter);
+            r.allocationItems = new ArrayList<>();
+            for (AllocationItem aiEntity : aiEntityList) {
+                org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem ai = createAllocationItem(r, aiEntity);
+                r.allocationItems.add(ai);
+            }
+
+            List<ResourceLoad> rlEntityList = resourceLoadJdbcDao.getResourceLoads(rEntity.id);
+            r.resourceLoadList = new ArrayList<>();
+            for (ResourceLoad rlEntity : rlEntityList) {
+                org.onap.ccsdk.sli.adaptors.rm.data.ResourceLoad rl = createResourceLoad(r, rlEntity);
+                r.resourceLoadList.add(rl);
+            }
+        }
+
+        return r;
+    }
+
     @Override
     public void saveResource(org.onap.ccsdk.sli.adaptors.rm.data.Resource resource) {
         if (resource == null) {
@@ -201,8 +227,7 @@ public class ResourceDaoImpl implements ResourceDao {
     @Override
     public List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> getResourceSet(String resourceSetId) {
         List<Resource> rEntityList = resourceJdbcDao.getResourceSet(resourceSetId);
-        List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist =
-                new ArrayList<>();
+        List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist = new ArrayList<>();
         for (Resource rEntity : rEntityList) {
             org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResource(rEntity);
             rlist.add(r);
@@ -227,8 +252,7 @@ public class ResourceDaoImpl implements ResourceDao {
     @Override
     public List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> getResourceUnion(String resourceUnionId) {
         List<Resource> rEntityList = resourceJdbcDao.getResourceUnion(resourceUnionId);
-        List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist =
-                new ArrayList<>();
+        List<org.onap.ccsdk.sli.adaptors.rm.data.Resource> rlist = new ArrayList<>();
         for (Resource rEntity : rEntityList) {
             org.onap.ccsdk.sli.adaptors.rm.data.Resource r = createResource(rEntity);
             rlist.add(r);
index e7b855d..b41c068 100644 (file)
@@ -66,7 +66,7 @@ public class DataSetup {
     }
 
     public void setupRangeItem(String resourceName, String assetId, String resourceSetId, String resourceUnionId,
-            String used) {
+            String resourceShareGroup, String used) {
         initTables();
 
         Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'");
@@ -74,7 +74,12 @@ public class DataSetup {
             resource.add(assetId, resourceName, "Range", null, used);
             rid = resource.getLastId();
         }
-        allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, null, used, new Date());
+        allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, resourceShareGroup, null, used, new Date());
+    }
+
+    public void setupRangeItem(String resourceName, String assetId, String resourceSetId, String resourceUnionId,
+            String used) {
+        setupRangeItem(resourceName, assetId, resourceSetId, resourceUnionId, null, used);
     }
 
     public boolean checkRangeItem(String resourceName, String assetId, String resourceSetId, String used) {
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java
new file mode 100644 (file)
index 0000000..4588913
--- /dev/null
@@ -0,0 +1,259 @@
+package jtest.org.onap.ccsdk.sli.adaptors.ra;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceRequest;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceTarget;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:test-context.xml"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestGetResource {
+
+    private static final Logger log = LoggerFactory.getLogger(TestGetResource.class);
+
+    @Autowired(required = true)
+    private ResourceAllocator resourceAllocator;
+
+    @Autowired(required = true)
+    private DataSetup dataSetup;
+
+    private void setupResourceData() {
+        dataSetup.cleanup();
+
+        String targetId = "GBLOND2025MG2";
+        String assetId = "Device::" + targetId;
+        String resourceName = "internal-vlan";
+
+        for (int i = 0; i < 5; i++) {
+            String entityId = "TEST" + i;
+
+            String resourceUnion = "EVC::" + entityId;
+            String resourceSet = resourceUnion + "::1";
+
+            dataSetup.setupRangeItem(resourceName, assetId, resourceSet, resourceUnion, String.valueOf(i));
+        }
+
+        for (int i = 0; i < 5; i++) {
+            String entityId = "TEST" + (i + 10);
+
+            String resourceUnion = "EVC::SVLAN::" + entityId;
+            String resourceSet = resourceUnion + "::1";
+
+            dataSetup.setupRangeItem(resourceName, assetId, resourceSet, resourceUnion, String.valueOf(10 + i));
+        }
+
+        for (int i = 0; i < 5; i++) {
+            String entityId = "TEST" + (i + 20);
+
+            String resourceUnion = "EVC::" + entityId;
+            String resourceSet = resourceUnion + "::1";
+            String resourceShareGroup = "SHARE1";
+
+            dataSetup.setupRangeItem(resourceName, assetId, resourceSet, resourceUnion, resourceShareGroup,
+                    String.valueOf(20 + i));
+        }
+
+        for (int i = 0; i < 5; i++) {
+            String entityId = "TEST" + (i + 30);
+
+            String resourceUnion = "EVC::SVLAN::" + entityId;
+            String resourceSet = resourceUnion + "::1";
+            String resourceShareGroup = "SHARE1";
+
+            dataSetup.setupRangeItem(resourceName, assetId, resourceSet, resourceUnion, resourceShareGroup,
+                    String.valueOf(30 + i));
+        }
+    }
+
+    @Test
+    public void test001() throws Exception {
+
+        String t = "001";
+        log.info("============== query node " + t + " ================================");
+        log.info("=== Test query for resource target - no additional criteria");
+
+        setupResourceData();
+
+        ResourceTarget rt = new ResourceTarget();
+        rt.resourceTargetId = "GBLOND2025MG2";
+        rt.resourceTargetType = "Device";
+
+        ResourceRequest rr = new ResourceRequest();
+        rr.resourceName = "internal-vlan";
+
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
+        ctx.setAttribute("ra-input.resource-target-type", "Device");
+
+        ctx.setAttribute("ra-input.resource-name", "internal-vlan");
+
+        QueryStatus st = resourceAllocator.query("NetworkCapacity", false, null, null, "ra-output", null, ctx);
+
+        Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list_length"), "1");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-name"), "internal-vlan");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-type"), "Device");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-id"), "GBLOND2025MG2");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocated"),
+                "0, 1, 2, 3, 4, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 30, 31, 32, 33, 34");
+    }
+
+    @Test
+    public void test002() throws Exception {
+
+        String t = "002";
+        log.info("============== query node " + t + " ================================");
+        log.info("=== Test query for resource target - with resource entity condition");
+
+        setupResourceData();
+
+        ResourceTarget rt = new ResourceTarget();
+        rt.resourceTargetId = "GBLOND2025MG2";
+        rt.resourceTargetType = "Device";
+
+        ResourceRequest rr = new ResourceRequest();
+        rr.resourceName = "internal-vlan";
+
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
+        ctx.setAttribute("ra-input.resource-target-type", "Device");
+
+        ctx.setAttribute("ra-input.resource-name", "internal-vlan");
+
+        ctx.setAttribute("ra-input.resource-entity-type-filter", "EVC");
+        ctx.setAttribute("ra-input.resource-entity-id-filter", "SVLAN%");
+
+        QueryStatus st = resourceAllocator.query("NetworkCapacity", false, null, null, "ra-output", null, ctx);
+
+        Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list_length"), "1");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-name"), "internal-vlan");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-type"), "Device");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-id"), "GBLOND2025MG2");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocated"),
+                "10, 11, 12, 13, 14, 30, 31, 32, 33, 34");
+    }
+
+    @Test
+    public void test003() throws Exception {
+
+        String t = "003";
+        log.info("============== query node " + t + " ================================");
+        log.info("=== Test query for resource target - with resource share group condition");
+
+        setupResourceData();
+
+        ResourceTarget rt = new ResourceTarget();
+        rt.resourceTargetId = "GBLOND2025MG2";
+        rt.resourceTargetType = "Device";
+
+        ResourceRequest rr = new ResourceRequest();
+        rr.resourceName = "internal-vlan";
+
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
+        ctx.setAttribute("ra-input.resource-target-type", "Device");
+
+        ctx.setAttribute("ra-input.resource-name", "internal-vlan");
+
+        ctx.setAttribute("ra-input.resource-share-group-filter", "SHARE1");
+
+        QueryStatus st = resourceAllocator.query("NetworkCapacity", false, null, null, "ra-output", null, ctx);
+
+        Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list_length"), "1");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-name"), "internal-vlan");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-type"), "Device");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-id"), "GBLOND2025MG2");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocated"),
+                "20, 21, 22, 23, 24, 30, 31, 32, 33, 34");
+    }
+
+    @Test
+    public void test004() throws Exception {
+
+        String t = "004";
+        log.info("============== query node " + t + " ================================");
+        log.info("=== Test query for resource target - with resource share group condition NULL");
+
+        setupResourceData();
+
+        ResourceTarget rt = new ResourceTarget();
+        rt.resourceTargetId = "GBLOND2025MG2";
+        rt.resourceTargetType = "Device";
+
+        ResourceRequest rr = new ResourceRequest();
+        rr.resourceName = "internal-vlan";
+
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
+        ctx.setAttribute("ra-input.resource-target-type", "Device");
+
+        ctx.setAttribute("ra-input.resource-name", "internal-vlan");
+
+        ctx.setAttribute("ra-input.resource-share-group-filter", "null");
+
+        QueryStatus st = resourceAllocator.query("NetworkCapacity", false, null, null, "ra-output", null, ctx);
+
+        Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list_length"), "1");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-name"), "internal-vlan");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-type"), "Device");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-id"), "GBLOND2025MG2");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocated"),
+                "0, 1, 2, 3, 4, 10, 11, 12, 13, 14");
+    }
+
+    @Test
+    public void test005() throws Exception {
+
+        String t = "005";
+        log.info("============== query node " + t + " ================================");
+        log.info("=== Test query for resource target - with both resource entity and resource share group conditions");
+
+        setupResourceData();
+
+        ResourceTarget rt = new ResourceTarget();
+        rt.resourceTargetId = "GBLOND2025MG2";
+        rt.resourceTargetType = "Device";
+
+        ResourceRequest rr = new ResourceRequest();
+        rr.resourceName = "internal-vlan";
+
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
+        ctx.setAttribute("ra-input.resource-target-type", "Device");
+
+        ctx.setAttribute("ra-input.resource-name", "internal-vlan");
+
+        ctx.setAttribute("ra-input.resource-entity-type-filter", "EVC");
+        ctx.setAttribute("ra-input.resource-entity-id-filter", "SVLAN%");
+        ctx.setAttribute("ra-input.resource-share-group-filter", "null");
+
+        QueryStatus st = resourceAllocator.query("NetworkCapacity", false, null, null, "ra-output", null, ctx);
+
+        Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list_length"), "1");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-name"), "internal-vlan");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-type"), "Device");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-id"), "GBLOND2025MG2");
+        Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocated"), "10, 11, 12, 13, 14");
+    }
+}