<commit_before>package cane.brothers.circus;

import static org.junit.Assert.assertThat;

import java.util.List;

import javax.annotation.Resource;

import org.hamcrest.CoreMatchers;
import org.joda.time.DateTime;
import org.joda.time.Period;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import cane.brothers.circus.domain.Program;
import cane.brothers.circus.domain.Troupe;
import cane.brothers.circus.repository.ProgramRepository;
import cane.brothers.circus.repository.TroupeRepository;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = JpaConfig.class)
public class TestCreateCircusData {
	
	private static final Logger log = LoggerFactory.getLogger(TestCreateCircusData.class);
	
	@Resource
	private TroupeRepository troupeRepo;
	
	@Resource
	private ProgramRepository programRepo;

	private Troupe liones;
	private Troupe aquacircus;
	
	private Program lionesInArea;
	private Program waterShow;


	@Before
	public void createTestData() {
		// troupes
		liones = troupeRepo.save(new Troupe("Канские Львы", "Михалков"));
		aquacircus = troupeRepo.save(new Troupe("Цирк на воде", "Шевченко"));
		
		// programs
		DateTime firstDate = new DateTime(2015, 10, 1, 12, 0);
		DateTime lastDate = firstDate.plus(Period.months(3));
		DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd");
		log.error(String.format("c %s по %s", firstDate.toString(fmt), lastDate.toString(fmt)));
		
		waterShow = programRepo.save( new Program("Цирк на воде в Воронеже", "Незабываемое шоу", firstDate, lastDate, aquacircus));
		
		firstDate = new DateTime(2016, 2, 1, 12, 0);
		lastDate = firstDate.plus(Period.months(3));
		log.error(String.format("c %s по %s", firstDate.toString(fmt), lastDate.toString(fmt)));
		
		lionesInArea = programRepo.save( new Program("Львы на арене", firstDate, lastDate, liones));
	}

	@Test
	public void testThatEntitiesCanBeFound() {
		testThatTroupesCanBeFound();
		testThatProgramsCanBeFound();
	}
	
	private void testThatTroupesCanBeFound() {
		List<Troupe> troupes = troupeRepo.findAll();
		log.error(String.format("!!! Есть труппы %s", troupes));
		assertThat(troupes, CoreMatchers.notNullValue());
		assertThat(troupes, CoreMatchers.hasItems(liones, aquacircus));
	}
	
	private void testThatProgramsCanBeFound() {
		List<Program> programs = programRepo.findAll();
		if(programs != null) {
			for(Program p: programs) {
				//Hibernate.initialize(p);
				log.error(String.format("!!! Есть программа: %s", p));
			}
		}
		assertThat(programs, CoreMatchers.notNullValue());
		assertThat(programs, CoreMatchers.hasItems(lionesInArea, waterShow));
	}

}<commit_msg>create circus test data<commit_after>package cane.brothers.circus;

import static org.junit.Assert.assertThat;

import java.util.List;

import javax.annotation.Resource;

import org.hamcrest.CoreMatchers;
import org.joda.time.DateTime;
import org.joda.time.Period;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import cane.brothers.circus.domain.Circus;
import cane.brothers.circus.domain.CircusLayout;
import cane.brothers.circus.domain.Program;
import cane.brothers.circus.domain.Troupe;
import cane.brothers.circus.repository.CircusLayoutRepository;
import cane.brothers.circus.repository.CircusRepository;
import cane.brothers.circus.repository.ProgramRepository;
import cane.brothers.circus.repository.TroupeRepository;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = JpaConfig.class)
public class TestCreateCircusData {
	
	private static final Logger log = LoggerFactory.getLogger(TestCreateCircusData.class);
	
	
	@Resource
	private CircusRepository circusRepo;

	@Resource
	private CircusLayoutRepository layoutRepo;
	
	@Resource
	private TroupeRepository troupeRepo;
	
	@Resource
	private ProgramRepository programRepo;

	
	private Circus circus;
	private CircusLayout layout;
	
	private Troupe liones;
	private Troupe aquacircus;
	
	private Program lionesInArea;
	private Program waterShow;




	@Before
	public void createTestData() {
		// circus
		circus = new Circus("Воронежский цирк", 
				"94006, г. Воронеж, ул. 20-летия октября, 121", 
				"Воронежский государственный цирк им. <NAME>");
		circus = circusRepo.save(circus);
		
		// layout
		layout = new CircusLayout(circus, "<NAME> ", 2400);
		layout = layoutRepo.save(layout);
		
		
		// troupes
		liones = troupeRepo.save(new Troupe("<NAME>", "Михалков"));
		aquacircus = troupeRepo.save(new Troupe("Цирк на воде", "Шевченко"));
		
		// programs
		DateTime firstDate = new DateTime(2015, 10, 1, 12, 0);
		DateTime lastDate = firstDate.plus(Period.months(3));
		DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd");
		log.error(String.format("c %s по %s", firstDate.toString(fmt), lastDate.toString(fmt)));
		
		waterShow = programRepo.save( new Program("Цирк на воде в Воронеже", "Незабываемое шоу", firstDate, lastDate, aquacircus));
		
		firstDate = new DateTime(2016, 2, 1, 12, 0);
		lastDate = firstDate.plus(Period.months(3));
		log.error(String.format("c %s по %s", firstDate.toString(fmt), lastDate.toString(fmt)));
		
		lionesInArea = programRepo.save( new Program("Львы на арене", firstDate, lastDate, liones));
	}

	@Test
	public void testThatEntitiesCanBeFound() {
		testThatTroupesCanBeFound();
		testThatProgramsCanBeFound();
	}
	
	private void testThatTroupesCanBeFound() {
		List<Troupe> troupes = troupeRepo.findAll();
		log.error(String.format("!!! Есть труппы %s", troupes));
		assertThat(troupes, CoreMatchers.notNullValue());
		assertThat(troupes, CoreMatchers.hasItems(liones, aquacircus));
	}
	
	private void testThatProgramsCanBeFound() {
		List<Program> programs = programRepo.findAll();
		if(programs != null) {
			for(Program p: programs) {
				//Hibernate.initialize(p);
				// TODO
				p.getActorsGroup();
				log.error(String.format("!!! Есть программа: %s", p));
			}
		}
		assertThat(programs, CoreMatchers.notNullValue());
		assertThat(programs, CoreMatchers.hasItems(lionesInArea, waterShow));
	}

}
{'fraction_non_alphanumeric': 0.11987237921604375, 'fraction_numerical': 0.010027347310847767, 'mean_word_length': 5.472959685349066, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '2276805', 'n_tokens_mistral': 2397, 'n_tokens_neox': 2213, 'n_words': 435}