<commit_before>package com.storage.mywarehouse.Dao;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertAll;

import com.storage.mywarehouse.Entity.Product;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;

public class ProductDaoTest {

    private static final int ZERO = 0;
    private static final int ONE = 1;
    private static final int TWO = 2;
    private static final String ANY = "ANY";
    private static final String ANY2 = "ANY2";
    private static final double DOUBLE_VAL = 1.1;
    private Product sut1;
    private Product sut2;
    private List<Product> rets;

    @AfterEach
    public void restore() {
        ProductDAO.deleteAll(ProductDAO.findAll());
    }

    @Test
    public void testSaveNFindAllNDeleteAll() {
        sut1 = new Product(ONE, ANY, ANY, DOUBLE_VAL);
        sut2 = new Product(TWO, ANY2, ANY2, DOUBLE_VAL);

        ProductDAO.save(sut1);
        ProductDAO.save(sut2);

        rets = ProductDAO.findAll();

        assertAll("test if products are saved",
                () -> assertEquals(TWO, rets.size()),
                () -> assertEquals(ANY, rets.get(0).getBrand()),
                () -> assertEquals(ANY2, rets.get(1).getBrand()));

        ProductDAO.delete(sut1);
        rets = ProductDAO.findAll();
        assertEquals(ONE, rets.size());

        ProductDAO.deleteAll(ProductDAO.findAll());
        rets = ProductDAO.findAll();
        assertEquals(ZERO, rets.size());
    }

    @Test
    public void testFindById() {

        sut1 = new Product(TWO, ANY2, ANY2, DOUBLE_VAL);
        ProductDAO.save(sut1);

        sut2 = ProductDAO.findById(TWO);
        assertEquals(ANY2, sut2.getBrand());
        
    }

}<commit_msg>reverting<commit_after>package com.storage.mywarehouse.Dao;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertAll;

import com.storage.mywarehouse.Entity.Product;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;

public class ProductDaoTest {

    private static final int ZERO = 0;
    private static final int ONE = 1;
    private static final int TWO = 2;
    private static final String ANY = "ANY";
    private static final String ANY2 = "ANY2";
    private static final double DOUBLE_VAL = 1.1;
    private Product sut1;
    private Product sut2;
    private List<Product> rets;

    @AfterEach
    public void restore() {
        ProductDAO.deleteAll(ProductDAO.findAll());
    }

    @Test
    public void testSaveNFindAllNDeleteAll() {
        sut1 = new Product(ONE, ANY, ANY, DOUBLE_VAL);
        sut2 = new Product(TWO, ANY2, ANY2, DOUBLE_VAL);

        ProductDAO.save(sut1);
        ProductDAO.save(sut2);

        rets = ProductDAO.findAll();

        assertAll("test if products are saved",
                () -> assertEquals(TWO, rets.size()),
                () -> assertEquals(ANY, rets.get(0).getBrand()),
                () -> assertEquals(ANY2, rets.get(1).getBrand()));

        ProductDAO.delete(sut1);
        rets = ProductDAO.findAll();
        assertEquals(ONE, rets.size());

        ProductDAO.deleteAll(ProductDAO.findAll());
        rets = ProductDAO.findAll();
        assertEquals(ZERO, rets.size());
    }
}
{'fraction_non_alphanumeric': 0.11800120409391933, 'fraction_numerical': 0.013546056592414209, 'mean_word_length': 2.759049773755656, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '3631822', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1025, 'n_words': 235}