### Question:
DLFileShortcutResolversImpl implements DLFileShortcutResolvers { @Override public DataFetcher<DLFileShortcut> deleteDLFileShortcutDataFetcher() { return environment -> { long fileShortcutId = util.getLongArg(environment, "fileShortcutId"); return dlFileShortcutLocalService.deleteDLFileShortcut(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 deleteDLFileShortcutDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("fileShortcutId", FILE_SHORTCUT_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); DLFileShortcut expectedResult = mock(DLFileShortcut.class); expectedResult.setFileShortcutId(FILE_SHORTCUT_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDLFileShortcut(eq(FILE_SHORTCUT_ID))) .thenReturn(expectedResult); DLFileShortcut result = resolvers.deleteDLFileShortcutDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchFileShortcutException.class) public void deleteDLFileShortcutDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); DLFileShortcut expectedResult = mock(DLFileShortcut.class); expectedResult.setFileShortcutId(FILE_SHORTCUT_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDLFileShortcut(eq(FILE_SHORTCUT_ID))) .thenThrow(NoSuchFileShortcutException.class); DLFileShortcut result = resolvers.deleteDLFileShortcutDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchFileShortcutException.class) public void deleteDLFileShortcutDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("fileShortcutId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); DLFileShortcut expectedResult = mock(DLFileShortcut.class); expectedResult.setFileShortcutId(FILE_SHORTCUT_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("fileShortcutId"))) .thenReturn(789456L); when(localService.deleteDLFileShortcut(eq(789456L))) .thenThrow(NoSuchFileShortcutException.class); DLFileShortcut result = resolvers.deleteDLFileShortcutDataFetcher() .get(environment); assertNull(result); }