@Test public void deleteRoad() throws Exception { when(roadAdminClient.getRoad(road.getName())).thenReturn(Optional.of(road)); MessageStatus m = new MessageStatus(); m.setLastUpdated(100); m.setNumberOfMessages(0); road.setMessageStatus(m); road.setEnabledTimeStamp(99); underTest.deleteRoad(road.getName()); ArgumentCaptor<PatchSet> patchCaptor = ArgumentCaptor.forClass(PatchSet.class); verify(roadAdminClient).updateRoad(patchCaptor.capture()); PatchSet patch = patchCaptor.getValue(); assertThat(patch.getDocumentId(), is(road.getName())); assertThat(patch.getOperations().size(), is(1)); assertThat(patch.getOperations().get(0).getOperation(), is(Operation.ADD)); assertThat(patch.getOperations().get(0).getPath(), is("/deleted")); assertThat(patch.getOperations().get(0).getValue(), is(true)); }
@Override public void deleteRoad(String name) throws UnknownRoadException { Road road = getRoadOrThrow(name); if(zeroActiveDestination(road.getDestinations()) && hasNoMessages(road)) { roadAdminClient.updateRoad(new PatchSet(road.getName(), singletonList(PatchOperation.add("/deleted",true)))); } else { throw new IllegalArgumentException("Road " + name + " can't be deleted. Make sure there are no active destinations, " + "the road is disabled and there are no messages for this road"); } }
PaverServiceImpl implements PaverService { @Override public void deleteRoad(String name) throws UnknownRoadException { Road road = getRoadOrThrow(name); if(zeroActiveDestination(road.getDestinations()) && hasNoMessages(road)) { roadAdminClient.updateRoad(new PatchSet(road.getName(), singletonList(PatchOperation.add("/deleted",true)))); } else { throw new IllegalArgumentException("Road " + name + " can't be deleted. Make sure there are no active destinations, " + "the road is disabled and there are no messages for this road"); } } }
PaverServiceImpl implements PaverService { @Override public void deleteRoad(String name) throws UnknownRoadException { Road road = getRoadOrThrow(name); if(zeroActiveDestination(road.getDestinations()) && hasNoMessages(road)) { roadAdminClient.updateRoad(new PatchSet(road.getName(), singletonList(PatchOperation.add("/deleted",true)))); } else { throw new IllegalArgumentException("Road " + name + " can't be deleted. Make sure there are no active destinations, " + "the road is disabled and there are no messages for this road"); } } @Autowired  PaverServiceImpl(
      RoadAdminClient roadAdminClient,
      SchemaStoreClient schemaStoreClient,
      CidrBlockValidator cidrBlockBValidator,
      List<PatchMapping> mappings,
      RoadSchemaNotificationHandler roadSchemaNotificationHandler,
      @Value("${destinations.hive.autoCreate:true}") boolean autoCreateHiveDestination,
      @Value("#{clock}") Clock clock); }
PaverServiceImpl implements PaverService { @Override public void deleteRoad(String name) throws UnknownRoadException { Road road = getRoadOrThrow(name); if(zeroActiveDestination(road.getDestinations()) && hasNoMessages(road)) { roadAdminClient.updateRoad(new PatchSet(road.getName(), singletonList(PatchOperation.add("/deleted",true)))); } else { throw new IllegalArgumentException("Road " + name + " can't be deleted. Make sure there are no active destinations, " + "the road is disabled and there are no messages for this road"); } } @Autowired  PaverServiceImpl(
      RoadAdminClient roadAdminClient,
      SchemaStoreClient schemaStoreClient,
      CidrBlockValidator cidrBlockBValidator,
      List<PatchMapping> mappings,
      RoadSchemaNotificationHandler roadSchemaNotificationHandler,
      @Value("${destinations.hive.autoCreate:true}") boolean autoCreateHiveDestination,
      @Value("#{clock}") Clock clock); @Override SortedSet<String> getRoadNames(); @Override void createRoad(BasicRoadModel basicModel); @Override RoadModel getRoad(String name); @Override void applyPatch(String name, List<PatchOperation> modelOperations); @Override Map<Integer, Schema> getActiveSchemas(String name); @Override SchemaVersion getActiveSchema(String name, int version); @Override SchemaVersion getLatestActiveSchema(String name); @Override SchemaVersion addSchema(String name, Schema schema); @Override SchemaVersion addSchema(String name, Schema schema, int version); @Override void deleteSchemaVersion(String name, int version); @Override void deleteRoad(String name); }
PaverServiceImpl implements PaverService { @Override public void deleteRoad(String name) throws UnknownRoadException { Road road = getRoadOrThrow(name); if(zeroActiveDestination(road.getDestinations()) && hasNoMessages(road)) { roadAdminClient.updateRoad(new PatchSet(road.getName(), singletonList(PatchOperation.add("/deleted",true)))); } else { throw new IllegalArgumentException("Road " + name + " can't be deleted. Make sure there are no active destinations, " + "the road is disabled and there are no messages for this road"); } } @Autowired  PaverServiceImpl(
      RoadAdminClient roadAdminClient,
      SchemaStoreClient schemaStoreClient,
      CidrBlockValidator cidrBlockBValidator,
      List<PatchMapping> mappings,
      RoadSchemaNotificationHandler roadSchemaNotificationHandler,
      @Value("${destinations.hive.autoCreate:true}") boolean autoCreateHiveDestination,
      @Value("#{clock}") Clock clock); @Override SortedSet<String> getRoadNames(); @Override void createRoad(BasicRoadModel basicModel); @Override RoadModel getRoad(String name); @Override void applyPatch(String name, List<PatchOperation> modelOperations); @Override Map<Integer, Schema> getActiveSchemas(String name); @Override SchemaVersion getActiveSchema(String name, int version); @Override SchemaVersion getLatestActiveSchema(String name); @Override SchemaVersion addSchema(String name, Schema schema); @Override SchemaVersion addSchema(String name, Schema schema, int version); @Override void deleteSchemaVersion(String name, int version); @Override void deleteRoad(String name);  }