@Test public void applyPatch() throws Exception { final String partitionPath = "$.group"; when(roadAdminClient.getRoad(road.getName())).thenReturn(Optional.of(road)); List<PatchOperation> patchSet = Arrays.asList(PatchOperation.add("/partitionPath", partitionPath)); underTest.applyPatch(road.getName(), patchSet); 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.REPLACE)); assertThat(patch.getOperations().get(0).getPath(), is("/partitionPath")); assertThat(patch.getOperations().get(0).getValue(), is(partitionPath)); }
@Override public void applyPatch(String name, List<PatchOperation> modelOperations) throws UnknownRoadException { Road road = getRoadOrThrow(name); List<PatchOperation> operations = new ArrayList<>(); for (PatchOperation modelOperation : modelOperations) { PatchMapping mapping = patchMappings.get(modelOperation.getPath()); checkArgument(mapping != null, "\"%s\" is not a valid path to patch", modelOperation.getPath()); operations.add(mapping.convertOperation(road, modelOperation)); if(mapping instanceof EnabledPatchMapping) { operations.add(PatchOperation.add("/enabledTimeStamp", clock.instant().toEpochMilli())); } } roadAdminClient.updateRoad(new PatchSet(road.getName(), operations)); }
PaverServiceImpl implements PaverService { @Override public void applyPatch(String name, List<PatchOperation> modelOperations) throws UnknownRoadException { Road road = getRoadOrThrow(name); List<PatchOperation> operations = new ArrayList<>(); for (PatchOperation modelOperation : modelOperations) { PatchMapping mapping = patchMappings.get(modelOperation.getPath()); checkArgument(mapping != null, "\"%s\" is not a valid path to patch", modelOperation.getPath()); operations.add(mapping.convertOperation(road, modelOperation)); if(mapping instanceof EnabledPatchMapping) { operations.add(PatchOperation.add("/enabledTimeStamp", clock.instant().toEpochMilli())); } } roadAdminClient.updateRoad(new PatchSet(road.getName(), operations)); } }
PaverServiceImpl implements PaverService { @Override public void applyPatch(String name, List<PatchOperation> modelOperations) throws UnknownRoadException { Road road = getRoadOrThrow(name); List<PatchOperation> operations = new ArrayList<>(); for (PatchOperation modelOperation : modelOperations) { PatchMapping mapping = patchMappings.get(modelOperation.getPath()); checkArgument(mapping != null, "\"%s\" is not a valid path to patch", modelOperation.getPath()); operations.add(mapping.convertOperation(road, modelOperation)); if(mapping instanceof EnabledPatchMapping) { operations.add(PatchOperation.add("/enabledTimeStamp", clock.instant().toEpochMilli())); } } roadAdminClient.updateRoad(new PatchSet(road.getName(), operations)); } @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 applyPatch(String name, List<PatchOperation> modelOperations) throws UnknownRoadException { Road road = getRoadOrThrow(name); List<PatchOperation> operations = new ArrayList<>(); for (PatchOperation modelOperation : modelOperations) { PatchMapping mapping = patchMappings.get(modelOperation.getPath()); checkArgument(mapping != null, "\"%s\" is not a valid path to patch", modelOperation.getPath()); operations.add(mapping.convertOperation(road, modelOperation)); if(mapping instanceof EnabledPatchMapping) { operations.add(PatchOperation.add("/enabledTimeStamp", clock.instant().toEpochMilli())); } } roadAdminClient.updateRoad(new PatchSet(road.getName(), operations)); } @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 applyPatch(String name, List<PatchOperation> modelOperations) throws UnknownRoadException { Road road = getRoadOrThrow(name); List<PatchOperation> operations = new ArrayList<>(); for (PatchOperation modelOperation : modelOperations) { PatchMapping mapping = patchMappings.get(modelOperation.getPath()); checkArgument(mapping != null, "\"%s\" is not a valid path to patch", modelOperation.getPath()); operations.add(mapping.convertOperation(road, modelOperation)); if(mapping instanceof EnabledPatchMapping) { operations.add(PatchOperation.add("/enabledTimeStamp", clock.instant().toEpochMilli())); } } roadAdminClient.updateRoad(new PatchSet(road.getName(), operations)); } @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);  }