### Question:
DLFileEntryResolversImpl implements DLFileEntryResolvers { @Override public DataFetcher<DLFileEntry> deleteDLFileEntryDataFetcher() { return environment -> { long fileEntryId = util.getLongArg(environment, "fileEntryId"); return dlFileEntryLocalService.deleteDLFileEntry(fileEntryId); }; }  @Reference(unbind = "-") void setDLFileEntryLocalService(DLFileEntryLocalService dlFileEntryLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DLFileEntry>> getDLFileEntriesDataFetcher(); @Override DataFetcher<CompletableFuture<DLFileEntry>> getDLFileEntryDataFetcher(); @Override DataFetcher<DLFileEntry> createDLFileEntryDataFetcher(); @Override DataFetcher<DLFileEntry> updateDLFileEntryDataFetcher(); @Override DataFetcher<DLFileEntry> deleteDLFileEntryDataFetcher();  }### Answer:
@Test public void deleteDLFileEntryDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("fileEntryId", FILE_ENTRY_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); DLFileEntry expectedResult = mock(DLFileEntry.class); expectedResult.setFileEntryId(FILE_ENTRY_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDLFileEntry(eq(FILE_ENTRY_ID))) .thenReturn(expectedResult); DLFileEntry result = resolvers.deleteDLFileEntryDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchFileEntryException.class) public void deleteDLFileEntryDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); DLFileEntry expectedResult = mock(DLFileEntry.class); expectedResult.setFileEntryId(FILE_ENTRY_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDLFileEntry(eq(FILE_ENTRY_ID))) .thenThrow(NoSuchFileEntryException.class); DLFileEntry result = resolvers.deleteDLFileEntryDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchFileEntryException.class) public void deleteDLFileEntryDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("fileEntryId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); DLFileEntry expectedResult = mock(DLFileEntry.class); expectedResult.setFileEntryId(FILE_ENTRY_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("fileEntryId"))) .thenReturn(789456L); when(localService.deleteDLFileEntry(eq(789456L))) .thenThrow(NoSuchFileEntryException.class); DLFileEntry result = resolvers.deleteDLFileEntryDataFetcher() .get(environment); assertNull(result); }