<commit_before>package org.books.data.entity;

import org.books.data.PopulateDBJpaTest;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Test;

import javax.persistence.NoResultException;
import javax.persistence.EntityNotFoundException;
import javax.persistence.TypedQuery;
import org.books.data.dao.BookDAOBean;
import org.books.data.dto.BookInfo;

public class BookTest extends PopulateDBJpaTest {

    @Test
    public void BookFindByISBNTest() {
        TypedQuery<Book> query = em.createNamedQuery(Book.FINB_BY_ISBN, Book.class);
        final String isbn = "143024626X";
        query.setParameter("isbn", isbn);

        Book book = query.getSingleResult();
        Assert.assertEquals(isbn, book.getIsbn());
        Assert.assertEquals("Beginning Java EE 7 (Expert Voice in Java)", book.getTitle());

    }

    @Test(expectedExceptions = NoResultException.class)
    public void BookFindByISBNTestNullValue() {
        TypedQuery<Book> query = em.createNamedQuery("Book.findByISBN", Book.class);
        query.setParameter("isbn", "123");
        Book book = query.getSingleResult();
    }

    @Test
    public void BookFindByISBNDAOTest() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);
        Book book = bean.find("143024626X");
        Assert.assertEquals(isbn, book.getIsbn());
        Assert.assertEquals("Beginning Java EE 7 (Expert Voice in Java)", book.getTitle());
    }

    @Test(expectedExceptions = EntityNotFoundException.class)
    public void BookFindByISBNDAOTestNullValue() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);
        Book book = bean.find("123");
    }
    
    @Test
    public void searchByKeyWordsJava() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("java");
        Assert.assertEquals(searchList.size(), 11);
    }

    @Test
    public void searchByKeyWordsEEJava() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("ee java");
        Assert.assertEquals(searchList.size(), 6);
    }
    
    @Test
    public void searchByKeyWordsJavaEEQuoted() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("\"java ee\"");
        Assert.assertEquals(searchList.size(), 5);
    }

    @Test
    public void searchByKeyWordsApressBeginning() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("Apress beginning");
        Assert.assertEquals(searchList.size(), 2);
    }

    @Test
    public void searchByKeyWords2EJB() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("ejb java beginning ejb");
        Assert.assertEquals(searchList.size(), 1);
    }
    
    @Test
    public void searchByKeyWordsMicrosoft() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("Microsoft");
        Assert.assertEquals(searchList.size(), 0);
    }


    
}
<commit_msg>EntityNotFoundException wasn't thrown in BookDAO.find(isbn) Tests for BookDAO.find(isbn added)<commit_after>package org.books.data.entity;

import org.books.data.PopulateDBJpaTest;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Test;

import javax.persistence.NoResultException;
import javax.persistence.EntityNotFoundException;
import javax.persistence.TypedQuery;
import org.books.data.dao.BookDAOBean;
import org.books.data.dto.BookInfo;

public class BookTest extends PopulateDBJpaTest {

    @Test
    public void BookFindByISBNTest() {
        TypedQuery<Book> query = em.createNamedQuery(Book.FINB_BY_ISBN, Book.class);
        final String isbn = "143024626X";
        query.setParameter("isbn", isbn);

        Book book = query.getSingleResult();
        Assert.assertEquals(isbn, book.getIsbn());
        Assert.assertEquals("Beginning Java EE 7 (Expert Voice in Java)", book.getTitle());

    }

    @Test(expectedExceptions = NoResultException.class)
    public void BookFindByISBNTestNullValue() {
        TypedQuery<Book> query = em.createNamedQuery("Book.findByISBN", Book.class);
        query.setParameter("isbn", "123");
        Book book = query.getSingleResult();
    }

    @Test
    public void BookFindByISBNDAOTest() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);
        final String isbn = "143024626X";
        Book book = bean.find(isbn);
        Assert.assertEquals(isbn, book.getIsbn());
        Assert.assertEquals("Beginning Java EE 7 (Expert Voice in Java)", book.getTitle());
    }

    @Test(expectedExceptions = EntityNotFoundException.class)
    public void BookFindByISBNDAOTestNullValue() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);
        Book book = bean.find("123");
    }
    
    @Test
    public void searchByKeyWordsJava() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("java");
        Assert.assertEquals(searchList.size(), 11);
    }

    @Test
    public void searchByKeyWordsEEJava() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("ee java");
        Assert.assertEquals(searchList.size(), 6);
    }
    
    @Test
    public void searchByKeyWordsJavaEEQuoted() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("\"java ee\"");
        Assert.assertEquals(searchList.size(), 5);
    }

    @Test
    public void searchByKeyWordsApressBeginning() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("Apress beginning");
        Assert.assertEquals(searchList.size(), 2);
    }

    @Test
    public void searchByKeyWords2EJB() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("ejb java beginning ejb");
        Assert.assertEquals(searchList.size(), 1);
    }
    
    @Test
    public void searchByKeyWordsMicrosoft() {
        BookDAOBean bean = new BookDAOBean();
        bean.setEntityManager(em);

        List<BookInfo> searchList = bean.search("Microsoft");
        Assert.assertEquals(searchList.size(), 0);
    }


    
}

{'fraction_non_alphanumeric': 0.11366691560866318, 'fraction_numerical': 0.010156833457804331, 'mean_word_length': 3.107975460122699, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4440565', 'n_tokens_mistral': 2072, 'n_tokens_neox': 1969, 'n_words': 398}