Search in sources :

Example 26 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class MetaDataValidatorTest method badIndexLastModifiedVersion.

@Test
public void badIndexLastModifiedVersion() {
    RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
    metaData.getIndex("MySimpleRecord$str_value_indexed").setLastModifiedVersion(metaData.getVersion() + 1);
    assertInvalid("Index MySimpleRecord$str_value_indexed has last modified version " + (metaData.getVersion() + 1) + " which is greater than the meta-data version " + metaData.getVersion(), metaData);
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder) Test(org.junit.jupiter.api.Test)

Example 27 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class MetaDataValidatorTest method duplicateIntegralFormerAndCurrentSubspaceKeys.

@Test
public void duplicateIntegralFormerAndCurrentSubspaceKeys() {
    RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
    metaData.getIndex("MySimpleRecord$str_value_indexed").setSubspaceKey(42L);
    metaData.removeIndex("MySimpleRecord$str_value_indexed");
    metaData.getIndex("MySimpleRecord$num_value_3_indexed").setSubspaceKey(42);
    assertInvalid("Same subspace key 42 used by index MySimpleRecord$num_value_3_indexed and former index MySimpleRecord$str_value_indexed", metaData);
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder) Test(org.junit.jupiter.api.Test)

Example 28 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class MetaDataValidatorTest method indexAddedAfterLastModifiedVersion.

@Test
public void indexAddedAfterLastModifiedVersion() {
    RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
    metaData.getIndex("MySimpleRecord$str_value_indexed").setAddedVersion(metaData.getVersion());
    metaData.getIndex("MySimpleRecord$str_value_indexed").setLastModifiedVersion(metaData.getVersion() - 1);
    assertInvalid("Index MySimpleRecord$str_value_indexed has added version " + metaData.getVersion() + " which is greater than the last modified version " + (metaData.getVersion() - 1), metaData);
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder) Test(org.junit.jupiter.api.Test)

Example 29 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class MetaDataValidatorTest method duplicateFormerSubspaceKey.

@Test
public void duplicateFormerSubspaceKey() {
    RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
    metaData.getIndex("MySimpleRecord$str_value_indexed").setSubspaceKey("same");
    metaData.removeIndex("MySimpleRecord$str_value_indexed");
    metaData.getIndex("MySimpleRecord$num_value_3_indexed").setSubspaceKey("same");
    metaData.removeIndex("MySimpleRecord$num_value_3_indexed");
    assertInvalid("Same subspace key same used by two former indexes MySimpleRecord$num_value_3_indexed and MySimpleRecord$str_value_indexed", metaData);
    RecordMetaDataProto.MetaData.Builder protoBuilder = metaData.build(false).toProto().toBuilder();
    protoBuilder.getFormerIndexesBuilder(0).clearFormerName();
    protoBuilder.getFormerIndexesBuilder(1).clearFormerName();
    metaData = RecordMetaData.newBuilder().setRecords(protoBuilder.build());
    assertInvalid("Same subspace key same used by two former indexes <unknown> and <unknown>", metaData);
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder) RecordMetaData(com.apple.foundationdb.record.RecordMetaData) Test(org.junit.jupiter.api.Test)

Example 30 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class MetaDataValidatorTest method badIndexAddedVersion.

@Test
public void badIndexAddedVersion() {
    RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
    metaData.getIndex("MySimpleRecord$str_value_indexed").setAddedVersion(metaData.getVersion() + 1);
    metaData.getIndex("MySimpleRecord$str_value_indexed").setLastModifiedVersion(metaData.getVersion() + 1);
    assertInvalid("Index MySimpleRecord$str_value_indexed has added version " + (metaData.getVersion() + 1) + " which is greater than the meta-data version " + metaData.getVersion(), metaData);
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

RecordMetaDataBuilder (com.apple.foundationdb.record.RecordMetaDataBuilder)150 Test (org.junit.jupiter.api.Test)91 RecordMetaData (com.apple.foundationdb.record.RecordMetaData)69 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 Nonnull (javax.annotation.Nonnull)22 Index (com.apple.foundationdb.record.metadata.Index)21 Descriptors (com.google.protobuf.Descriptors)15 TestRecords1Proto (com.apple.foundationdb.record.TestRecords1Proto)14 KeyExpression (com.apple.foundationdb.record.metadata.expressions.KeyExpression)14 RecordMetaDataProto (com.apple.foundationdb.record.RecordMetaDataProto)13 ByteString (com.google.protobuf.ByteString)13 Tuple (com.apple.foundationdb.tuple.Tuple)12 Collections (java.util.Collections)12 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)11 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)11 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)11 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)11 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)11 RecordCoreException (com.apple.foundationdb.record.RecordCoreException)10 BooleanSource (com.apple.test.BooleanSource)10