addResourcesToGroup(rgFlat, resourcesServiceE4);
createPlugin("remove-types-plugin", "2.0", "remove_types_v2.xml");
//Removal of this resource type exceeds default criteria page size.
ResourceTypeManagerLocal resourceTypeMgr = LookupUtil.getResourceTypeManager();
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
ResourceTypeCriteria criteria = new ResourceTypeCriteria();
criteria.addFilterName("ServiceE4");
criteria.addFilterPluginName("RemoveTypesPlugin");
long start = nanoTime();
boolean allTypesRemoved = false;
do {
Thread.sleep(SECONDS.toMillis(5));
allTypesRemoved = resourceTypeMgr.findResourceTypesByCriteria(subjectMgr.getOverlord(), criteria).size() == 0;
} while (!allTypesRemoved && (nanoTime() - start) < MINUTES.toNanos(10));
assertTrue("Resource type 'ServiceE4' not fully removed", allTypesRemoved);
}