<commit_before>package info.cukes;

import cucumber.api.java.After;
import cucumber.api.java.Before;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.List;

/**
 * @author glick
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:cucumber.xml"})
public class CreateAuthorsWithBookTest
{
  Book authoredBook;

  List<Author> expectedAuthorList = new ArrayList<>();

  @Autowired
  BookRepository bookRepository;

  @Autowired
  AuthorRepository authorRepository;

  @Before
  public void setUp()
  {
    bookRepository.deleteAll();
    authorRepository.deleteAll();
  }

  @After
  public void tearDown()
  {
    bookRepository.deleteAll();
    authorRepository.deleteAll();
  }

  @Test
  public void testCreateAuthorsEachWithOneBook()
  {
    createAuthorsWithABook();

    List<Author> authors = authorRepository.findAll();

    List<String> persistentAuthorNameList = Author.getListOfAuthorNames(authors);

    List<String> expectedAuthorNameList = Author.getListOfAuthorNames(expectedAuthorList);

    Assert.assertTrue(expectedAuthorNameList.containsAll(persistentAuthorNameList));

    for (Author author : authors)
    {
      Assert.assertTrue(author.getAuthoredBooks().contains(authoredBook));
    }
  }

  public void createAuthorsWithABook()
  {
    Author andyGlick = new Author("<NAME>");

    Author jimLaSpada = new Author("<NAME>");

    authoredBook = new Book("Spring in Action");

    andyGlick.addAuthoredBook(authoredBook);

    jimLaSpada.addAuthoredBook(authoredBook);

    expectedAuthorList.add(andyGlick);
    expectedAuthorList.add(jimLaSpada);
  }
}<commit_msg>Hadn't been writing objects to the database in the CreateAuthorsWithBookTest, fixed that<commit_after>package info.cukes;

import cucumber.api.java.After;
import cucumber.api.java.Before;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.List;

/**
 * @author glick
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:cucumber.xml"})
public class CreateAuthorsWithBookTest
{
  Book authoredBook;

  List<Author> expectedAuthorList = new ArrayList<>();

  @Autowired
  BookRepository bookRepository;

  @Autowired
  AuthorRepository authorRepository;

  @Before
  public void setUp()
  {
    bookRepository.deleteAll();
    authorRepository.deleteAll();
  }

  @After
  public void tearDown()
  {
    bookRepository.deleteAll();
    authorRepository.deleteAll();
  }

  @Test
  public void testCreateAuthorsEachWithOneBook()
  {
    createAuthorsWithABook();

    List<Author> authors = authorRepository.findAll();

    Assert.assertEquals(2, authors.size());

    List<String> persistentAuthorNameList = Author.getListOfAuthorNames(authors);

    List<String> expectedAuthorNameList = Author.getListOfAuthorNames(expectedAuthorList);

    Assert.assertEquals(2, persistentAuthorNameList.size());

    Assert.assertEquals(2, expectedAuthorNameList.size());

    Assert.assertTrue(expectedAuthorNameList.containsAll(persistentAuthorNameList));

    for (Author author : authors)
    {
      Assert.assertTrue(author.getAuthoredBooks().contains(authoredBook));
    }
  }

  public void createAuthorsWithABook()
  {
    Author andyGlick = new Author("<NAME>");

    Author jimLaSpada = new Author("<NAME>");

    authoredBook = new Book("Spring in Action");

    bookRepository.save(authoredBook);

    andyGlick.addAuthoredBook(authoredBook);

    jimLaSpada.addAuthoredBook(authoredBook);

    authorRepository.save(andyGlick);
    authorRepository.save(jimLaSpada);

    expectedAuthorList.add(andyGlick);
    expectedAuthorList.add(jimLaSpada);
  }
}
{'fraction_non_alphanumeric': 0.10556621880998081, 'fraction_numerical': 0.002159309021113244, 'mean_word_length': 5.015873015873016, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2271916', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1208, 'n_words': 208}