Source:
<code>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( <START> "select * from %s.%s where shape_id='%s'", <END> testNamespace, Table.PATTERNS.name, newShapeId ), 1); }</code><technical_language>I there, this assertion pass if pattern patternId updated of newShapeId. This improved adding a clause for pattern id a more exact expectation of data integrity happen</technical_language>

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); }