### Question:
ExpandoRowResolversImpl implements ExpandoRowResolvers { @Override public DataFetcher<CompletableFuture<ExpandoRow>> getExpandoRowDataFetcher() { return environment -> { long rowId = getRowId(environment); if (rowId <= 0) { return null; } DataLoader<Long, ExpandoRow> dataLoader = environment.getDataLoader(ExpandoRowBatchLoader.KEY); return dataLoader.load(rowId); }; }  @Reference(unbind = "-") void setExpandoRowLocalService(ExpandoRowLocalService expandoRowLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<ExpandoRow>> getExpandoRowsDataFetcher(); @Override DataFetcher<CompletableFuture<ExpandoRow>> getExpandoRowDataFetcher(); @Override DataFetcher<ExpandoRow> createExpandoRowDataFetcher(); @Override DataFetcher<ExpandoRow> deleteExpandoRowDataFetcher();  }### Answer:
@Test public void getExpandoRowDataFetcher_should_return_the_searched_object() throws Exception { ExpandoRow expectedResult = mock(ExpandoRow.class); expectedResult.setRowId(ROW_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("rowId")) .thenReturn(ROW_ID); when(dataLoader.load(ROW_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<ExpandoRow> asyncResult = resolvers.getExpandoRowDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); ExpandoRow result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getExpandoRowDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("rowId")) .thenReturn(0L); CompletableFuture<ExpandoRow> asyncResult = resolvers.getExpandoRowDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getExpandoRowDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("rowId")) .thenReturn(ROW_ID); when(dataLoader.load(ROW_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<ExpandoRow> asyncResult = resolvers.getExpandoRowDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); ExpandoRow result = asyncResult.get(); assertNull(result); }