@Test public void getRoad_returns_empty_optional_when_road_isDeleted() throws Exception { road1.setDeleted(true); store.put(road1.getName(), road1); Optional<Road> road = client.getRoad(road1.getName()); assertFalse(road.isPresent()); }
@Override public Optional<Road> getRoad(String name) throws IllegalArgumentException, ServiceException { checkNotBlank(name, "name"); Road road = store.get(name); if(road == null || road.isDeleted()) { return Optional.empty(); } return Optional.ofNullable(road); }
TollboothRoadAdminClient implements RoadAdminClient { @Override public Optional<Road> getRoad(String name) throws IllegalArgumentException, ServiceException { checkNotBlank(name, "name"); Road road = store.get(name); if(road == null || road.isDeleted()) { return Optional.empty(); } return Optional.ofNullable(road); } }
TollboothRoadAdminClient implements RoadAdminClient { @Override public Optional<Road> getRoad(String name) throws IllegalArgumentException, ServiceException { checkNotBlank(name, "name"); Road road = store.get(name); if(road == null || road.isDeleted()) { return Optional.empty(); } return Optional.ofNullable(road); } @Autowired  TollboothRoadAdminClient(@Value("#{store}") Map<String, Road> store, PatchSetEmitter modificationEmitter); }
TollboothRoadAdminClient implements RoadAdminClient { @Override public Optional<Road> getRoad(String name) throws IllegalArgumentException, ServiceException { checkNotBlank(name, "name"); Road road = store.get(name); if(road == null || road.isDeleted()) { return Optional.empty(); } return Optional.ofNullable(road); } @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); }
TollboothRoadAdminClient implements RoadAdminClient { @Override public Optional<Road> getRoad(String name) throws IllegalArgumentException, ServiceException { checkNotBlank(name, "name"); Road road = store.get(name); if(road == null || road.isDeleted()) { return Optional.empty(); } return Optional.ofNullable(road); } @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);  }