ImportsHolder { public String toJavaImportString() { StringBuilder sb = new StringBuilder(); String lastDomain = ""; boolean first = true; for (PackageImport pi : imports) { String name = pi.getName(); if (!name.startsWith("static ")) { String domain = name.split("\\.")[0]; if (!first && !lastDomain.equals(domain)) { sb.append("\n"); } lastDomain = domain; } sb.append("import ").append(name).append(";\n"); first = false; } return sb.toString(); } ImportsHolder(String currentPackage); void addImports(List<PackageImport> packageImports); boolean addImport(PackageImport packageImport); boolean add(String fullType); List<PackageImport> getList(); boolean hasImports(); String toJavaImportString();  }
@Test public void empty() { ImportsHolder holder = new ImportsHolder(""); assertThat(holder.toJavaImportString()).isEmpty(); }