return pageList;
}
private void testGroupQueries(ArrayList<GroupAvailCounts> groupAvailCounts) throws Exception {
ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
AuthorizationManagerLocal authManager = LookupUtil.getAuthorizationManager();
env = new ArrayList<LargeGroupEnvironment>(groupAvailCounts.size());
LargeGroupEnvironment lgeWithTypes = null;
for (GroupAvailCounts gac : groupAvailCounts) {
env.add(createLargeGroupWithNormalUserRoleAccessWithInventoryStatus(lgeWithTypes, gac.total, gac.down,
gac.unknown, gac.disabled, gac.uncommitted, Permission.CONFIGURE_READ));
lgeWithTypes = env.get(0);
}
ResourceGroupCriteria criteria;
PageList<ResourceGroupComposite> pageList;
ResourceGroupComposite groupComp;
long start;
// test findResourceGroupCompositesByCriteria
for (int i = 0; i < groupAvailCounts.size(); i++) {
LargeGroupEnvironment lge = env.get(i);
GroupAvailCounts gac = groupAvailCounts.get(i);
SessionTestHelper.simulateLogin(lge.normalSubject);
criteria = new ResourceGroupCriteria();
start = System.currentTimeMillis();
pageList = groupManager.findResourceGroupCompositesByCriteria(lge.normalSubject, criteria);
System.out.println("findResourceGroupCompositesByCriteria #" + i + "==>"
+ (System.currentTimeMillis() - start) + "ms");
assert pageList.size() == 1 : "the query should only have selected the one group for our user";
groupComp = pageList.get(0);
System.out.println("-->" + groupComp);
assert groupComp.getExplicitCount() == gac.visibleTotal;
assert groupComp.getExplicitCount() == groupComp.getImplicitCount(); // we aren't testing recursive groups
assert groupComp.getExplicitUp() == gac.up;
assert groupComp.getExplicitDown() == gac.down;
assert groupComp.getExplicitUnknown() == gac.unknown;
assert groupComp.getExplicitDisabled() == gac.disabled;
// mainly to help test when there are uncommitted resources in the group - see BZ 820981
Resource committed = pickAResourceWithInventoryStatus(lge.platformResource, InventoryStatus.COMMITTED);
assert true == authManager.hasResourcePermission(lge.normalSubject, Permission.CONFIGURE_READ,
Collections.singletonList(committed.getId()));
assert false == authManager.hasResourcePermission(lge.normalSubject, Permission.CONTROL,
Collections.singletonList(committed.getId())); // we weren't given CONTROL perms on the committed resource
Resource uncommitted = pickAResourceWithInventoryStatus(lge.platformResource, InventoryStatus.NEW);
if (uncommitted != null) {
assert false == authManager.hasResourcePermission(lge.normalSubject, Permission.CONFIGURE_READ,
Collections.singletonList(uncommitted.getId())); // no permissions for uncommitted resource
}
}
// test getResourceGroupComposite