public static List<UpdateRequirement> forUpdateTable(
      TableMetadata base, List<MetadataUpdate> metadataUpdates) {
    Preconditions.checkArgument(null != base, "Invalid table metadata: null");
    Preconditions.checkArgument(null != metadataUpdates, "Invalid metadata updates: null");
    Builder builder = new Builder(base, false);
    builder.require(new UpdateRequirement.AssertTableUUID(base.uuid()));
    metadataUpdates.forEach(builder::update);
    return builder.build();
  }
@Test
  public void addPartitionSpec() {
    int lastAssignedPartitionId = 3;
    when(metadata.lastAssignedPartitionId()).thenReturn(lastAssignedPartitionId);
    Schema schema = new Schema(required(3, "id", Types.IntegerType.get()));
    List<UpdateRequirement> requirements =
        UpdateRequirements.forUpdateTable(
            metadata,
            ImmutableList.of(
                new MetadataUpdate.AddPartitionSpec(
                    PartitionSpec.builderFor(schema).withSpecId(lastAssignedPartitionId).build()),
                new MetadataUpdate.AddPartitionSpec(
                    PartitionSpec.builderFor(schema)
                        .withSpecId(lastAssignedPartitionId + 1)
                        .build()),
                new MetadataUpdate.AddPartitionSpec(
                    PartitionSpec.builderFor(schema)
                        .withSpecId(lastAssignedPartitionId + 2)
                        .build())));
    requirements.forEach(req -> req.validate(metadata));

    assertThat(requirements)
        .hasSize(2)
        .hasOnlyElementsOfTypes(
            UpdateRequirement.AssertTableUUID.class,
            UpdateRequirement.AssertLastAssignedPartitionId.class);

    assertTableUUID(requirements);

    assertThat(requirements)
        .element(1)
        .asInstanceOf(
            InstanceOfAssertFactories.type(UpdateRequirement.AssertLastAssignedPartitionId.class))
        .extracting(UpdateRequirement.AssertLastAssignedPartitionId::lastAssignedPartitionId)
        .isEqualTo(lastAssignedPartitionId);
  }