### Question:
AssetVocabularyResolversImpl implements AssetVocabularyResolvers { @Override public DataFetcher<AssetVocabulary> deleteAssetVocabularyDataFetcher() { return environment -> { long vocabularyId = util.getLongArg(environment, "vocabularyId"); return assetVocabularyLocalService.deleteAssetVocabulary(vocabularyId); }; }  @Reference(unbind = "-") void setAssetVocabularyLocalService(AssetVocabularyLocalService assetVocabularyLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<AssetVocabulary>> getAssetVocabulariesDataFetcher(); @Override DataFetcher<CompletableFuture<AssetVocabulary>> getAssetVocabularyDataFetcher(); @Override DataFetcher<AssetVocabulary> createAssetVocabularyDataFetcher(); @Override DataFetcher<AssetVocabulary> updateAssetVocabularyDataFetcher(); @Override DataFetcher<AssetVocabulary> deleteAssetVocabularyDataFetcher();  }### Answer:
@Test public void deleteAssetVocabularyDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("vocabularyId", VOCABULARY_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); AssetVocabulary expectedResult = mock(AssetVocabulary.class); expectedResult.setVocabularyId(VOCABULARY_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteAssetVocabulary(eq(VOCABULARY_ID))) .thenReturn(expectedResult); AssetVocabulary result = resolvers.deleteAssetVocabularyDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchVocabularyException.class) public void deleteAssetVocabularyDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); AssetVocabulary expectedResult = mock(AssetVocabulary.class); expectedResult.setVocabularyId(VOCABULARY_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteAssetVocabulary(eq(VOCABULARY_ID))) .thenThrow(NoSuchVocabularyException.class); AssetVocabulary result = resolvers.deleteAssetVocabularyDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchVocabularyException.class) public void deleteAssetVocabularyDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("vocabularyId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); AssetVocabulary expectedResult = mock(AssetVocabulary.class); expectedResult.setVocabularyId(VOCABULARY_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("vocabularyId"))) .thenReturn(789456L); when(localService.deleteAssetVocabulary(eq(789456L))) .thenThrow(NoSuchVocabularyException.class); AssetVocabulary result = resolvers.deleteAssetVocabularyDataFetcher() .get(environment); assertNull(result); }