### Question:
CategoryProvider implements InitializingBean { public Category fromSearchNewznabCategories(String cats) { if (StringUtils.isEmpty(cats)) { return getNotAvailable(); } try { return fromSearchNewznabCategories(Arrays.stream(cats.split(",")).map(Integer::valueOf).collect(Collectors.toList()), getNotAvailable()); } catch (NumberFormatException e) { logger.error("Unable to parse categories string '{}'", cats); return getNotAvailable(); } } CategoryProvider(); @Override void afterPropertiesSet(); @org.springframework.context.event.EventListener void handleNewConfigEvent(ConfigChangedEvent newConfig); List<Category> getCategories(); void setCategories(List<Category> categories); Category getByInternalName(String name); Category getNotAvailable(); Category fromSearchNewznabCategories(String cats); Optional<Category> fromSubtype(Subtype subtype); Category fromSearchNewznabCategories(List<Integer> cats, Category defaultCategory); Category fromResultNewznabCategories(List<Integer> cats); static boolean checkCategoryMatchingMainCategory(int cat, int possibleMainCat); Category getMatchingCategoryOrMatchingMainCategory(List<Integer> cats, Category defaultCategory); static final Category naCategory; }### Answer:
@Test public void shouldConvertSearchNewznabCategoriesToInternalCategory() throws Exception { assertThat(testee.fromSearchNewznabCategories(Arrays.asList(3000), CategoriesConfig.allCategory).getName(), is("3000,3030")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(3030), CategoriesConfig.allCategory).getName(), is("3000,3030")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(7020), CategoriesConfig.allCategory).getName(), is("7020,8010")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(7000, 7020), CategoriesConfig.allCategory).getName(), is("7020,8010")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(7020, 8010), CategoriesConfig.allCategory).getName(), is("7020,8010")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(4000), CategoriesConfig.allCategory).getName(), is("4000")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(4020), CategoriesConfig.allCategory).getName(), is("4000")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(4090), CategoriesConfig.allCategory).getName(), is("4090")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(4000, 4090), CategoriesConfig.allCategory).getName(), is("4000")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(7090), CategoriesConfig.allCategory).getName(), is("All")); assertThat(testee.fromSearchNewznabCategories("4000").getName(), is("4000")); assertThat(testee.fromSearchNewznabCategories("7020,8010").getName(), is("7020,8010")); assertThat(testee.fromSearchNewznabCategories(Collections.emptyList(), CategoriesConfig.allCategory).getName(), is("All")); assertThat(testee.fromSearchNewznabCategories("").getName(), is("N/A")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(4030, 4090), CategoriesConfig.allCategory).getName(), is("4000")); assertThat(testee.fromSearchNewznabCategories(Arrays.asList(3000, 4000), CategoriesConfig.allCategory).getName(), is("4000")); }