Scoop { public <T> T findService(String serviceName) { return findService(this, serviceName); } private  Scoop(String name, Scoop parent, Map<String, Object> services); void destroy(); T findService(String serviceName); String getName(); Scoop getParent(); Scoop findChild(String childName); static Scoop fromView(View view); static Scoop fromContext(Context context); LayoutInflater inflater(Context context); Context createContext(Context context); View inflate(int layoutId, ViewGroup viewGroup, boolean attachToRoot);  }
@Test public void findService() { FooService service = new FooService(); Scoop rootScoop = new Scoop.Builder("root") .service("foo_service", service) .build(); Assert.assertEquals(service, rootScoop.findService("foo_service")); }
@Test public void findServiceInParent() { FooService service = new FooService(); Scoop rootScoop = new Scoop.Builder("root") .service("foo_service", service) .build(); Scoop childScoop = new Scoop.Builder("child", rootScoop) .build(); Assert.assertEquals(service, childScoop.findService("foo_service")); }