### Question:
JournalFolderResolversImpl implements JournalFolderResolvers { @Override public DataFetcher<CompletableFuture<JournalFolder>> getJournalFolderDataFetcher() { return environment -> { long folderId = getFolderId(environment); if (folderId <= 0) { return null; } DataLoader<Long, JournalFolder> dataLoader = environment.getDataLoader(JournalFolderBatchLoader.KEY); return dataLoader.load(folderId); }; }  @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 getJournalFolderDataFetcher_should_return_the_searched_object() throws Exception { JournalFolder expectedResult = mock(JournalFolder.class); expectedResult.setFolderId(FOLDER_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("folderId")) .thenReturn(FOLDER_ID); when(dataLoader.load(FOLDER_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<JournalFolder> asyncResult = resolvers.getJournalFolderDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); JournalFolder result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getJournalFolderDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("folderId")) .thenReturn(0L); CompletableFuture<JournalFolder> asyncResult = resolvers.getJournalFolderDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getJournalFolderDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("folderId")) .thenReturn(FOLDER_ID); when(dataLoader.load(FOLDER_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<JournalFolder> asyncResult = resolvers.getJournalFolderDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); JournalFolder result = asyncResult.get(); assertNull(result); }