### Question:
WebsiteResolversImpl implements WebsiteResolvers { @Override public DataFetcher<Website> deleteWebsiteDataFetcher() { return environment -> { long websiteId = util.getLongArg(environment, "websiteId"); return websiteLocalService.deleteWebsite(websiteId); }; }  @Reference(unbind = "-") void setWebsiteLocalService(WebsiteLocalService websiteLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<Website>> getWebsitesDataFetcher(); @Override DataFetcher<List<Website>> getWebsitesForEntityDataFetcher(); @Override DataFetcher<CompletableFuture<Website>> getWebsiteDataFetcher(); @Override DataFetcher<Website> createWebsiteDataFetcher(); @Override DataFetcher<Website> updateWebsiteDataFetcher(); @Override DataFetcher<Website> deleteWebsiteDataFetcher();  }### Answer:
@Test public void deleteWebsiteDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("websiteId", WEBSITE_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); Website expectedResult = mock(Website.class); expectedResult.setWebsiteId(WEBSITE_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteWebsite(eq(WEBSITE_ID))) .thenReturn(expectedResult); Website result = resolvers.deleteWebsiteDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchWebsiteException.class) public void deleteWebsiteDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); Website expectedResult = mock(Website.class); expectedResult.setWebsiteId(WEBSITE_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteWebsite(eq(WEBSITE_ID))) .thenThrow(NoSuchWebsiteException.class); Website result = resolvers.deleteWebsiteDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchWebsiteException.class) public void deleteWebsiteDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("websiteId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); Website expectedResult = mock(Website.class); expectedResult.setWebsiteId(WEBSITE_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("websiteId"))) .thenReturn(789456L); when(localService.deleteWebsite(eq(789456L))) .thenThrow(NoSuchWebsiteException.class); Website result = resolvers.deleteWebsiteDataFetcher() .get(environment); assertNull(result); }