### Question:
AssetTagResolversImpl implements AssetTagResolvers { @Override public DataFetcher<AssetTag> deleteAssetTagDataFetcher() { return environment -> { long tagId = util.getLongArg(environment, "tagId"); return assetTagLocalService.deleteAssetTag(tagId); }; }  @Reference(unbind = "-") void setAssetTagLocalService(AssetTagLocalService assetTagLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<AssetTag>> getAssetTagsDataFetcher(); @Override DataFetcher<List<AssetTag>> getAssetTagsForAssetDataFetcher(); @Override DataFetcher<CompletableFuture<AssetTag>> getAssetTagDataFetcher(); @Override DataFetcher<AssetTag> createAssetTagDataFetcher(); @Override DataFetcher<AssetTag> updateAssetTagDataFetcher(); @Override DataFetcher<AssetTag> deleteAssetTagDataFetcher();  }### Answer:
@Test public void deleteAssetTagDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("tagId", TAG_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); AssetTag expectedResult = mock(AssetTag.class); expectedResult.setTagId(TAG_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteAssetTag(eq(TAG_ID))) .thenReturn(expectedResult); AssetTag result = resolvers.deleteAssetTagDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchTagException.class) public void deleteAssetTagDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); AssetTag expectedResult = mock(AssetTag.class); expectedResult.setTagId(TAG_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteAssetTag(eq(TAG_ID))) .thenThrow(NoSuchTagException.class); AssetTag result = resolvers.deleteAssetTagDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchTagException.class) public void deleteAssetTagDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("tagId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); AssetTag expectedResult = mock(AssetTag.class); expectedResult.setTagId(TAG_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("tagId"))) .thenReturn(789456L); when(localService.deleteAssetTag(eq(789456L))) .thenThrow(NoSuchTagException.class); AssetTag result = resolvers.deleteAssetTagDataFetcher() .get(environment); assertNull(result); }