use of com.torodb.core.TableRefFactory in project torodb by torodb.
the class ReservedIdGeneratorImplTest method whenTableRefDoesntExistsCallsToFactory.
@Test
public void whenTableRefDoesntExistsCallsToFactory() {
ReservedIdInfoFactory factory = new MockedReservedIdInfoFactory();
factory.startAsync();
factory.awaitRunning();
TableRefFactory tableRefFactory = new TableRefFactoryImpl();
ReservedIdInfoFactory reservedIdInfoFactory = Mockito.spy(factory);
ReservedIdGeneratorImpl container = new ReservedIdGeneratorImpl(reservedIdInfoFactory, new ThreadFactoryBuilder().build());
DocPartRidGenerator docPartRidGenerator = container.getDocPartRidGenerator("myDB", "myCollection");
int nextRid = docPartRidGenerator.nextRid(tableRefFactory.createRoot());
Mockito.verify(reservedIdInfoFactory).create("myDB", "myCollection", tableRefFactory.createRoot());
assertEquals(1, nextRid);
}
use of com.torodb.core.TableRefFactory in project torodb by torodb.
the class SqlTorodTransaction method extractTableRef.
protected TableRef extractTableRef(AttributeReference attRef) {
TableRefFactory tableRefFactory = getConnection().getServer().getTableRefFactory();
TableRef ref = tableRefFactory.createRoot();
if (attRef.getKeys().isEmpty()) {
throw new IllegalArgumentException("The empty attribute reference is not valid");
}
if (attRef.getKeys().size() > 1) {
List<Key<?>> keys = attRef.getKeys();
List<Key<?>> tableKeys = keys.subList(0, keys.size() - 1);
for (Key<?> key : tableKeys) {
ref = tableRefFactory.createChild(ref, extractKeyName(key));
}
}
return ref;
}
Aggregations