package com.thebluealliance.androidclient.subscribers;

import com.thebluealliance.androidclient.datafeed.APICache;
import com.thebluealliance.androidclient.datafeed.framework.DatafeedTestDriver;
import com.thebluealliance.androidclient.datafeed.framework.ModelMaker;
import com.thebluealliance.androidclient.helpers.EventHelper;
import com.thebluealliance.androidclient.models.Event;
import com.thebluealliance.androidclient.renderers.EventRenderer;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import android.content.Context;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;

@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class EventListSubscriberTest {

    @Mock APICache mCache;

    private EventListSubscriber mSubscriber;
    private Context mContext;
    private EventRenderer mRenderer;
    private List<Event> mEvents;
    private List<Object> mExpected;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        mContext = mock(Context.class, RETURNS_DEEP_STUBS);

        mEvents = ModelMaker.getModelList(Event.class, "2015_events");
        mRenderer = new EventRenderer(mCache);
        mSubscriber = new EventListSubscriber(mContext);
        mExpected = new ArrayList<>();
    }

    @Test
    public void testParseNullData()  {
        DatafeedTestDriver.parseNullData(mSubscriber);
    }

    @Test
    public void testSimpleParsing()  {
        DatafeedTestDriver.testSimpleParsing(mSubscriber, mEvents);
    }

    @Test
    public void testParseWeek()  {
        mSubscriber.setRenderMode(EventListSubscriber.MODE_WEEK);
        List<Object> data = DatafeedTestDriver.getParsedData(mSubscriber, mEvents);
        EventHelper.renderEventListForWeek(mContext, mEvents, mExpected);

        assertListsEqual(data);
    }

    @Test
    public void testParseTeam()  {
        mSubscriber.setRenderMode(EventListSubscriber.MODE_TEAM);
        List<Object> data = DatafeedTestDriver.getParsedData(mSubscriber, mEvents);
        EventHelper.renderEventListForWeek(mContext, mEvents, mExpected);

        assertListsEqual(data);
    }

    @Test
    public void testParseDistrict()  {
        mSubscriber.setRenderMode(EventListSubscriber.MODE_DISTRICT);
        List<Object> data = DatafeedTestDriver.getParsedData(mSubscriber, mEvents);
        EventHelper.renderEventListForDistrict(mContext, mEvents, mExpected);

        assertListsEqual(data);
    }

    private void assertListsEqual(List<Object> actual) {
        assertEquals(actual.size(), mExpected.size());
        for (int i = 0; i < actual.size(); i++) {
            assertTrue(actual.get(i).equals(mExpected.get(i)));
        }
    }
}
@@ -49,16 +49,76 @@
 ibers;%0A%0A
+import com.thebluealliance.androidclient.DefaultTestRunner;%0A
 import c
@@ -441,74 +441,8 @@
 ent;
-%0Aimport com.thebluealliance.androidclient.renderers.EventRenderer;
 %0A%0Aim
@@ -608,36 +608,33 @@
 ectric.R
-obolectricTestRunner
+untimeEnvironment
 ;%0Aimport
@@ -846,102 +846,8 @@
 rue;
-%0Aimport static org.mockito.Mockito.RETURNS_DEEP_STUBS;%0Aimport static org.mockito.Mockito.mock;
 %0A%0A@C
@@ -889,19 +889,15 @@
 ith(
-Robolectric
+Default
 Test
@@ -1057,45 +1057,8 @@
 xt;%0A
-    private EventRenderer mRenderer;%0A
     
@@ -1228,47 +1228,38 @@
 t = 
-mock(Context.class, RETURNS_DEEP_STUBS)
+RuntimeEnvironment.application
 ;%0A%0A 
@@ -1332,55 +1332,8 @@
 %22);%0A
-        mRenderer = new EventRenderer(mCache);%0A
     

Fix tests