Search in sources :

Example 71 with MutableMetaSnapshot

use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testFieldNameAndTypeConflict.

/**
   * Test that an exception is thrown on field name and type conflicts
   *
   * @throws Exception
   */
@Test
public void testFieldNameAndTypeConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaField("fieldName1", "fieldId1", FieldType.TIME);
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
    changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaField("fieldName2", "fieldId1", FieldType.INTEGER);
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 72 with MutableMetaSnapshot

use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testIdempotency.

/**
   * Fails if the checker do not allow idempotency
   *
   * @throws Exception
   */
@Test
public void testIdempotency() throws Exception {
    SnapshotMerger merger;
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    MutableMetaDocPart metaDocPart = changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1");
    metaDocPart.addMetaField("fieldName1", "fieldId1", FieldType.INTEGER);
    metaDocPart.addMetaScalar("scalarId1", FieldType.INTEGER);
    merger = new SnapshotMerger(currentSnapshot, changedSnapshot);
    merger.merge();
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) MutableMetaDocPart(com.torodb.core.transaction.metainf.MutableMetaDocPart) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 73 with MutableMetaSnapshot

use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testDatabaseNameConflict.

/**
   * Test that an exception is thrown on database name conflicts
   *
   * @throws Exception
   */
@Test
public void testDatabaseNameConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName2", "dbId1");
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 74 with MutableMetaSnapshot

use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testDocPartRefConflict.

/**
   * Test that an exception is thrown on doc part table ref conflicts
   *
   * @throws Exception
   */
@Test
public void testDocPartRefConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createChild(tableRefFactory.createRoot(), "anotherTRef"), "docPartId1");
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Aggregations

MutableMetaSnapshot (com.torodb.core.transaction.metainf.MutableMetaSnapshot)74 Test (org.junit.Test)70 WrapperMutableMetaSnapshot (com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot)69 ImmutableMetaSnapshot (com.torodb.core.transaction.metainf.ImmutableMetaSnapshot)56 UnmergeableException (com.torodb.core.transaction.metainf.UnmergeableException)34 MutableMetaDatabase (com.torodb.core.transaction.metainf.MutableMetaDatabase)3 MergerStage (com.torodb.core.transaction.metainf.MetainfoRepository.MergerStage)2 SnapshotStage (com.torodb.core.transaction.metainf.MetainfoRepository.SnapshotStage)2 Nonnull (javax.annotation.Nonnull)2 SnapshotUpdater (com.torodb.core.backend.SnapshotUpdater)1 DatabaseNotFoundException (com.torodb.core.exceptions.user.DatabaseNotFoundException)1 MutableMetaDocPart (com.torodb.core.transaction.metainf.MutableMetaDocPart)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 DSLContext (org.jooq.DSLContext)1