Search in sources :

Example 1 with TimedRepository

use of org.neo4j.kernel.impl.util.collection.TimedRepository in project neo4j by neo4j.

the class ConversationManagerTest method testConversationWorkflow.

@Test
public void testConversationWorkflow() throws Exception {
    JobScheduler.JobHandle reaperJobHandle = mock(JobScheduler.JobHandle.class);
    when(config.get(HaSettings.lock_read_timeout)).thenReturn(1L);
    when(conversationSPI.scheduleRecurringJob(any(JobScheduler.Group.class), any(Long.class), any(Runnable.class))).thenReturn(reaperJobHandle);
    RequestContext requestContext = getRequestContext();
    conversationManager = getConversationManager();
    TimedRepository conversationStorage = mock(TimedRepository.class);
    conversationManager.conversations = conversationStorage;
    conversationManager.begin(requestContext);
    conversationManager.acquire(requestContext);
    conversationManager.release(requestContext);
    conversationManager.end(requestContext);
    InOrder conversationOrder = inOrder(conversationStorage);
    conversationOrder.verify(conversationStorage).begin(requestContext);
    conversationOrder.verify(conversationStorage).acquire(requestContext);
    conversationOrder.verify(conversationStorage).release(requestContext);
    conversationOrder.verify(conversationStorage).end(requestContext);
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) InOrder(org.mockito.InOrder) TimedRepository(org.neo4j.kernel.impl.util.collection.TimedRepository) RequestContext(org.neo4j.com.RequestContext) Test(org.junit.Test)

Example 2 with TimedRepository

use of org.neo4j.kernel.impl.util.collection.TimedRepository in project neo4j by neo4j.

the class ConversationManagerTest method testConversationStop.

@Test
public void testConversationStop() {
    RequestContext requestContext = getRequestContext();
    conversationManager = getConversationManager();
    Conversation conversation = mock(Conversation.class);
    when(conversation.isActive()).thenReturn(true);
    TimedRepository conversationStorage = mock(TimedRepository.class);
    when(conversationStorage.end(requestContext)).thenReturn(conversation);
    conversationManager.conversations = conversationStorage;
    conversationManager.stop(requestContext);
    verify(conversationStorage).end(requestContext);
    verify(conversation).stop();
}
Also used : TimedRepository(org.neo4j.kernel.impl.util.collection.TimedRepository) RequestContext(org.neo4j.com.RequestContext) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RequestContext (org.neo4j.com.RequestContext)2 TimedRepository (org.neo4j.kernel.impl.util.collection.TimedRepository)2 InOrder (org.mockito.InOrder)1 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)1