### Question:
GroupResolversImpl implements GroupResolvers { @Override public DataFetcher<CompletableFuture<Group>> getGroupDataFetcher() { return environment -> { long groupId = getGroupId(environment); if (groupId <= 0) { return null; } DataLoader<Long, Group> dataLoader = environment.getDataLoader(GroupBatchLoader.KEY); return dataLoader.load(groupId); }; }  @Reference(unbind = "-") void setGroupLocalService(GroupLocalService groupLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<Group>> getGroupsDataFetcher(); @Override DataFetcher<CompletableFuture<Group>> getGroupDataFetcher(); @Override DataFetcher<Group> getGroupByKeyDataFetcher(); @Override DataFetcher<Group> createGroupDataFetcher(); @Override DataFetcher<Group> updateGroupDataFetcher(); @Override DataFetcher<Group> deleteGroupDataFetcher();  }### Answer:
@Test public void getGroupDataFetcher_should_return_the_searched_object() throws Exception { Group expectedResult = mock(Group.class); expectedResult.setGroupId(GROUP_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("groupId")) .thenReturn(GROUP_ID); when(dataLoader.load(GROUP_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<Group> asyncResult = resolvers.getGroupDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); Group result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getGroupDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("groupId")) .thenReturn(0L); CompletableFuture<Group> asyncResult = resolvers.getGroupDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getGroupDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("groupId")) .thenReturn(GROUP_ID); when(dataLoader.load(GROUP_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<Group> asyncResult = resolvers.getGroupDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); Group result = asyncResult.get(); assertNull(result); }