### Question:
JournalFeedResolversImpl implements JournalFeedResolvers { @Override public DataFetcher<List<JournalFeed>> getJournalFeedsDataFetcher() { return environment -> { int start = util.getIntArg(environment, "start", 0); int end = util.getIntArg(environment, "end", 10); return journalFeedLocalService.getJournalFeeds(start, end); }; }  @Reference(unbind = "-") void setJournalFeedLocalService(JournalFeedLocalService journalFeedLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<JournalFeed>> getJournalFeedsDataFetcher(); @Override DataFetcher<CompletableFuture<JournalFeed>> getJournalFeedDataFetcher(); @Override DataFetcher<JournalFeed> createJournalFeedDataFetcher(); @Override DataFetcher<JournalFeed> updateJournalFeedDataFetcher(); @Override DataFetcher<JournalFeed> deleteJournalFeedDataFetcher();  }### Answer:
@Test public void getJournalFeedsDataFetcher_should_return_the_specified_number_of_objects() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("start", 3); arguments.put("end", 3); DataFetchingEnvironment environment = getTestEnvironment(arguments); List<JournalFeed> availableObjects = new ArrayList<>(); IntStream.rangeClosed(1, 20) .forEach(value -> { JournalFeed entity = mock(JournalFeed.class); entity.setId(value); availableObjects.add(entity); }); List<JournalFeed> expectedResults = availableObjects.stream() .skip(3) .limit(3) .collect(Collectors.toList()); useSimpleGraphQLUtil(); when(localService.getJournalFeeds(3, 3)) .thenReturn(expectedResults); List<JournalFeed> results = resolvers.getJournalFeedsDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }
@Test public void getJournalFeedsDataFetcher_without_args_should_return_10_first_objects() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); List<JournalFeed> availableObjects = new ArrayList<>(); IntStream.rangeClosed(1, 20) .forEach(value -> { JournalFeed entity = mock(JournalFeed.class); entity.setId(value); availableObjects.add(entity); }); List<JournalFeed> expectedResults = availableObjects.stream() .skip(0) .limit(10) .collect(Collectors.toList()); useSimpleGraphQLUtil(); when(localService.getJournalFeeds(0, 10)) .thenReturn(expectedResults); List<JournalFeed> results = resolvers.getJournalFeedsDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }
@Test public void getJournalFeedsDataFetcher_with_big_range_args_should_return_only_available_objects() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("start", 0); arguments.put("end", 100); DataFetchingEnvironment environment = getTestEnvironment(arguments); List<JournalFeed> expectedResults = new ArrayList<>(); IntStream.rangeClosed(1, 20) .forEach(value -> { JournalFeed entity = mock(JournalFeed.class); entity.setId(value); expectedResults.add(entity); }); useSimpleGraphQLUtil(); when(localService.getJournalFeeds(0, 100)) .thenReturn(expectedResults); List<JournalFeed> results = resolvers.getJournalFeedsDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }
@Test public void getJournalFeedsDataFetcher_no_objects_available_should_return_empty_list() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("start", 0); arguments.put("end", 100); DataFetchingEnvironment environment = getTestEnvironment(arguments); List<JournalFeed> expectedResults = new ArrayList<>(); useSimpleGraphQLUtil(); when(localService.getJournalFeeds(0, 100)) .thenReturn(expectedResults); List<JournalFeed> results = resolvers.getJournalFeedsDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }