@Test public void provide_types() { ResourceTypeTree tree = DefaultResourceTypes.get(); assertThat(tree.getTypes()).hasSize(7); assertThat(tree.getChildren(Qualifiers.PROJECT)).containsExactly(Qualifiers.MODULE); }
@Test public void projects_should_be_available_for_global_widgets() { ResourceTypeTree tree = DefaultResourceTypes.get(); ResourceType projectResourceType = tree.getTypes().get(0); assertThat(projectResourceType.getQualifier()).isEqualTo(Qualifiers.PROJECT); assertThat(projectResourceType.getBooleanProperty("supportsGlobalDashboards")).isTrue(); }
public ResourceTypes(ResourceTypeTree[] trees) { Preconditions.checkNotNull(trees); Map<String, ResourceTypeTree> treeMap = Maps.newHashMap(); Map<String, ResourceType> typeMap = Maps.newLinkedHashMap(); Collection<ResourceType> rootsSet = Sets.newHashSet(); for (ResourceTypeTree tree : trees) { rootsSet.add(tree.getRootType()); for (ResourceType type : tree.getTypes()) { if (treeMap.containsKey(type.getQualifier())) { throw new IllegalStateException( "Qualifier " + type.getQualifier() + " is defined in several trees"); } treeMap.put(type.getQualifier(), tree); typeMap.put(type.getQualifier(), type); } } treeByQualifier = ImmutableMap.copyOf(treeMap); typeByQualifier = ImmutableMap.copyOf(typeMap); rootTypes = ImmutableList.copyOf(rootsSet); }
@Test public void getTypes() { assertThat(tree.getTypes().size(), is(4)); assertThat(qualifiers(tree.getTypes()), hasItems("TRK", "DIR", "FIL", "UTS")); }