### Question:
RatingsEntryResolversImpl implements RatingsEntryResolvers { @Override public DataFetcher<RatingsEntry> deleteRatingsEntryDataFetcher() { return environment -> { long entryId = util.getLongArg(environment, "entryId"); return ratingsEntryLocalService.deleteRatingsEntry(entryId); }; }  @Reference(unbind = "-") void setRatingsEntryLocalService(RatingsEntryLocalService ratingsEntryLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<RatingsEntry>> getRatingsEntriesDataFetcher(); @Override DataFetcher<CompletableFuture<RatingsEntry>> getRatingsEntryDataFetcher(); @Override DataFetcher<RatingsEntry> createRatingsEntryDataFetcher(); @Override DataFetcher<RatingsEntry> deleteRatingsEntryDataFetcher();  }### Answer:
@Test public void deleteRatingsEntryDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("entryId", ENTRY_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); RatingsEntry expectedResult = mock(RatingsEntry.class); expectedResult.setEntryId(ENTRY_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteRatingsEntry(eq(ENTRY_ID))) .thenReturn(expectedResult); RatingsEntry result = resolvers.deleteRatingsEntryDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchEntryException.class) public void deleteRatingsEntryDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); RatingsEntry expectedResult = mock(RatingsEntry.class); expectedResult.setEntryId(ENTRY_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteRatingsEntry(eq(ENTRY_ID))) .thenThrow(NoSuchEntryException.class); RatingsEntry result = resolvers.deleteRatingsEntryDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchEntryException.class) public void deleteRatingsEntryDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("entryId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); RatingsEntry expectedResult = mock(RatingsEntry.class); expectedResult.setEntryId(ENTRY_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("entryId"))) .thenReturn(789456L); when(localService.deleteRatingsEntry(eq(789456L))) .thenThrow(NoSuchEntryException.class); RatingsEntry result = resolvers.deleteRatingsEntryDataFetcher() .get(environment); assertNull(result); }