@Test public void test_getVisibility_ReturnsPublic_WhenTheSpecifiedTypeIsPublic() throws Exception { TypeVisibility typeCategory= TypeUtils.getVisibility(types, "test.TypeUtils.SomeInterface"); assertSame(TypeVisibility.PUBLIC, typeCategory); }
@Test public void test_getVisibility_ReturnsPackage_WhenTheSpecifiedTypeIsPackageScoped() throws Exception { TypeVisibility typeCategory= TypeUtils.getVisibility(types, "test.TypeUtils.SomeClass"); assertSame(TypeVisibility.PACKAGE, typeCategory); }
@Test public void test_getVisibility_ReturnsNull_WhenTheSpecifiedTypeCouldNotBeFound() throws Exception { assertNull(TypeUtils.getVisibility(types, "com.company.app.Class")); }
private void findSupportingTypes(Set<Component> components) { for (Component component : components) { for (CodeElement codeElement : component.getCode()) { TypeVisibility visibility = TypeUtils.getVisibility(getTypeRepository(), codeElement.getType()); if (visibility != null) { codeElement.setVisibility(visibility.getName()); } TypeCategory category = TypeUtils.getCategory(getTypeRepository(), codeElement.getType()); if (category != null) { codeElement.setCategory(category.getName()); } } for (SupportingTypesStrategy strategy : supportingTypesStrategies) { for (Class<?> type : strategy.findSupportingTypes(component)) { if (!isNestedClass(type) && componentFinder.getContainer().getComponentOfType(type.getCanonicalName()) == null) { CodeElement codeElement = component.addSupportingType(type.getCanonicalName()); TypeVisibility visibility = TypeUtils.getVisibility(getTypeRepository(), codeElement.getType()); if (visibility != null) { codeElement.setVisibility(visibility.getName()); } TypeCategory category = TypeUtils.getCategory(getTypeRepository(), codeElement.getType()); if (category != null) { codeElement.setCategory(category.getName()); } } } } } }