@@ -0,0 +1,2544 @@
+// Copyright 2019 Google LLC%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     https://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.sps;%0A%0Aimport com.google.sps.data.Product;%0A%0Aimport java.io.File;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.jsoup.Jsoup;%0Aimport org.jsoup.nodes.Document;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0A%0A/** */%0A@RunWith(JUnit4.class)%0Apublic final class ProductListExtractorTest %7B%0A  private ProductListExtractor productListExtractor;%0A%0A  @Before%0A  public void setUp() %7B%0A    productListExtractor = new ProductListExtractor();%0A  %7D%0A%0A  @Test%0A  public void CompleteDoc() throws Exception %7B%0A    List%3CProduct%3E expectedProducts = new ArrayList%3C%3E();%0A    expectedProducts.add(Product.create(%22TWSBI Eco %3Cb%3EFountain Pen%3C/b%3E - Clear - Extra-Fine%22, %0A        %22https://image-link-1.com%22, %0A        %22%3Cspan class=%5C%22HRLxBb%5C%22%3E$30.99%3C/span%3E from Goldspot%22, %0A        %22https://product-link-1.com%22, %0A        %22+$4.95 shipping%22));%0A    %0A    File completeDocFile = new File(%22./src/main/webapp/fake-shopping-results/complete-doc.html%22);%0A    Document completeDoc = Jsoup.parse(completeDocFile, %22UTF-8%22);%0A%0A    List%3CProduct%3E actualProducts = productListExtractor.extract(completeDoc);%0A%0A    Assert.assertEquals(expectedProducts, actualProducts);%0A  %7D%0A%0A  @Test%0A  public void noProductRatingProvided() throws Exception  %7B%0A    List%3CProduct%3E expectedProducts = new ArrayList%3C%3E();%0A    expectedProducts.add(Product.create(%22TWSBI Eco %3Cb%3EFountain Pen%3C/b%3E - Clear - Extra-Fine%22, %0A        %22https://image-link-1.com%22, %0A        %22%3Cspan class=%5C%22HRLxBb%5C%22%3E$30.99%3C/span%3E from Goldspot%22, %0A        %22https://product-link-1.com%22, %0A        %22+$4.95 shipping%22));%0A    %0A    File completeDocFile = new File(%22./src/main/webapp/fake-shopping-results/product-rating-missing.html%22);%0A    Document completeDoc = Jsoup.parse(completeDocFile, %22UTF-8%22);%0A%0A    List%3CProduct%3E actualProducts = productListExtractor.extract(completeDoc);%0A%0A    Assert.assertEquals(expectedProducts, actualProducts);%0A  %7D%0A%7D

Create ProductListExtractorTest