### Question:
CategoryProvider implements InitializingBean { public Optional<Category> fromSubtype(Subtype subtype) { return categories.stream().filter(x -> x.getSubtype() == subtype).findFirst(); } 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 shouldFindBySubtype() { Optional<Category> animeOptional = testee.fromSubtype(Subtype.ANIME); assertThat(animeOptional.isPresent(), is(true)); assertThat(animeOptional.get().getName(), is("7020,8010")); Optional<Category> magazineOptional = testee.fromSubtype(Subtype.MAGAZINE); assertThat(magazineOptional.isPresent(), is(false)); }