package org.atlasapi.messaging;

import org.atlasapi.content.Content;
import org.atlasapi.content.ContentRef;
import org.atlasapi.content.ContentResolver;
import org.atlasapi.entity.Id;
import org.atlasapi.entity.util.Resolved;
import org.atlasapi.neo4j.service.Neo4jContentStore;

import com.metabroadcast.common.time.Timestamp;

import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.Futures;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class Neo4jContentStoreContentUpdateWorkerTest {

    @Mock private ContentResolver contentResolver;
    @Mock private Neo4jContentStore neo4JContentStore;
    @Mock private Timer timer;
    @Mock private Meter failureMeter;
    @Mock private Timer.Context timerContext;

    @Mock private ContentRef contentRef;
    @Mock private Content content;

    private EquivalentContentUpdatedMessage message;
    private Id id;

    private Neo4jContentStoreContentUpdateWorker worker;

    @Before
    public void setUp() throws Exception {
        id = Id.valueOf(0L);

        message = new EquivalentContentUpdatedMessage(
                "messageId", Timestamp.of(DateTime.now()), 10L, contentRef
        );

        when(contentRef.getId()).thenReturn(id);
        when(contentResolver.resolveIds(ImmutableList.of(id)))
                .thenReturn(Futures.immediateFuture(Resolved.valueOf(
                        ImmutableList.of(content)
                )));
        when(timer.time()).thenReturn(timerContext);

        worker = Neo4jContentStoreContentUpdateWorker.create(
                contentResolver, neo4JContentStore, timer, failureMeter
        );
    }

    @Test
    public void processMessageCallsDependenciesInOrder() throws Exception {
        worker.process(message);

        InOrder order = inOrder(contentResolver, timer, timerContext, neo4JContentStore);
        order.verify(timer).time();
        order.verify(contentResolver).resolveIds(ImmutableList.of(id));
        order.verify(neo4JContentStore).writeContent(content);
        order.verify(timerContext).stop();
    }
}

@@ -359,45 +359,19 @@
 .Met
-er;%0Aimport com.codahale.metrics.Timer
+ricRegistry
 ;%0Aim
@@ -964,123 +964,8 @@
 ore;
-%0A    @Mock private Timer timer;%0A    @Mock private Meter failureMeter;%0A    @Mock private Timer.Context timerContext;
 %0A%0A  
@@ -1653,61 +1653,8 @@
 )));
-%0A        when(timer.time()).thenReturn(timerContext);
 %0A%0A  
@@ -1769,27 +1769,32 @@
 re, 
-timer, failureMeter
+%22%22, new MetricRegistry()
 %0A   
@@ -1981,82 +1981,25 @@
 er, 
-timer, timerContext, neo4JContentStore);%0A        order.verify(timer).time(
+neo4JContentStore
 );%0A 
@@ -2136,51 +2136,8 @@
 t);%0A
-        order.verify(timerContext).stop();%0A
     

Fix compilation failures due to interface change