Search in sources :

Example 1 with CategoryInfo

use of org.onehippo.taxonomy.api.CategoryInfo in project hippo by NHS-digital-website.

the class TaxonomyFacetWrapperTest method mockCategory.

private Category mockCategory(String key) {
    Category category = mock(Category.class);
    given(category.getKey()).willReturn(key);
    CategoryInfo categoryInfo = mock(CategoryInfo.class);
    given(category.getInfo(Locale.UK)).willReturn(categoryInfo);
    given(categoryInfo.getName()).willReturn(capitalize(key).replace('_', ' '));
    // If the key is not a root one, set the parent
    if (!key.matches("taxonomy_\\d")) {
        Category parent = mockCategory(key.replaceFirst("_\\d$", ""));
        given(category.getParent()).willReturn(parent);
    }
    return category;
}
Also used : CategoryInfo(org.onehippo.taxonomy.api.CategoryInfo) Category(org.onehippo.taxonomy.api.Category)

Aggregations

Category (org.onehippo.taxonomy.api.Category)1 CategoryInfo (org.onehippo.taxonomy.api.CategoryInfo)1