// Path: app/src/mock/java/com/michaelvescovo/android/itemreaper/data/FakeDataSource.java
// final static List<Item> ITEMS = Lists.newArrayList();
// 
// Path: app/src/mock/java/com/michaelvescovo/android/itemreaper/data/FakeDataSource.java
// public final static Item ITEM_1 = new Item("1",
//         1453554000000L, // purchase: 24/01/2016
//         2000,
//         0,
//         1485176400000L, // expiry: 24/01/2017
//         "Clothing", "Casual", "T-shirt",
//         "Short sleeve", "V-neck", "Plain", "Black", "Dark", "Some secondary colour",
//         "Some Size", "Some Brand", "Some Shop", "Standard plain T-shirt", "Some note",
//         "file:///android_asset/black-t-shirt.jpg", false);
// 
// Path: app/src/mock/java/com/michaelvescovo/android/itemreaper/data/FakeDataSource.java
// public final static Item ITEM_2 = new Item("2",
//         -1, // purchase: unknown
//         3000,
//         -1,
//         1514206800000L, // expiry: 26/12/2017
//         "Bathroom", null,
//         "Towel", null, null, null, "White", null, null, null, null, null, null, null, null,
//         false);
// 
// Path: app/src/mock/java/com/michaelvescovo/android/itemreaper/data/FakeDataSource.java
// public final static String USER_ID = "testUID";
// 
// Path: app/src/main/java/com/michaelvescovo/android/itemreaper/item_details/ItemDetailsPresenter.java
// public final static String ITEM_DETAILS_CALLER = "item_details";
// 
// Path: app/src/main/java/com/michaelvescovo/android/itemreaper/items/ItemsPresenter.java
// @SuppressWarnings("WeakerAccess")
// @VisibleForTesting
// public final static String ITEMS_CALLER = "items";
// 
// Path: app/src/main/java/com/michaelvescovo/android/itemreaper/util/Constants.java
// public static final String SORT_BY_EXPIRY_STRING = "expiry";


