Source:
public void shouldChangeShapeIdOnPatternUpdate() throws IOException, SQLException, InvalidNamespaceException { String patternId = "10"; ShapePointDTO[] shapes = new ShapePointDTO[]{ new ShapePointDTO(2, 0.0, sharedShapeId, firstStopLat, firstStopLon, 0), new ShapePointDTO(2, 150.0, sharedShapeId, lastStopLat, lastStopLon, 1) }; PatternStopDTO[] patternStops = new PatternStopDTO[]{ new PatternStopDTO(patternId, firstStopId, 0), new PatternStopDTO(patternId, lastStopId, 1) }; PatternDTO simplePattern = createRouteAndPattern("1001", patternId, "The Line", sharedShapeId, shapes, patternStops, 0); assertThat(simplePattern.shape_id, equalTo(sharedShapeId)); String secondPatternId = "11"; patternStops[0].pattern_id = secondPatternId; patternStops[1].pattern_id = secondPatternId; PatternDTO patternWithSharedShape = createRouteAndPattern("1002", secondPatternId, "The Line 2", sharedShapeId, shapes, patternStops, 0); assertThat(patternWithSharedShape.shape_id, equalTo(sharedShapeId)); JdbcTableWriter patternUpdater = createTestTableWriter(Table.PATTERNS); patternWithSharedShape.name = "The shape_id should update"; String sharedPatternOutput = patternUpdater.update(patternWithSharedShape.id, mapper.writeValueAsString(patternWithSharedShape), true); PatternDTO updatedSharedPattern = mapper.readValue(sharedPatternOutput, PatternDTO.class); LOG.info("Updated pattern output: {}", sharedPatternOutput); String newShapeId = updatedSharedPattern.shape_id; assertThat(newShapeId, not(equalTo(sharedShapeId))); assertThatSqlQueryYieldsRowCount(String.format( "select * from %s.%s where shape_id='%s'", testNamespace, Table.PATTERNS.name, newShapeId ), 1); }

Target:
public void shouldChangeShapeIdOnPatternUpdate() throws IOException, SQLException, InvalidNamespaceException { String patternId = "10"; ShapePointDTO[] shapes = new ShapePointDTO[]{ new ShapePointDTO(2, 0.0, sharedShapeId, firstStopLat, firstStopLon, 0), new ShapePointDTO(2, 150.0, sharedShapeId, lastStopLat, lastStopLon, 1) }; PatternStopDTO[] patternStops = new PatternStopDTO[]{ new PatternStopDTO(patternId, firstStopId, 0), new PatternStopDTO(patternId, lastStopId, 1) }; PatternDTO simplePattern = createRouteAndPattern("1001", patternId, "The Line", sharedShapeId, shapes, patternStops, 0); assertThat(simplePattern.shape_id, equalTo(sharedShapeId)); String secondPatternId = "11"; patternStops[0].pattern_id = secondPatternId; patternStops[1].pattern_id = secondPatternId; PatternDTO patternWithSharedShape = createRouteAndPattern("1002", secondPatternId, "The Line 2", sharedShapeId, shapes, patternStops, 0); assertThat(patternWithSharedShape.shape_id, equalTo(sharedShapeId)); JdbcTableWriter patternUpdater = createTestTableWriter(Table.PATTERNS); patternWithSharedShape.name = "The shape_id should update"; String sharedPatternOutput = patternUpdater.update(patternWithSharedShape.id, mapper.writeValueAsString(patternWithSharedShape), true); PatternDTO updatedSharedPattern = mapper.readValue(sharedPatternOutput, PatternDTO.class); LOG.info("Updated pattern output: {}", sharedPatternOutput); String newShapeId = updatedSharedPattern.shape_id; assertThat(newShapeId, not(equalTo(sharedShapeId))); assertThatSqlQueryYieldsRowCount(String.format( "select * from %s.%s where shape_id='%s' and pattern_id='%s'", testNamespace, Table.PATTERNS.name, newShapeId, secondPatternId ), 1); }