MortarScope { public boolean hasService(String serviceName) { return serviceName.equals(MORTAR_SERVICE) || findService(serviceName, false) != null; } MortarScope(String name, MortarScope parent, Map<String, Object> services); static MortarScope getScope(Context context); static MortarScope findChild(Context context, String name); static Builder buildChild(Context context); static boolean isDestroyed(Context context); static Builder buildRootScope(); final String getName(); String getPath(); boolean hasService(String serviceName); T getService(String serviceName); void register(Scoped scoped); MortarScope findChild(String childName); Builder buildChild(); Context createContext(Context parentContext); boolean isDestroyed(); void destroy(); @Override String toString(); static final String DIVIDER; }
@Test public void hasService() { String foo = "FOO"; MortarScope root = scopeBuilder .withService("FOO", foo) .build("root"); assertThat(root.hasService("FOO")).isTrue(); assertThat(root.hasService("BAR")).isFalse(); }