Search in sources :

Example 16 with ImmutableMetaSnapshot

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

the class SnapshotMergerTest method testDatabaseIdConflict.

/**
   * Test that an exception is thrown on database id conflicts
   *
   * @throws Exception
   */
@Test
public void testDatabaseIdConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId2");
    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 17 with ImmutableMetaSnapshot

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

the class SnapshotMergerTest method testScalar_different.

/**
   * Test that no exception is thrown when creating a new scalar with different id and type
   *
   * @throws Exception
   */
@Test
public void testScalar_different() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaScalar("fieldId20", FieldType.LONG);
    new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 18 with ImmutableMetaSnapshot

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

the class SnapshotMergerTest method testCollectionNameConflict.

/**
   * Test that an exception is thrown on collection name conflicts
   *
   * @throws Exception
   */
@Test
public void testCollectionNameConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName2", "colId1");
    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 19 with ImmutableMetaSnapshot

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

the class SnapshotMergerTest method testDocPartIdConflict.

/**
   * Test that an exception is thrown on doc part id conflicts
   *
   * @throws Exception
   */
@Test
public void testDocPartIdConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId2");
    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 20 with ImmutableMetaSnapshot

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

the class SnapshotMergerTest method testField_differentName.

/**
   * Test that no exception is thrown when creating a new field that shares type but not name with a
   * previous one.
   *
   * @throws Exception
   */
@Test
public void testField_differentName() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaField("fieldName2", "fieldId4", FieldType.INTEGER);
    new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Aggregations

ImmutableMetaSnapshot (com.torodb.core.transaction.metainf.ImmutableMetaSnapshot)65 Test (org.junit.Test)62 MutableMetaSnapshot (com.torodb.core.transaction.metainf.MutableMetaSnapshot)56 WrapperMutableMetaSnapshot (com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot)55 UnmergeableException (com.torodb.core.transaction.metainf.UnmergeableException)22 SnapshotStage (com.torodb.core.transaction.metainf.MetainfoRepository.SnapshotStage)2 MergerStage (com.torodb.core.transaction.metainf.MetainfoRepository.MergerStage)1 MutableMetaDocPart (com.torodb.core.transaction.metainf.MutableMetaDocPart)1 Connection (java.sql.Connection)1 DSLContext (org.jooq.DSLContext)1