### Question:
RegionResolversImpl implements RegionResolvers { @Override public DataFetcher<List<Region>> getRegionsDataFetcher() { return environment -> { boolean active = util.getBooleanArg(environment, "active", true); return regionService.getRegions(active); }; }  @Reference(unbind = "-") void setRegionService(RegionService regionService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<Region>> getRegionsDataFetcher(); @Override DataFetcher<Region> getRegionDataFetcher(); @Override DataFetcher<Region> getRegionByCodeDataFetcher(); @Override DataFetcher<Region> createRegionDataFetcher();  }### Answer:
@Test public void getRegionsDataFetcher_should_return_the_active_objects() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("active", ACTIVE); DataFetchingEnvironment environment = getTestEnvironment(arguments); List<Region> availableObjects = new ArrayList<>(); IntStream.rangeClosed(1, 20) .forEach(value -> { Region entity = mock(Region.class); entity.setRegionId(value); entity.setActive(random.nextBoolean()); availableObjects.add(entity); }); List<Region> expectedResults = availableObjects.stream() .filter(Region::getActive) .collect(Collectors.toList()); useSimpleGraphQLUtil(); when(localService.getRegions(ACTIVE)) .thenReturn(expectedResults); List<Region> results = resolvers.getRegionsDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }
@Test public void getRegionsDataFetcher_without_args_should_return_the_active_objects() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); List<Region> availableObjects = new ArrayList<>(); IntStream.rangeClosed(1, 20) .forEach(value -> { Region entity = mock(Region.class); entity.setRegionId(value); entity.setActive(random.nextBoolean()); availableObjects.add(entity); }); List<Region> expectedResults = availableObjects.stream() .filter(Region::getActive) .collect(Collectors.toList()); useSimpleGraphQLUtil(); when(localService.getRegions(ACTIVE)) .thenReturn(expectedResults); List<Region> results = resolvers.getRegionsDataFetcher() .get(environment); assertNotNull(results); assertEquals(expectedResults, results); }