import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.List;
import static com.michaelvescovo.android.itemreaper.data.FakeDataSource.ITEMS;
import static com.michaelvescovo.android.itemreaper.data.FakeDataSource.ITEM_1;
import static com.michaelvescovo.android.itemreaper.data.FakeDataSource.ITEM_2;
import static com.michaelvescovo.android.itemreaper.data.FakeDataSource.USER_ID;
import static com.michaelvescovo.android.itemreaper.item_details.ItemDetailsPresenter.ITEM_DETAILS_CALLER;
import static com.michaelvescovo.android.itemreaper.items.ItemsPresenter.ITEMS_CALLER;
import static com.michaelvescovo.android.itemreaper.util.Constants.SORT_BY_EXPIRY_STRING;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
        List<Item> emptyList = new ArrayList<>();
        mRepository.getItems(USER_ID, SORT_BY_EXPIRY_STRING, ITEMS_CALLER, mGetItemsCallback);
        // Trigger callback.
        verify(mRemoteDataSource).getItems(anyString(), anyString(), anyString(),
                mItemsCallbackCaptor.capture());
        // Set the callback data.
        mItemsCallbackCaptor.getValue().onItemsLoaded(emptyList);
        // Returns null
        verify(mGetItemsCallback).onItemsLoaded(emptyList);
    }

    @Test
    public void getItem_CacheAfterFirstCall() {
        // First call.
        mRepository.getItem(ITEM_1.getId(), USER_ID, ITEM_DETAILS_CALLER, mGetItemCallback);
        // Trigger callback.
        verify(mRemoteDataSource).getItem(anyString(), anyString(), anyString(),
                mItemCallbackCaptor.capture());
        // Set the callback data.
        mItemCallbackCaptor.getValue().onItemLoaded(ITEM_1);
        // Second call.
        mRepository.getItem(ITEM_1.getId(), USER_ID, ITEM_DETAILS_CALLER, mGetItemCallback);
        // Confirm the total calls to the remote data source is only 1; the cache was used.
        verify(mRemoteDataSource, times(1)).getItem(anyString(), anyString(), anyString(),
                any(DataSource.GetItemCallback.class));
    }

    @Test
    public void getItemNotInCache_queriesRemoteDataSource() {
        // Call to get item not in cache.
// Path: app/src/mock/java/com/michaelvescovo/android/itemreaper/data/FakeDataSource.java
// final static List<Item> ITEMS = Lists.newArrayList();
// 
// Path: app/src/mock/java/com/michaelvescovo/android/itemreaper/data/FakeDataSource.java
// public final static Item ITEM_1 = new Item("1",
//         1453554000000L, // purchase: 24/01/2016
//         2000,
//         0,
//         1485176400000L, // expiry: 24/01/2017
//         "Clothing", "Casual", "T-shirt",
//         "Short sleeve", "V-neck", "Plain", "Black", "Dark", "Some secondary colour",
//         "Some Size", "Some Brand", "Some Shop", "Standard plain T-shirt", "Some note",
//         "file:///android_asset/black-t-shirt.jpg", false);
// 
// Path: app/src/mock/java/com/michaelvescovo/android/itemreaper/data/FakeDataSource.java
// public final static Item ITEM_2 = new Item("2",
//         -1, // purchase: unknown
//         3000,
//         -1,
//         1514206800000L, // expiry: 26/12/2017
//         "Bathroom", null,
//         "Towel", null, null, null, "White", null, null, null, null, null, null, null, null,
//         false);
// 
// Path: app/src/mock/java/com/michaelvescovo/android/itemreaper/data/FakeDataSource.java
// public final static String USER_ID = "testUID";
// 
// Path: app/src/main/java/com/michaelvescovo/android/itemreaper/item_details/ItemDetailsPresenter.java
// public final static String ITEM_DETAILS_CALLER = "item_details";
// 
// Path: app/src/main/java/com/michaelvescovo/android/itemreaper/items/ItemsPresenter.java
// @SuppressWarnings("WeakerAccess")
// @VisibleForTesting
// public final static String ITEMS_CALLER = "items";
// 
// Path: app/src/main/java/com/michaelvescovo/android/itemreaper/util/Constants.java
// public static final String SORT_BY_EXPIRY_STRING = "expiry";


// Path: app/src/testMock/java/com/michaelvescovo/android/itemreaper/data/RepositoryTest.java
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.List;
import static com.michaelvescovo.android.itemreaper.data.FakeDataSource.ITEMS;
import static com.michaelvescovo.android.itemreaper.data.FakeDataSource.ITEM_1;
import static com.michaelvescovo.android.itemreaper.data.FakeDataSource.ITEM_2;
import static com.michaelvescovo.android.itemreaper.data.FakeDataSource.USER_ID;
import static com.michaelvescovo.android.itemreaper.item_details.ItemDetailsPresenter.ITEM_DETAILS_CALLER;
import static com.michaelvescovo.android.itemreaper.items.ItemsPresenter.ITEMS_CALLER;
import static com.michaelvescovo.android.itemreaper.util.Constants.SORT_BY_EXPIRY_STRING;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

        List<Item> emptyList = new ArrayList<>();
        mRepository.getItems(USER_ID, SORT_BY_EXPIRY_STRING, ITEMS_CALLER, mGetItemsCallback);
        // Trigger callback.
        verify(mRemoteDataSource).getItems(anyString(), anyString(), anyString(),
                mItemsCallbackCaptor.capture());
        // Set the callback data.
        mItemsCallbackCaptor.getValue().onItemsLoaded(emptyList);
        // Returns null
        verify(mGetItemsCallback).onItemsLoaded(emptyList);
    }

    @Test
    public void getItem_CacheAfterFirstCall() {
        // First call.
        mRepository.getItem(ITEM_1.getId(), USER_ID, ITEM_DETAILS_CALLER, mGetItemCallback);
        // Trigger callback.
        verify(mRemoteDataSource).getItem(anyString(), anyString(), anyString(),
                mItemCallbackCaptor.capture());
        // Set the callback data.
        mItemCallbackCaptor.getValue().onItemLoaded(ITEM_1);
        // Second call.
        mRepository.getItem(ITEM_1.getId(), USER_ID, ITEM_DETAILS_CALLER, mGetItemCallback);
        // Confirm the total calls to the remote data source is only 1; the cache was used.
        verify(mRemoteDataSource, times(1)).getItem(anyString(), anyString(), anyString(),
                any(DataSource.GetItemCallback.class));
    }

    @Test
    public void getItemNotInCache_queriesRemoteDataSource() {
        // Call to get item not in cache.
        mRepository.getItem(ITEM_2.getId(), USER_ID, ITEM_DETAILS_CALLER, mGetItemCallback);