BeanHierarchy { Set<Class<? extends Bean>> subtypes(Class<?> type) { Node node = _nodes.get(type); if (node == null) { return Collections.emptySet(); } Set<Class<? extends Bean>> types = Sets.newHashSet(); addSubtypes(node, types); return types; } BeanHierarchy(Set<MetaBean> metaBeans);   }
@Test public void oneMetaBean() { BeanHierarchy hierarchy = new BeanHierarchy(Sets.<MetaBean>newHashSet(FXForwardSecurity.meta())); assertEquals(ImmutableSet.of(FXForwardSecurity.class), hierarchy.subtypes(FinancialSecurity.class)); assertEquals(ImmutableSet.of(FXForwardSecurity.class), hierarchy.subtypes(ManageableSecurity.class)); assertEquals(ImmutableSet.of(FXForwardSecurity.class), hierarchy.subtypes(Object.class)); assertEquals(ImmutableSet.of(FXForwardSecurity.class), hierarchy.subtypes(FXForwardSecurity.class)); }
@Test public void multipleMetaBeansOneHierarchy() { BeanHierarchy hierarchy = new BeanHierarchy(Sets.<MetaBean>newHashSet(ManageableSecurity.meta(), FXForwardSecurity.meta())); assertEquals(ImmutableSet.of(ManageableSecurity.class, FXForwardSecurity.class), hierarchy.subtypes(Object.class)); assertEquals(ImmutableSet.of(ManageableSecurity.class, FXForwardSecurity.class), hierarchy.subtypes(ManageableSecurity.class)); assertEquals(ImmutableSet.of(FXForwardSecurity.class), hierarchy.subtypes(FXForwardSecurity.class)); }
@Test public void abstractBean() { BeanHierarchy hierarchy = new BeanHierarchy(Sets.<MetaBean>newHashSet(FinancialSecurity.meta(), FXForwardSecurity.meta())); assertEquals(ImmutableSet.of(FXForwardSecurity.class), hierarchy.subtypes(Object.class)); assertEquals(ImmutableSet.of(FXForwardSecurity.class), hierarchy.subtypes(ManageableSecurity.class)); assertEquals(ImmutableSet.of(FXForwardSecurity.class), hierarchy.subtypes(FinancialSecurity.class)); }