### Question:
Creator { public static <T> T create(Class<T> type, Map<?, ?> map) { Context context = DependencyInjection.fromMap(map); context.add( DependencyInjection.classes(type) ); return context.get( type ); }  static T create(Class<T> type, Map<?, ?> map); static T create(Class<T> type, Context context); static T newOf( Class<T> type, Object... args );  }### Answer:
@Test public void testCreateWithInstance1() { Bar bar = new Bar(); bar.name = "baz"; Map myMap = map( "bar", bar ); Foo foo = create( fooType, myMap ); boolean ok = foo != null || die(); ok = foo.bar != null || die(); ok = foo.bar.name.equals( "baz" ) || die(); }
@Test public void testCreateWithInstance() { Bar bar = new Bar(); bar.name = "baz"; Foo foo = create( fooType, map( "bar", bar ) ); boolean ok = foo != null || die(); ok = foo.bar != null || die(); ok = foo.bar.name.equals( "baz" ) || die(); }
@Test public void testCreateWithInstance6() { Foo foo = create( fooType, map("bar", map("class", "org.boon.di.CreatorTest$Bar", "name", "barFromMap") )); boolean ok = foo != null || die(); ok = foo.bar != null || die(); ok = foo.bar.name.equals( "barFromMap" ) || die(); }
@Test public void testCreateWithClass() { Foo foo = create( fooType, map( "bar", Bar.class ) ); boolean ok = foo != null || die(); ok = foo.bar != null || die(); ok = foo.bar.name.equals( "bar" ) || die(); }
@Test public void testCreateWithProvider() { Foo foo = create( fooType, map( "bar", new BarProvider() ) ); boolean ok = foo != null || die(); ok = foo.bar != null || die(); ok = foo.bar.name.equals( "fromProvider" ) || die(); }
@Test public void testCreateWithContext() { Context context = context( classes( Foo2.class, Bar.class ) ); Foo2 foo = create( fooType2, context ); boolean ok = foo != null || die(); ok = foo.bar != null || die(); ok = foo.bar.name.equals( "bar" ) || die(); }