PopulateHelper { public static void populateRouteReaders(Map<Boolean, List<Reader>> readers, InternalRoute route) { if (nonNull(route.getRequestType())) { readers.get(TRUE).stream().distinct() .filter(transformer -> transformer.isReaderCompatible(route)) .forEach(route::addReader); readers.get(FALSE).stream().distinct() .filter(reader -> reader.isReaderCompatible(route)) .forEach(route::addReader); } }  static void populateRouteReaders(Map<Boolean, List<Reader>> readers, InternalRoute route); static void populateRouteWriters(Map<Boolean, List<Writer>> writers, InternalRoute route); static void populateHandlerWriters(Map<Boolean, List<Writer>> writers, InternalExceptionHandler handler,
                                              boolean condition);  }
@Test public void populate_readers_null() throws Exception { List<Reader> readers = Arrays.asList(new FirstReader(), new SecondReader(), new GeneralReader()); Map<Boolean, List<Reader>> transformers = createTransformers(readers); InternalRoute route = basicRoute(); populateRouteReaders(transformers, route); assertEquals(emptyMap(), route.getReaders()); }
@Test public void populate_readers() throws Exception { List<Reader> readers = Arrays.asList(new FirstReader(), new SecondReader(), new GeneralReader()); Map<Boolean, List<Reader>> transformers = createTransformers(readers); InternalRoute route = basicRoute(); populateRouteReaders(transformers, route); assertNull(route.getReaders().get(MediaType.of("reader/FIRST"))); assertNull(route.getReaders().get(MediaType.of("reader/SECOND"))); assertNull(route.getReaders().get(MediaType.of("reader/GENERAL"))); }