<commit_before>package io.github.zwieback.relef.parsers;

import io.github.zwieback.relef.entities.Manufacturer;
import io.github.zwieback.relef.entities.Product;
import io.github.zwieback.relef.entities.ProductProperty;
import io.github.zwieback.relef.entities.TradeMark;
import org.jetbrains.annotations.NotNull;
import org.jsoup.nodes.Document;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static org.junit.Assert.assertEquals;

abstract class AbstractProductParserTest extends AbstractParserTest {

    @SuppressWarnings("unused")
    @Autowired
    private ProductParser productParser;

    abstract Long getProductId();

    abstract Long getCatalogId();

    String getResourcePage() {
        return String.format("classpath:pages/catalog_%d_product_%d.html", getCatalogId(), getProductId());
    }

    abstract Product getExpectedProduct();

    @Test
    public void test_parseProduct_should_returns_parsed_product() {
        Document productDocument = productParser.parseUrl("");
        Product product = productParser.parseProduct(productDocument, getCatalogId(), getProductId());

        compareProducts(getExpectedProduct(), product);
    }

    private static void compareProducts(Product expectedProduct, Product actualProduct) {
        assertEquals(expectedProduct.getId(), actualProduct.getId());
        assertEquals(expectedProduct.getCatalogId(), actualProduct.getCatalogId());
        assertEquals(expectedProduct.getPhotoUrl(), actualProduct.getPhotoUrl());
        assertEquals(expectedProduct.getPhotoCachedUrl(), actualProduct.getPhotoCachedUrl());
        assertEquals(expectedProduct.getName(), actualProduct.getName());
        assertEquals(expectedProduct.getDescription(), actualProduct.getDescription());
        assertEquals(expectedProduct.getCode(), actualProduct.getCode());
        assertEquals(expectedProduct.getArticle(), actualProduct.getArticle());
        assertEquals(expectedProduct.getBarcode(), actualProduct.getBarcode());
        assertEquals(expectedProduct.getManufacturerCountry(), actualProduct.getManufacturerCountry());
        assertEquals(expectedProduct.getParty(), actualProduct.getParty());
        assertEquals(expectedProduct.getWeight(), actualProduct.getWeight());
        assertEquals(expectedProduct.getVolume(), actualProduct.getVolume());
        assertEquals(expectedProduct.getProperties().size(), actualProduct.getProperties().size());
        assertEquals(expectedProduct.getManufacturer().getName(), actualProduct.getManufacturer().getName());
        assertEquals(expectedProduct.getManufacturer().getUrl(), actualProduct.getManufacturer().getUrl());
        assertEquals(expectedProduct.getTradeMark().getName(), actualProduct.getTradeMark().getName());
        assertEquals(expectedProduct.getTradeMark().getUrl(), actualProduct.getTradeMark().getUrl());
    }

    static List<ProductProperty> generatePropertiesStub(int size) {
        return IntStream.range(0, size).mapToObj(i -> (ProductProperty) null).collect(Collectors.toList());
    }

    @NotNull
    static Manufacturer generateManufacturer(@NotNull String name, @NotNull String url) {
        return new Manufacturer(name, url);
    }

    @NotNull
    static TradeMark generateTradeMark(@NotNull String name, @NotNull String url) {
        return new TradeMark(name, url);
    }
}
<commit_msg>RP-3: changed equality of manufacturer and tradeMark in ProductParser tests<commit_after>package io.github.zwieback.relef.parsers;

import io.github.zwieback.relef.entities.Manufacturer;
import io.github.zwieback.relef.entities.Product;
import io.github.zwieback.relef.entities.ProductProperty;
import io.github.zwieback.relef.entities.TradeMark;
import org.jetbrains.annotations.NotNull;
import org.jsoup.nodes.Document;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static org.junit.Assert.assertEquals;

abstract class AbstractProductParserTest extends AbstractParserTest {

    @SuppressWarnings("unused")
    @Autowired
    private ProductParser productParser;

    abstract Long getProductId();

    abstract Long getCatalogId();

    String getResourcePage() {
        return String.format("classpath:pages/catalog_%d_product_%d.html", getCatalogId(), getProductId());
    }

    abstract Product getExpectedProduct();

    @Test
    public void test_parseProduct_should_returns_parsed_product() {
        Document productDocument = productParser.parseUrl("");
        Product product = productParser.parseProduct(productDocument, getCatalogId(), getProductId());

        compareProducts(getExpectedProduct(), product);
    }

    private static void compareProducts(Product expectedProduct, Product actualProduct) {
        assertEquals(expectedProduct.getId(), actualProduct.getId());
        assertEquals(expectedProduct.getCatalogId(), actualProduct.getCatalogId());
        assertEquals(expectedProduct.getPhotoUrl(), actualProduct.getPhotoUrl());
        assertEquals(expectedProduct.getPhotoCachedUrl(), actualProduct.getPhotoCachedUrl());
        assertEquals(expectedProduct.getName(), actualProduct.getName());
        assertEquals(expectedProduct.getDescription(), actualProduct.getDescription());
        assertEquals(expectedProduct.getCode(), actualProduct.getCode());
        assertEquals(expectedProduct.getArticle(), actualProduct.getArticle());
        assertEquals(expectedProduct.getBarcode(), actualProduct.getBarcode());
        assertEquals(expectedProduct.getManufacturerCountry(), actualProduct.getManufacturerCountry());
        assertEquals(expectedProduct.getParty(), actualProduct.getParty());
        assertEquals(expectedProduct.getWeight(), actualProduct.getWeight());
        assertEquals(expectedProduct.getVolume(), actualProduct.getVolume());
        assertEquals(expectedProduct.getProperties().size(), actualProduct.getProperties().size());
        assertEquals(expectedProduct.getManufacturer(), actualProduct.getManufacturer());
        assertEquals(expectedProduct.getTradeMark(), actualProduct.getTradeMark());
    }

    static List<ProductProperty> generatePropertiesStub(int size) {
        return IntStream.range(0, size).mapToObj(i -> (ProductProperty) null).collect(Collectors.toList());
    }

    @NotNull
    static Manufacturer generateManufacturer(@NotNull String name, @NotNull String url) {
        return new Manufacturer(name, url);
    }

    @NotNull
    static TradeMark generateTradeMark(@NotNull String name, @NotNull String url) {
        return new TradeMark(name, url);
    }
}

{'fraction_non_alphanumeric': 0.11038961038961038, 'fraction_numerical': 0.00044273907910271547, 'mean_word_length': 5.121951219512195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2373367', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1692, 'n_words': 293}