package org.atlasapi.system.bootstrap.workers;

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

import org.atlasapi.entity.Id;
import org.atlasapi.entity.ResourceRef;
import org.atlasapi.entity.util.Resolved;
import org.atlasapi.event.Event;
import org.atlasapi.event.EventResolver;
import org.atlasapi.event.EventWriter;
import org.atlasapi.messaging.ResourceUpdatedMessage;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.Futures;

@RunWith(MockitoJUnitRunner.class)
public class EventReadWriteWorkerTest {

    private @Mock EventResolver resolver;
    private @Mock EventWriter writer;
    private @Mock ResourceUpdatedMessage message;
    private @Mock ResourceRef updatedResource;
    private @Mock Event event;

    private EventReadWriteWorker worker;

    @Before
    public void setUp() throws Exception {
        worker = new EventReadWriteWorker(resolver, writer);

        Id id = Id.valueOf(0L);
        when(message.getUpdatedResource()).thenReturn(updatedResource);
        when(updatedResource.getId()).thenReturn(id);
        when(resolver.resolveIds(ImmutableList.of(id)))
                .thenReturn(Futures.immediateFuture(Resolved.valueOf(ImmutableList.of(event))));
    }

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

        verify(writer).write(event);
    }
}
@@ -558,16 +558,51 @@
 unner;%0A%0A
+import com.codahale.metrics.Timer;%0A
 import c
@@ -637,24 +637,24 @@
 utableList;%0A
-
 import com.g
@@ -844,24 +844,101 @@
 ter writer;%0A
+    private @Mock Timer timer;%0A    private @Mock Timer.Context timerContext;%0A
     private 
@@ -1209,16 +1209,23 @@
 , writer
+, timer
 );%0A%0A    
@@ -1434,16 +1434,16 @@
 f(id)))%0A
-
         
@@ -1531,16 +1531,69 @@
 nt))));%0A
+        when(timer.time()).thenReturn(timerContext);%0A
     %7D%0A%0A 

Fix broken test