### Question:
ImportBuilder { public Type resolve(Type type) { if (type == null) { throw new IllegalArgumentException("type must not be null"); } return type.accept(resolver, null); } ImportBuilder(ModelFactory factory, PackageDeclaration packageDecl, Strategy strategy); Type resolvePackageMember(Name name); Type resolve(Type type); Type toType(Name name); Type toType(java.lang.reflect.Type type); List<ImportDeclaration> toImportDeclarations(); PackageDeclaration getPackageDeclaration();  }### Answer:
@Test public void parameterized() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat( importer.resolve(type(Map.class, Date.class, Calendar.class)), is(type("Map", "Date", "Calendar"))); assertImported(importer, Map.class, Calendar.class, Date.class); }
@Test public void qualified() { QualifiedType type = f.newQualifiedType( type(List.class, Date.class), f.newSimpleName("Inner")); QualifiedType imported = f.newQualifiedType( type("List", "Date"), f.newSimpleName("Inner")); ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.resolve(type), is((Type) imported)); assertImported(importer, List.class, Date.class); }
@Test public void current() { PackageDeclaration pkg = f.newPackageDeclaration( Models.toName(f, "com.example")); ImportBuilder importer = new ImportBuilder(f, pkg, Strategy.TOP_LEVEL); assertThat(importer.resolve(type("com.example.Test")), is(type("Test"))); assertImported(importer); }
@Test public void defaultPackage() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat( importer.resolve(type("Example")), is(type("Example"))); assertThat( importer.resolve(type("Outer.Inner")), is(type("Outer.Inner"))); assertImportedNames(importer); }
@Test public void duplicate() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.resolve(type(Date.class)), is(type("Date"))); assertThat(importer.resolve(type(Date.class)), is(type("Date"))); assertThat(importer.resolve(type(Date.class)), is(type("Date"))); assertImported(importer, Date.class); }
@Test public void conflict() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.resolve(type(Date.class)), is(type("Date"))); assertThat(importer.resolve(type(java.sql.Date.class)), is(type(java.sql.Date.class))); assertImported(importer, Date.class); }
@Test public void conflictInDefaultPackage() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.resolve(type("Example")), is(type("Example"))); assertThat(importer.resolve(type("com.example.Example")), is(type("com.example.Example"))); assertImported(importer); }