use of com.torodb.core.transaction.metainf.ImmutableMetaDocPart in project torodb by torodb.
the class IdentifierFactoryImplTest method longForCounterFieldToIdentifierTest.
@Test
public void longForCounterFieldToIdentifierTest() {
ImmutableMetaDocPart metaDocPart = new ImmutableMetaDocPart.Builder(createTableRef(), "docpart").build();
String identifier = identifierFactory.toFieldIdentifier(metaDocPart, "field____long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long", FieldType.STRING);
Assert.assertEquals("field____long_long_long_long_long_long_long_long_long_long_lonng_long_long_long_long_long_long_long_long_long_long_long_long_1_s", identifier);
}
use of com.torodb.core.transaction.metainf.ImmutableMetaDocPart in project torodb by torodb.
the class IdentifierFactoryImplTest method longForCounterWithCollisionCharacterFieldToIdentifierTest.
@Test
public void longForCounterWithCollisionCharacterFieldToIdentifierTest() {
ImmutableMetaDocPart metaDocPart = new ImmutableMetaDocPart.Builder(createTableRef(), "docpart").put(new ImmutableMetaField("field_collider", "field____long_long_long_long_long_long_long_long_long_long_lonng_long_long_long_long_long_long_long_long_long_long_long_long_1_s", FieldType.STRING)).build();
String identifier = identifierFactory.toFieldIdentifier(metaDocPart, "field____long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long", FieldType.STRING);
Assert.assertEquals("field____long_long_long_long_long_long_long_long_long_long_lonng_long_long_long_long_long_long_long_long_long_long_long_long_2_s", identifier);
}
use of com.torodb.core.transaction.metainf.ImmutableMetaDocPart in project torodb by torodb.
the class IdentifierFactoryImplTest method unallowedFieldToIdentifierTest.
@Test
public void unallowedFieldToIdentifierTest() {
ImmutableMetaDocPart metaDocPart = new ImmutableMetaDocPart.Builder(createTableRef(), "docpart").build();
String identifier = identifierFactory.toFieldIdentifier(metaDocPart, "unallowed_column", FieldType.STRING);
Assert.assertEquals("_unallowed_column_s", identifier);
}
use of com.torodb.core.transaction.metainf.ImmutableMetaDocPart in project torodb by torodb.
the class DefaultToBackendFunctionTest method testNoBatchMetaDocPart.
@Test
public void testNoBatchMetaDocPart() {
CollectionData collectionData = mock(CollectionData.class);
DocPartData data1 = mock(DocPartData.class);
given(data1.getMetaDocPart()).willReturn(new WrapperMutableMetaDocPart(new ImmutableMetaDocPart(tableRefFactory.createRoot(), "aDocPartName"), (o) -> {
}));
given(collectionData.orderedDocPartData()).willReturn(Collections.singleton(data1));
//when
try {
fun.apply(collectionData);
//then
fail("An exception was expected when a metadoc part which is not a " + BatchMetaDocPart.class + " is used");
} catch (AssertionError | ClassCastException ex) {
}
}
use of com.torodb.core.transaction.metainf.ImmutableMetaDocPart in project torodb by torodb.
the class SnapshotMerger method merge.
@SuppressWarnings("checkstyle:LineLength")
private void merge(MetaDatabase newDb, MetaDatabase oldDb, MutableMetaCollection newStructure, ImmutableMetaCollection oldStructure, ImmutableMetaCollection.Builder parentBuilder, MutableMetaDocPart changed) throws UnmergeableException {
ImmutableMetaDocPart byRef = oldStructure.getMetaDocPartByTableRef(changed.getTableRef());
ImmutableMetaDocPart byId = oldStructure.getMetaDocPartByIdentifier(changed.getIdentifier());
if (byRef != byId) {
throw createUnmergeableException(oldDb, oldStructure, changed, byRef, byId);
}
if (byRef == null && byId == null) {
parentBuilder.put(changed.immutableCopy());
return;
}
assert byRef != null;
assert byId != null;
ImmutableMetaDocPart.Builder childBuilder = new ImmutableMetaDocPart.Builder(byId);
for (ImmutableMetaField addedMetaField : changed.getAddedMetaFields()) {
merge(oldDb, newStructure, oldStructure, changed, byId, childBuilder, addedMetaField);
}
for (ImmutableMetaScalar addedMetaScalar : changed.getAddedMetaScalars()) {
merge(oldDb, oldStructure, byId, childBuilder, addedMetaScalar);
}
for (Tuple2<ImmutableMetaIdentifiedDocPartIndex, MetaElementState> addedMetaDocPartIndex : changed.getModifiedMetaDocPartIndexes()) {
merge(oldDb, newStructure, oldStructure, changed, byId, childBuilder, addedMetaDocPartIndex.v1(), addedMetaDocPartIndex.v2());
}
parentBuilder.put(childBuilder);
}
Aggregations