Search in sources :

Example 1 with TableRefFactoryImpl

use of com.torodb.core.impl.TableRefFactoryImpl 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);
}
Also used : DocPartRidGenerator(com.torodb.core.d2r.ReservedIdGenerator.DocPartRidGenerator) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) TableRefFactory(com.torodb.core.TableRefFactory) TableRefFactoryImpl(com.torodb.core.impl.TableRefFactoryImpl) Test(org.junit.Test)

Aggregations

ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 TableRefFactory (com.torodb.core.TableRefFactory)1 DocPartRidGenerator (com.torodb.core.d2r.ReservedIdGenerator.DocPartRidGenerator)1 TableRefFactoryImpl (com.torodb.core.impl.TableRefFactoryImpl)1 Test (org.junit.Test)1