<commit_before>package by.kraskovski.pms.repository;

import by.kraskovski.pms.Application;
import by.kraskovski.pms.model.Product;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import java.time.LocalDateTime;

import static org.junit.Assert.assertNotNull;

@RunWith(SpringRunner.class)
@ContextConfiguration(classes = Application.class)
@DataJpaTest
@TestPropertySource("classpath:/application-test.properties")
public class ProductRepositoryTest {

    @Autowired
    private TestEntityManager entityManager;

    @Test
    public void createProductTest() {
        final Product product = prepareProduct();
        entityManager.persist(product);
        assertNotNull(entityManager.find(Product.class, product.getId()));
    }

    private Product prepareProduct() {
        final Product product = new Product();
        product.setName("Product");
        product.setCost(420.5);
        product.setDetails("Description of product details");
        product.setHeight(391);
        product.setWidth(102);
        product.setWeight(10);
        product.setType("Product Type");
        product.setImage("--null--");
        product.setManufactureDate(LocalDateTime.now());
        return product;
    }
}<commit_msg>repository testing started<commit_after>package by.kraskovski.pms.repository;

import by.kraskovski.pms.Application;
import by.kraskovski.pms.model.Product;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import java.time.LocalDateTime;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;


@RunWith(SpringRunner.class)
@ContextConfiguration(classes = Application.class)
@DataJpaTest
@TestPropertySource("classpath:/application-test.properties")
public class ProductRepositoryTest {

    @Autowired
    private TestEntityManager entityManager;

    @Autowired
    private ProductRepository productRepository;

    @After
    public void after() {
        productRepository.deleteAll();
    }

    @Test
    public void findProductByNameTest() {
        entityManager.persist(prepareProduct());
        final Product foundProduct = productRepository.findByName("Sam").get(0);
        assertNotNull(foundProduct.getId());
        assertTrue(foundProduct.getName().contains("Sam"));
    }

    @Test
    public void findProductsByType() {
        entityManager.persist(prepareProduct());
        final List<Product> foundProducts = productRepository.findByType("Phone");
        assertEquals(foundProducts.size(), 1);
        assertEquals(foundProducts.get(0).getType(), "Phone");
    }

    private Product prepareProduct() {
        final Product product = new Product();
        product.setName("Samsung s8");
        product.setCost(599.99);
        product.setDetails("Components\n" +
                "Galaxy S8 phone\n" +
                "Earphones \n" +
                "USB Type-C Cable\n" +
                "Travel Adapter\n" +
                "USB Connector (C to A)\n" +
                "Micro USB Connector (C to B)\n" +
                "Ejection Pin\n" +
                "Ear Tips\n" +
                "Quick Start Guide ");
        product.setHeight(391);
        product.setWidth(102);
        product.setWeight(10);
        product.setType("Phone");
        product.setImage("--null--");
        product.setManufactureDate(LocalDateTime.now());
        return product;
    }
}
{'fraction_non_alphanumeric': 0.1107714016933208, 'fraction_numerical': 0.007525870178739417, 'mean_word_length': 3.529286474973376, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '3636078', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1156, 'n_words': 205}