DepResolution { public static List<ModuleDescriptor> getLatestProducts(int limit, List<ModuleDescriptor> mdl) { Collections.sort(mdl, Collections.reverseOrder()); Iterator<ModuleDescriptor> it = mdl.listIterator(); String product = ""; int no = 0; while (it.hasNext()) { ModuleDescriptor md = it.next(); if (!product.equals(md.getProduct())) { product = md.getProduct(); no = 0; } else if (no >= limit) { it.remove(); } no++; } return mdl; } private  DepResolution(); static String checkDependencies(Collection<ModuleDescriptor> available,
                                         Collection<ModuleDescriptor> testList); static String checkAllDependencies(Map<String, ModuleDescriptor> available); static String checkAllConflicts(Map<String, ModuleDescriptor> modlist); static Future<Void> installSimulate(Map<String, ModuleDescriptor> modsAvailable,
                                             Map<String, ModuleDescriptor> modsEnabled,
                                             List<TenantModuleDescriptor> tml); static List<ModuleDescriptor> getLatestProducts(int limit, List<ModuleDescriptor> mdl);  }
@Test public void testLatest(TestContext context) { List<ModuleDescriptor> mdl = new LinkedList<>(); mdl.add(mdA200); mdl.add(mdA100); mdl.add(mdB); mdl.add(mdC); mdl.add(mdA110); mdl.add(mdE100); DepResolution.getLatestProducts(2, mdl); context.assertEquals(5, mdl.size()); context.assertEquals(mdE100, mdl.get(0)); context.assertEquals(mdC, mdl.get(1)); context.assertEquals(mdB, mdl.get(2)); context.assertEquals(mdA200, mdl.get(3)); context.assertEquals(mdA110, mdl.get(4)); DepResolution.getLatestProducts(1, mdl); context.assertEquals(4, mdl.size()); context.assertEquals(mdA200, mdl.get(3)); }