### Question:
DLFileShortcutResolversImpl implements DLFileShortcutResolvers { @Override public DataFetcher<CompletableFuture<DLFileShortcut>> getDLFileShortcutDataFetcher() { return environment -> { long fileShortcutId = util.getLongArg(environment, "fileShortcutId"); if (fileShortcutId <= 0) { return null; } DataLoader<Long, DLFileShortcut> dataLoader = environment.getDataLoader(DLFileShortcutBatchLoader.KEY); return dataLoader.load(fileShortcutId); }; }  @Reference(unbind = "-") void setDLFileShortcutLocalService(DLFileShortcutLocalService dlFileShortcutLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DLFileShortcut>> getDLFileShortcutsDataFetcher(); @Override DataFetcher<CompletableFuture<DLFileShortcut>> getDLFileShortcutDataFetcher(); @Override DataFetcher<DLFileShortcut> createDLFileShortcutDataFetcher(); @Override DataFetcher<DLFileShortcut> updateDLFileShortcutDataFetcher(); @Override DataFetcher<DLFileShortcut> deleteDLFileShortcutDataFetcher();  }### Answer:
@Test public void getDLFileShortcutDataFetcher_should_return_the_searched_object() throws Exception { DLFileShortcut expectedResult = mock(DLFileShortcut.class); expectedResult.setFileShortcutId(FILE_SHORTCUT_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileShortcutId")) .thenReturn(FILE_SHORTCUT_ID); when(dataLoader.load(FILE_SHORTCUT_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<DLFileShortcut> asyncResult = resolvers.getDLFileShortcutDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFileShortcut result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getDLFileShortcutDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("fileShortcutId")) .thenReturn(0L); CompletableFuture<DLFileShortcut> asyncResult = resolvers.getDLFileShortcutDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getDLFileShortcutDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileShortcutId")) .thenReturn(FILE_SHORTCUT_ID); when(dataLoader.load(FILE_SHORTCUT_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<DLFileShortcut> asyncResult = resolvers.getDLFileShortcutDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFileShortcut result = asyncResult.get(); assertNull(result); }