### Question:
AssetVocabularyResolversImpl implements AssetVocabularyResolvers { @Override public DataFetcher<CompletableFuture<AssetVocabulary>> getAssetVocabularyDataFetcher() { return environment -> { long vocabularyId = getVocabularyId(environment); if (vocabularyId <= 0) { return null; } DataLoader<Long, AssetVocabulary> dataLoader = environment.getDataLoader(AssetVocabularyBatchLoader.KEY); return dataLoader.load(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 getAssetVocabularyDataFetcher_should_return_the_searched_object() throws Exception { AssetVocabulary expectedResult = mock(AssetVocabulary.class); expectedResult.setVocabularyId(3L); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("vocabularyId")) .thenReturn(3L); when(dataLoader.load(3L)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<AssetVocabulary> asyncResult = resolvers.getAssetVocabularyDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); AssetVocabulary result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getAssetVocabularyDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("vocabularyId")) .thenReturn(0L); CompletableFuture<AssetVocabulary> asyncResult = resolvers.getAssetVocabularyDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getAssetVocabularyDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("vocabularyId")) .thenReturn(3L); when(dataLoader.load(3L)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<AssetVocabulary> asyncResult = resolvers.getAssetVocabularyDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); AssetVocabulary result = asyncResult.get(); assertNull(result); }