### Question:
AssetCategoryResolversImpl implements AssetCategoryResolvers { @Override public DataFetcher<AssetCategory> deleteAssetCategoryDataFetcher() { return environment -> { long categoryId = util.getLongArg(environment, "categoryId"); return assetCategoryLocalService.deleteAssetCategory(categoryId); }; }  @Reference(unbind = "-") void setAssetCategoryLocalService(AssetCategoryLocalService assetCategoryLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<AssetCategory>> getAssetCategoriesDataFetcher(); @Override DataFetcher<List<AssetCategory>> getAssetCategoriesForAssetDataFetcher(); @Override DataFetcher<CompletableFuture<AssetCategory>> getAssetCategoryDataFetcher(); @Override DataFetcher<AssetCategory> createAssetCategoryDataFetcher(); @Override DataFetcher<AssetCategory> updateAssetCategoryDataFetcher(); @Override DataFetcher<AssetCategory> deleteAssetCategoryDataFetcher();  }### Answer:
@Test public void deleteAssetCategoryDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("categoryId", CATEGORY_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); AssetCategory expectedResult = mock(AssetCategory.class); expectedResult.setCategoryId(CATEGORY_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteAssetCategory(eq(CATEGORY_ID))) .thenReturn(expectedResult); AssetCategory result = resolvers.deleteAssetCategoryDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchCategoryException.class) public void deleteAssetCategoryDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); AssetCategory expectedResult = mock(AssetCategory.class); expectedResult.setCategoryId(CATEGORY_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteAssetCategory(eq(CATEGORY_ID))) .thenThrow(NoSuchCategoryException.class); AssetCategory result = resolvers.deleteAssetCategoryDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchCategoryException.class) public void deleteAssetCategoryDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("categoryId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); AssetCategory expectedResult = mock(AssetCategory.class); expectedResult.setCategoryId(CATEGORY_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("categoryId"))) .thenReturn(789456L); when(localService.deleteAssetCategory(eq(789456L))) .thenThrow(NoSuchCategoryException.class); AssetCategory result = resolvers.deleteAssetCategoryDataFetcher() .get(environment); assertNull(result); }