<commit_before>package com.concurrentperformance.ringingmaster.engine.notation.impl;


import com.concurrentperformance.ringingmaster.engine.NumberOfBells;
import com.concurrentperformance.ringingmaster.engine.notation.NotationBody;
import com.concurrentperformance.ringingmaster.generated.notation.persist.SerializableNotation;
import com.ringingmaster.extraction.CentralCouncilMethodExtractor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

@RunWith(Parameterized.class)
public class CheckAllLeadHeadsTest {

	private final Logger log = LoggerFactory.getLogger(this.getClass());


	@Parameterized.Parameters
	public static Collection<Object[]> checkAllCCLibrary() {
		return new CentralCouncilMethodExtractor()
				.extractNotationsToStream()
//				.filter(serializableNotation -> serializableNotation.getNumberOfBells() == 8)
//				.filter(serializableNotation -> serializableNotation.getName().contains("Waterloo Reverse Bob"))
				.map(serializableNotation -> new Object[]{serializableNotation})
				.collect(Collectors.toList());
	}

	public CheckAllLeadHeadsTest(SerializableNotation serializableNotation) {
		this.serializableNotation = serializableNotation;
	}

	private final SerializableNotation serializableNotation;

	@Test
	public void checkLeadHeadCorrectness() {

		log.info(serializableNotation.toString());

		NotationBody notationBody = NotationBuilder.getInstance()
				.setFromSerializableNotation(serializableNotation)
				.build();

		NumberOfBells ccNumberOfBells = NumberOfBells.valueOf(serializableNotation.getNumberOfBells());
		String ccLeadHead = serializableNotation.getLeadHead();


		// Uncomment section to log out the changes in the lead
//		log.warn(notationBody.toString());
//		log.warn(PlainCourseHelper.buildPlainCourse(notationBody, "TEST", false).getCreatedMethod().getLead(0).toString());

		LeadHeadCalculator.LeadHeadCodeType leadHeadType = LeadHeadCalculator.getLeadHeadType(ccLeadHead, ccNumberOfBells);

		String calculatedLeadHead = null;
		if (leadHeadType == LeadHeadCalculator.LeadHeadCodeType.VALID_LEADHEAD_ROW) {

			//TODO need to exclude non plain bob lead heads from calculating a code.
			// These rows are where it is not a plain bob lead head, and therefore no code is in the cc library.
//			calculatedLeadHead = LeadHeadCalculator.lookupRowFromCode(notationBody.getLeadHeadCode(), notationBody.getNumberOfWorkingBells());
			calculatedLeadHead = notationBody.getLeadHeadCode();
		}
		else if (leadHeadType == LeadHeadCalculator.LeadHeadCodeType.VALID_LEADHEAD_CODE){
			calculatedLeadHead = notationBody.getLeadHeadCode();
		}
		else {
			fail();
		}

		assertEquals("[" + notationBody.getNumberOfWorkingBells().getBellCount() + "] " + notationBody.getNameIncludingNumberOfBells() +
						"[" + ccLeadHead + "](library) vs [" + notationBody.getLeadHeadCode() + "](calculated) NOT OK ",
				ccLeadHead, calculatedLeadHead);

	}
}<commit_msg>Tidy up the main lead head test<commit_after>package com.concurrentperformance.ringingmaster.engine.notation.impl;


import com.concurrentperformance.ringingmaster.engine.NumberOfBells;
import com.concurrentperformance.ringingmaster.engine.helper.PlainCourseHelper;
import com.concurrentperformance.ringingmaster.engine.notation.NotationBody;
import com.concurrentperformance.ringingmaster.generated.notation.persist.SerializableNotation;
import com.ringingmaster.extraction.CentralCouncilMethodExtractor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class CheckAllLeadHeadsTest {

	private final Logger log = LoggerFactory.getLogger(this.getClass());


	@Parameterized.Parameters
	public static Collection<Object[]> checkAllCCLibrary() {
		return new CentralCouncilMethodExtractor()
				.extractNotationsToStream()
				.filter(serializableNotation -> serializableNotation.getNumberOfBells() == 8)
				.filter(serializableNotation -> serializableNotation.getName().contains("Waterloo Reverse Bob"))
				.map(serializableNotation -> new Object[]{serializableNotation})
				.collect(Collectors.toList());
	}

	public CheckAllLeadHeadsTest(SerializableNotation serializableNotation) {
		this.serializableNotation = serializableNotation;
	}

	private final SerializableNotation serializableNotation;

	@Test
	public void checkLeadHeadCorrectness() {

		log.info(serializableNotation.toString());

		NotationBody notationBody = NotationBuilder.getInstance()
				.setFromSerializableNotation(serializableNotation)
				.build();

		NumberOfBells ccNumberOfBells = NumberOfBells.valueOf(serializableNotation.getNumberOfBells());
		String ccLeadHead = serializableNotation.getLeadHead();


		// Uncomment section to log out the changes in the lead
		log.warn(notationBody.toString());
		log.warn(PlainCourseHelper.buildPlainCourse(notationBody, "TEST", false).getCreatedMethod().getLead(0).toString());

		LeadHeadCalculator.LeadHeadCodeType leadHeadType = LeadHeadCalculator.getLeadHeadType(ccLeadHead, ccNumberOfBells);

		String calculatedLeadHead = notationBody.getLeadHeadCode();
		if (leadHeadType == LeadHeadCalculator.LeadHeadCodeType.VALID_LEADHEAD_ROW) {
			//TODO need to exclude non plain bob lead heads from calculating a code.
			// These rows are where it is not a plain bob lead head, and therefore no code is in the cc library.
			calculatedLeadHead = LeadHeadCalculator.lookupRowFromCode(notationBody.getLeadHeadCode(), notationBody.getNumberOfWorkingBells());
		}

		assertEquals("[" + notationBody.getNumberOfWorkingBells().getBellCount() + "] " + notationBody.getNameIncludingNumberOfBells() +
						"[" + ccLeadHead + "](library) vs [" + notationBody.getLeadHeadCode() + "](calculated) NOT OK ",
				ccLeadHead, calculatedLeadHead);

	}
}
{'fraction_non_alphanumeric': 0.09858926544511107, 'fraction_numerical': 0.0012972271769093563, 'mean_word_length': 6.265017667844523, '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': '145916', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1738, 'n_words': 329}