@Test public void shouldConvertIndexerNewznabCategoriesToInternalCategory() throws Exception { assertThat(testee.fromResultNewznabCategories(Collections.emptyList()).getName(), is("N/A")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(4000, 4090)).getName(), is("4090")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(4000, 4090, 10_000)).getName(), is("4090")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(4000, 10_000)).getName(), is("4000")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(4090, 11_000)).getName(), is("4090&11_000")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(6060)).getName(), is("6060+9090&99_000")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(6060, 99_000)).getName(), is("6060+9090&99_000")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(7070, 88_000)).getName(), is("N/A")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(10_000, 20_000, 30_000)).getName(), is("10_000&20_000&30_000")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(10_000, 20_000)).getName(), is("N/A")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(4020)).getName(), is("4000")); assertThat(testee.fromResultNewznabCategories(Arrays.asList(9999)).getName(), is("N/A")); }
public Category fromResultNewznabCategories(List<Integer> cats) { if (cats == null || cats.size() == 0) { return naCategory; } cats.sort((o1, o2) -> Integer.compare(o2, o1)); return getMatchingCategoryOrMatchingMainCategory(cats, naCategory); }
CategoryProvider implements InitializingBean { public Category fromResultNewznabCategories(List<Integer> cats) { if (cats == null || cats.size() == 0) { return naCategory; } cats.sort((o1, o2) -> Integer.compare(o2, o1)); return getMatchingCategoryOrMatchingMainCategory(cats, naCategory); } }
CategoryProvider implements InitializingBean { public Category fromResultNewznabCategories(List<Integer> cats) { if (cats == null || cats.size() == 0) { return naCategory; } cats.sort((o1, o2) -> Integer.compare(o2, o1)); return getMatchingCategoryOrMatchingMainCategory(cats, naCategory); } CategoryProvider(); }
CategoryProvider implements InitializingBean { public Category fromResultNewznabCategories(List<Integer> cats) { if (cats == null || cats.size() == 0) { return naCategory; } cats.sort((o1, o2) -> Integer.compare(o2, o1)); return getMatchingCategoryOrMatchingMainCategory(cats, naCategory); } 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); }
CategoryProvider implements InitializingBean { public Category fromResultNewznabCategories(List<Integer> cats) { if (cats == null || cats.size() == 0) { return naCategory; } cats.sort((o1, o2) -> Integer.compare(o2, o1)); return getMatchingCategoryOrMatchingMainCategory(cats, naCategory); } 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; }