### Question:
JournalArticleResolversImpl implements JournalArticleResolvers { @Override public DataFetcher<JournalArticle> deleteJournalArticleDataFetcher() { return environment -> { long id = util.getLongArg(environment, "id"); return journalArticleLocalService.deleteJournalArticle(id); }; }  @Reference(unbind = "-") void setJournalArticleLocalService(JournalArticleLocalService journalArticleLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<JournalArticle>> getJournalArticlesDataFetcher(); @Override DataFetcher<CompletableFuture<JournalArticle>> getJournalArticleDataFetcher(); @Override DataFetcher<JournalArticle> createJournalArticleDataFetcher(); @Override DataFetcher<JournalArticle> updateJournalArticleDataFetcher(); @Override DataFetcher<JournalArticle> deleteJournalArticleDataFetcher();  }### Answer:
@Test public void deleteJournalArticleDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("id", ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); JournalArticle expectedResult = mock(JournalArticle.class); expectedResult.setId(ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteJournalArticle(eq(ID))) .thenReturn(expectedResult); JournalArticle result = resolvers.deleteJournalArticleDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchArticleException.class) public void deleteJournalArticleDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); JournalArticle expectedResult = mock(JournalArticle.class); expectedResult.setId(ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteJournalArticle(eq(ID))) .thenThrow(NoSuchArticleException.class); JournalArticle result = resolvers.deleteJournalArticleDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchArticleException.class) public void deleteJournalArticleDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("id", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); JournalArticle expectedResult = mock(JournalArticle.class); expectedResult.setId(ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("id"))) .thenReturn(789456L); when(localService.deleteJournalArticle(eq(789456L))) .thenThrow(NoSuchArticleException.class); JournalArticle result = resolvers.deleteJournalArticleDataFetcher() .get(environment); assertNull(result); }