TollboothRoadAdminClient implements RoadAdminClient { @Override public SortedSet<String> listRoads() throws ServiceException { return ImmutableSortedSet.copyOf(store.entrySet().stream().filter(r -> !r.getValue().isDeleted()) .map(x -> x.getKey()).collect(Collectors.toSet())); } @Autowired  TollboothRoadAdminClient(@Value("#{store}") Map<String, Road> store, PatchSetEmitter modificationEmitter); @Override SortedSet<String> listRoads(); @Override Optional<Road> getRoad(String name); @Override void createRoad(Road road); @Override void updateRoad(PatchSet patchSet);  }
@Test public void listRoads() throws Exception { Set<String> roads; roads = client.listRoads(); assertTrue(roads.isEmpty()); store.put("road1", road1); roads = client.listRoads(); assertThat(roads.size(), is(1)); assertTrue(roads.contains("road1")); }
@Test public void listRoads_deleted() throws Exception { road1.setDeleted(true); store.put("road1", road1); Set<String> roads; roads = client.listRoads(); assertTrue(roads.isEmpty()); }