### Question:
ImportBuilder { public Type toType(Name name) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } return resolve(resolver.factory.newNamedType(name)); } 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 primitive() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.toType(int.class), is(type(int.class))); assertImported(importer); }
@Test public void aClass() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.toType(Date.class), is(type(Date.class.getSimpleName()))); assertImported(importer, Date.class); }
@Test public void array() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.toType(int[].class), is(type(int[].class))); assertThat(importer.toType(Date[].class), is((Type) f.newArrayType(type("Date")))); assertImported(importer, Date.class); }
@Test public void javaLang() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.toType(String.class), is(type(String.class.getSimpleName()))); assertImported(importer); }
@Test public void enclosing() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.TOP_LEVEL); assertThat(importer.toType(Map.Entry.class), is(type("Map.Entry"))); assertImported(importer, Map.class); }
@Test public void enclosing_just() { ImportBuilder importer = new ImportBuilder(f, null, Strategy.ENCLOSING); assertThat(importer.toType(Map.Entry.class), is(type("Entry"))); assertImported(importer, Map.Entry.class); }