### Question:
ImportedPackages implements ProgressCheckFactory { static Set<ImportedPackage> parseImportPackageHeader(String header) { if (header == null) { return Collections.emptySet(); } Set<ImportedPackage> result = new LinkedHashSet<>(); String[] parts = header.split(";"); int currentPartIndex = 0; ImportedPackage currentPackage = new ImportedPackage(); while (currentPartIndex < parts.length) { String currentPart = parts[currentPartIndex]; if (currentPart.startsWith("resolution:=optional")) { currentPackage.optional = true; int commaIndex = currentPart.indexOf(','); if (commaIndex > -1) { result.add(currentPackage); currentPackage = new ImportedPackage(); currentPackage = parsePartAsPackageName(currentPackage, currentPart.substring(commaIndex + 1), result); } } else if (currentPart.startsWith("version")) { int firstQuoteIndex = currentPart.indexOf('"') + 1; int secondQuoteIndex = currentPart.indexOf('"', firstQuoteIndex); String versionPart = currentPart.substring(firstQuoteIndex, secondQuoteIndex); currentPackage.versionRange = new VersionRange(versionPart); int commaAfterSecondQuote = currentPart.indexOf(',', secondQuoteIndex); if (commaAfterSecondQuote > -1) { result.add(currentPackage); currentPackage = new ImportedPackage(); currentPackage = parsePartAsPackageName(currentPackage, currentPart.substring(commaAfterSecondQuote + 1), result); } } else { currentPackage = parsePartAsPackageName(currentPackage, currentPart, result); } currentPartIndex++; } if (currentPackage.packageName != null) { result.add(currentPackage); } return result; }  @Override ProgressCheck newInstance(JsonObject config);  }### Answer:
@Test public void testParseImportPackageHeader() { Set<ImportedPackages.ImportedPackage> emptyHeader = ImportedPackages.parseImportPackageHeader(null); assertNotNull("set should not be null", emptyHeader); assertTrue("set should be empty", emptyHeader.isEmpty()); final String expectOptionalImport = "javax.json;resolution:=optional;version=\"[1.0.0,2.0.0)\""; final Set<ImportedPackages.ImportedPackage> optionalImportSet = ImportedPackages .parseImportPackageHeader(expectOptionalImport); assertNotNull("set should not be null", optionalImportSet); assertFalse("set should not be empty", optionalImportSet.isEmpty()); final ImportedPackages.ImportedPackage optionalImport = optionalImportSet.iterator().next(); assertEquals("import should match", expectOptionalImport, optionalImport.toString()); final String expectMandatoryImport = "javax.json;version=\"[1.0.0,2.0.0)\""; final Set<ImportedPackages.ImportedPackage> mandatoryImportSet = ImportedPackages .parseImportPackageHeader(expectMandatoryImport); assertNotNull("set should not be null", mandatoryImportSet); assertFalse("set should not be empty", mandatoryImportSet.isEmpty()); final ImportedPackages.ImportedPackage mandatoryImport = mandatoryImportSet.iterator().next(); assertEquals("import should match", expectMandatoryImport, mandatoryImport.toString()); ImportedPackages.Result mandatoryResult = mandatoryImport .satisfied(Collections.singletonMap("javax.json", Collections.singleton(Version.valueOf("2.0.0")))); assertNotSame("expect non-same result", ImportedPackages.ImportedPackage.OK, mandatoryResult); assertNotSame("expect non-same result", ImportedPackages.ImportedPackage.NO_EXPORTS, mandatoryResult); }