TollBoothHiveDestinationAdminClient implements HiveDestinationAdminClient { @Override public void updateHiveDestination(String name, HiveDestination hiveDestination) throws UnknownRoadException, UnknownDestinationException { getHiveDestination(name).orElseThrow(() -> new UnknownDestinationException("Hive", name)); List<PatchOperation> operations = Collections .singletonList(PatchOperation.replace(DESTINATIONS_HIVE, hiveDestination)); PatchSet patchSet = new PatchSet(name, operations); modificationEmitter.emit(patchSet); } @Autowired  TollBoothHiveDestinationAdminClient(
      @Value("#{store}") Map<String, Road> roads,
      PatchSetEmitter modificationEmitter); @Override Optional<HiveDestination> getHiveDestination(String name); @Override void createHiveDestination(String name, HiveDestination hiveDestination); @Override void deleteHiveDestination(String name); @Override void updateHiveDestination(String name, HiveDestination hiveDestination);  }
@Test public void updateHiveDestination() throws Exception { destinations.put("hive", hiveDestination); road.setDestinations(destinations); store.put(NAME, road); HiveDestination updatedHiveDestination = new HiveDestination(); updatedHiveDestination.setEnabled(true); underTest.updateHiveDestination(NAME, updatedHiveDestination); assertThat(store.get(NAME).getDestinations().get("hive"), is(updatedHiveDestination)); }
@Test(expected = UnknownRoadException.class) public void updateHiveDestination_UnknownRoad() throws Exception { underTest.updateHiveDestination(NAME, hiveDestination); }
@Test(expected = UnknownDestinationException.class) public void updateHiveDestination_UnknownDestination() throws Exception { store.put(NAME, road); underTest.updateHiveDestination(NAME, hiveDestination); }
@Test(expected = UnknownRoadException.class) public void updateHiveDestination_deletedRoad() throws Exception { road.setDeleted(true); store.put(NAME, road); underTest.updateHiveDestination(NAME,hiveDestination); }