SortingStrategies { public Comparator<ApplicationInfo> forName(@NonNull final SortingStrategyName name) { val supplier = sortingStrategiesByName.get(name); return (supplier != null) ? supplier.get() : defaultStrategy.get(); } SortingStrategies(@NonNull final Supplier<String> readerAppName); Comparator<ApplicationInfo> forName(@NonNull final SortingStrategyName name);  }
@Test public void shouldReturnValidStrategyImplementationForName() { val nameAscStrategy = sortingStrategies.forName(SortingStrategyName.A_Z); assertThat(nameAscStrategy, is(instanceOf(NameInAscOrder.class))); val nameDescStrategy = sortingStrategies.forName(SortingStrategyName.Z_A); assertThat(nameDescStrategy, is(instanceOf(NameInDescOrder.class))); val readerAppFirstStrategy = sortingStrategies.forName(SortingStrategyName.READER_APP_FIRST); assertThat(readerAppFirstStrategy, is(instanceOf(ReaderApplicationFirst.class))); }