### Question:
AssetTagResolversImpl implements AssetTagResolvers { @Override public DataFetcher<CompletableFuture<AssetTag>> getAssetTagDataFetcher() { return environment -> { long tagId = util.getLongArg(environment, "tagId"); if (tagId <= 0) { return null; } DataLoader<Long, AssetTag> dataLoader = environment.getDataLoader(AssetTagBatchLoader.KEY); return dataLoader.load(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 getAssetTagDataFetcher_should_return_the_searched_object() throws Exception { AssetTag expectedResult = mock(AssetTag.class); expectedResult.setTagId(TAG_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("tagId")) .thenReturn(TAG_ID); when(dataLoader.load(TAG_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<AssetTag> asyncResult = resolvers.getAssetTagDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); AssetTag result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getAssetTagDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("tagId")) .thenReturn(0L); CompletableFuture<AssetTag> asyncResult = resolvers.getAssetTagDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getAssetTagDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("tagId")) .thenReturn(TAG_ID); when(dataLoader.load(TAG_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<AssetTag> asyncResult = resolvers.getAssetTagDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); AssetTag result = asyncResult.get(); assertNull(result); }