MortarScope { public static Builder buildChild(Context context) { return getScope(context).buildChild(); } 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 noChildrenWithSameName() { MortarScope rootScope = scopeBuilder.build("Root"); rootScope.buildChild().build("childOne"); try { rootScope.buildChild().build("childOne"); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessageContaining("already has a child named"); } }