### Question:
AssetLinkResolversImpl implements AssetLinkResolvers { @Override public DataFetcher<CompletableFuture<AssetLink>> getAssetLinkDataFetcher() { return environment -> { long linkId = util.getLongArg(environment, "linkId"); if (linkId <= 0) { return null; } DataLoader<Long, AssetLink> dataLoader = environment.getDataLoader(AssetLinkBatchLoader.KEY); return dataLoader.load(linkId); }; }  @Reference(unbind = "-") void setAssetLinkLocalService(AssetLinkLocalService assetLinkLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<AssetLink>> getAssetLinksDataFetcher(); @Override DataFetcher<CompletableFuture<AssetLink>> getAssetLinkDataFetcher(); @Override DataFetcher<AssetLink> createAssetLinkDataFetcher(); @Override DataFetcher<AssetLink> updateAssetLinkDataFetcher(); @Override DataFetcher<AssetLink> deleteAssetLinkDataFetcher();  }### Answer:
@Test public void getAssetLinkDataFetcher_should_return_the_searched_object() throws Exception { AssetLink expectedResult = mock(AssetLink.class); expectedResult.setLinkId(LINK_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("linkId")) .thenReturn(LINK_ID); when(dataLoader.load(LINK_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<AssetLink> asyncResult = resolvers.getAssetLinkDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); AssetLink result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getAssetLinkDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("linkId")) .thenReturn(0L); CompletableFuture<AssetLink> asyncResult = resolvers.getAssetLinkDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getAssetLinkDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("linkId")) .thenReturn(LINK_ID); when(dataLoader.load(LINK_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<AssetLink> asyncResult = resolvers.getAssetLinkDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); AssetLink result = asyncResult.get(); assertNull(result); }