### Question:
JournalFolderResolversImpl implements JournalFolderResolvers { @Override public DataFetcher<List<JournalFolder>> getJournalFoldersDataFetcher() { return environment -> { int start = util.getIntArg(environment, "start", 0); int end = util.getIntArg(environment, "end", 10); return journalFolderLocalService.getJournalFolders(start, end); }; }  @Reference(unbind = "-") void setJournalFolderLocalService(JournalFolderLocalService journalFolderLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<JournalFolder>> getJournalFoldersDataFetcher(); @Override DataFetcher<CompletableFuture<JournalFolder>> getJournalFolderDataFetcher(); @Override DataFetcher<JournalFolder> createJournalFolderDataFetcher(); @Override DataFetcher<JournalFolder> updateJournalFolderDataFetcher(); @Override DataFetcher<JournalFolder> deleteJournalFolderDataFetcher();  }### Answer:
@Test public void getJournalFoldersDataFetcher_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<JournalFolder> availableObjects = new ArrayList<>(); IntStream.rangeClosed(1, 20) .forEach(value -> { JournalFolder entity = mock(JournalFolder.class); entity.setFolderId(value); availableObjects.add(entity); }); List<JournalFolder> expectedResults = availableObjects.stream() .skip(3) .limit(3) .collect(Collectors.toList()); useSimpleGraphQLUtil(); when(localService.getJournalFolders(3, 3)) .thenReturn(expectedResults); List<JournalFolder> results = resolvers.getJournalFoldersDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }
@Test public void getJournalFoldersDataFetcher_without_args_should_return_10_first_objects() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); List<JournalFolder> availableObjects = new ArrayList<>(); IntStream.rangeClosed(1, 20) .forEach(value -> { JournalFolder entity = mock(JournalFolder.class); entity.setFolderId(value); availableObjects.add(entity); }); List<JournalFolder> expectedResults = availableObjects.stream() .skip(0) .limit(10) .collect(Collectors.toList()); useSimpleGraphQLUtil(); when(localService.getJournalFolders(0, 10)) .thenReturn(expectedResults); List<JournalFolder> results = resolvers.getJournalFoldersDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }
@Test public void getJournalFoldersDataFetcher_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<JournalFolder> expectedResults = new ArrayList<>(); IntStream.rangeClosed(1, 20) .forEach(value -> { JournalFolder entity = mock(JournalFolder.class); entity.setFolderId(value); expectedResults.add(entity); }); useSimpleGraphQLUtil(); when(localService.getJournalFolders(0, 100)) .thenReturn(expectedResults); List<JournalFolder> results = resolvers.getJournalFoldersDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }
@Test public void getJournalFoldersDataFetcher_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<JournalFolder> expectedResults = new ArrayList<>(); useSimpleGraphQLUtil(); when(localService.getJournalFolders(0, 100)) .thenReturn(expectedResults); List<JournalFolder> results = resolvers.getJournalFoldersDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }