// Path: app/src/test/java/pl/pola_app/TestApplication.java
// public class TestApplication extends Application {
// }
// 
// Path: app/src/main/java/pl/pola_app/model/SearchResult.java
// @Parcel
// public class SearchResult {
//     public Integer product_id;
//     public String code;
//     public String name;
//     public String card_type;
//     public String altText;
//     public ArrayList<Company> companies;
// 
//     public ReportV4 report; 
// 
//     public String friend_text;
// 
//     public Donate donate;
// 
//     public boolean askForSupport() {
//         return donate != null;
//     }
// 
// 
// }
// 
// Path: app/src/test/java/pl/pola_app/testutil/SearchUtil.java
// public static SearchResult createSearchResult(int id) {
//     SearchResult searchResult = new SearchResult();
// 
//     searchResult.product_id = id;
//     searchResult.code = "code" + id;
//     searchResult.card_type = "card_type" + id;
//     searchResult.altText = "altText" + id;
// 
//     ReportV4 report = new ReportV4();
//     searchResult.report = report;
//     searchResult.report.text = "report_text" + id;
//     searchResult.report.button_text = "report_button_text" + id;
//     searchResult.report.button_type = "report_button_type" + id;
// 
//     ArrayList<Company> companies = new ArrayList<Company>();
//     Company company = new Company();
//     companies.add(company);
//     searchResult.companies = companies;
//     searchResult.companies.get(0).description = "description" + id;
//     searchResult.name = searchResult.name != null ? searchResult.name + id : searchResult.companies.get(0).name + id;
//     searchResult.companies.get(0).plScore = 1 + id;
//     searchResult.companies.get(0).plCapital = 2 + id;
//     searchResult.companies.get(0).plWorkers = 3 + id;
//     searchResult.companies.get(0).plRnD = 4 + id;
//     searchResult.companies.get(0).plRegistered = 5 + id;
//     searchResult.companies.get(0).plNotGlobEnt = 6 + id;
// 
//     return searchResult;
// }


import android.os.Bundle;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import pl.pola_app.TestApplication;
import pl.pola_app.model.SearchResult;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static pl.pola_app.testutil.SearchUtil.createSearchResult;

        assertEquals(searchResult, productList.get(0));
    }

    @Test
    public void testProductAddedToFrontOfList() throws Exception {
        final SearchResult searchResultA = createSearchResult(1);
        final SearchResult searchResultB = createSearchResult(2);

        productList.addProduct(searchResultA);
        productList.addProduct(searchResultB);

        assertEquals(2, productList.size());
        assertEquals(searchResultA, productList.get(1));
        assertEquals(searchResultB, productList.get(0));
        assertNotEquals(searchResultA, productList.get(0));
        assertNotEquals(searchResultB, productList.get(1));
    }

    @Test
    public void testNotifyChangedOnAdd() throws Exception {
        final OnProductListChanged onProductListChanged = mock(OnProductListChanged.class);
        productList.setOnProductListChanged(onProductListChanged);
        productList.addProduct(createSearchResult(1));

        verify(onProductListChanged).onChanged();
    }

    @Test
    public void testItemDoesNotExistForEmptyList() throws Exception {
// Path: app/src/test/java/pl/pola_app/TestApplication.java
// public class TestApplication extends Application {
// }
// 
// Path: app/src/main/java/pl/pola_app/model/SearchResult.java
// @Parcel
// public class SearchResult {
//     public Integer product_id;
//     public String code;
//     public String name;
//     public String card_type;
//     public String altText;
//     public ArrayList<Company> companies;
// 
//     public ReportV4 report; 
// 
//     public String friend_text;
// 
//     public Donate donate;
// 
//     public boolean askForSupport() {
//         return donate != null;
//     }
// 
// 
// }
// 
// Path: app/src/test/java/pl/pola_app/testutil/SearchUtil.java
// public static SearchResult createSearchResult(int id) {
//     SearchResult searchResult = new SearchResult();
// 
//     searchResult.product_id = id;
//     searchResult.code = "code" + id;
//     searchResult.card_type = "card_type" + id;
//     searchResult.altText = "altText" + id;
// 
//     ReportV4 report = new ReportV4();
//     searchResult.report = report;
//     searchResult.report.text = "report_text" + id;
//     searchResult.report.button_text = "report_button_text" + id;
//     searchResult.report.button_type = "report_button_type" + id;
// 
//     ArrayList<Company> companies = new ArrayList<Company>();
//     Company company = new Company();
//     companies.add(company);
//     searchResult.companies = companies;
//     searchResult.companies.get(0).description = "description" + id;
//     searchResult.name = searchResult.name != null ? searchResult.name + id : searchResult.companies.get(0).name + id;
//     searchResult.companies.get(0).plScore = 1 + id;
//     searchResult.companies.get(0).plCapital = 2 + id;
//     searchResult.companies.get(0).plWorkers = 3 + id;
//     searchResult.companies.get(0).plRnD = 4 + id;
//     searchResult.companies.get(0).plRegistered = 5 + id;
//     searchResult.companies.get(0).plNotGlobEnt = 6 + id;
// 
//     return searchResult;
// }


// Path: app/src/test/java/pl/pola_app/ui/adapter/ProductListTest.java
import android.os.Bundle;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import pl.pola_app.TestApplication;
import pl.pola_app.model.SearchResult;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static pl.pola_app.testutil.SearchUtil.createSearchResult;


        assertEquals(searchResult, productList.get(0));
    }

    @Test
    public void testProductAddedToFrontOfList() throws Exception {
        final SearchResult searchResultA = createSearchResult(1);
        final SearchResult searchResultB = createSearchResult(2);

        productList.addProduct(searchResultA);
        productList.addProduct(searchResultB);

        assertEquals(2, productList.size());
        assertEquals(searchResultA, productList.get(1));
        assertEquals(searchResultB, productList.get(0));
        assertNotEquals(searchResultA, productList.get(0));
        assertNotEquals(searchResultB, productList.get(1));
    }

    @Test
    public void testNotifyChangedOnAdd() throws Exception {
        final OnProductListChanged onProductListChanged = mock(OnProductListChanged.class);
        productList.setOnProductListChanged(onProductListChanged);
        productList.addProduct(createSearchResult(1));

        verify(onProductListChanged).onChanged();
    }

    @Test
    public void testItemDoesNotExistForEmptyList() throws Exception {
        assertFalse(productList.itemExists("code"));