use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerTest method testField_different.
/**
* Test that no exception is thrown when creating a new field with different id, name and type
*
* @throws Exception
*/
@Test
public void testField_different() throws Exception {
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaField("fieldName10", "fieldId20", FieldType.CHILD);
new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
}
use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerTest method testScalarIdConflict.
/**
* Test that an exception is thrown on scalar id conflicts
*
* @throws Exception
*/
@Test
public void testScalarIdConflict() throws Exception {
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaScalar("scalarId1", FieldType.LONG);
try {
new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
} catch (UnmergeableException ex) {
}
}
use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerTest method testField_differentType.
/**
* Test that no exception is thrown when creating a new field that shares name but not type with a
* previous one.
*
* @throws Exception
*/
@Test
public void testField_differentType() throws Exception {
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaField("fieldName1", "fieldId4", FieldType.TIME);
new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
}
use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testIndexWithMultiFieldsInMultiDocPartsWithNewFieldAndNewDocPartIndex.
/**
* Test new field with new doc part index for existing index with multiple fields in multiple doc
* parts Case 3&3.OK1.3
*
* @throws Exception
*/
@Test
public void testIndexWithMultiFieldsInMultiDocPartsWithNewFieldAndNewDocPartIndex() throws Exception {
MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaDocPart(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "docPartId2");
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName4", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName5", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName2", "fieldId2", FieldType.STRING);
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentModifiedSnapshot.immutableCopy());
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName3", "fieldId3", FieldType.STRING);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaDocPartIndex(false).addMetaDocPartIndexColumn("fieldId2", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).getAddedMutableMetaDocPartIndexes().iterator().next().addMetaDocPartIndexColumn("fieldId3", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).getAddedMutableMetaDocPartIndexes().iterator().next().immutableCopy("idxId2");
new SnapshotMerger(currentModifiedSnapshot.immutableCopy(), changedSnapshot).merge();
}
use of com.torodb.core.transaction.metainf.MutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testNewIndexWhichMatchOldIndexConflict.
/**
* Test an exception is thrown when a new index match an old index Case 1&1.KO1.1a
*
* @throws Exception
*/
@Test
public void testNewIndexWhichMatchOldIndexConflict() throws Exception {
MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName3", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
try {
new SnapshotMerger(currentModifiedSnapshot.immutableCopy(), changedSnapshot).merge();
Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
} catch (UnmergeableException ex) {
}
}
Aggregations