SearchLevels { protected String cleanupCPE(String cpe) { if(cpe.startsWith(OLD_CPE_PREFIX)){ cpe = cpe.replaceAll("^"+OLD_CPE_PREFIX, CPE_PREFIX) .replace("::", ":-:") .replace("~-", "~") .replace("~", ":-:") .replace("::", ":") .replaceAll("[:-]*$", ""); } return cpe.toLowerCase(); } SearchLevels(CveSearchApi cveSearchApi); Stream<List<NeedleWithMeta>> apply(Release release);  }
@Test public void cleanupNewCpeTest() { String newCpe = "cpe:2.3:a:Vendor:Product:Version"; assert(searchLevels.cleanupCPE(newCpe).equals(newCpe.toLowerCase())); }
@Test public void cleanupOldCpeTest() { String oldCpe = "cpe:/a:vendor:product:version:~~~~"; String newCpe = "cpe:2.3:a:vendor:product:version"; assert(searchLevels.cleanupCPE(oldCpe).equals(newCpe)); }