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;
}
Aggregations