<commit_before>package org.innovateuk.ifs.competition.resource;

import org.junit.Test;

import java.time.ZonedDateTime;

import static org.innovateuk.ifs.competition.builder.CompetitionResourceBuilder.newCompetitionResource;
import static org.junit.Assert.*;

public class CompetitionSetupSectionTest {

	@Test
	public void testFromPathNotRecognised() {
		String path = "something";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertNull(result);
	}
	
	@Test
	public void testFromPathInitial() {
		String path = "initial";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.INITIAL_DETAILS, result);
	}
	
	@Test
	public void testFromPathAdditional() {
		String path = "additional";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.ADDITIONAL_INFO, result);
	}
	
	@Test
	public void testFromPathEligibility() {
		String path = "eligibility";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.ELIGIBILITY, result);
	}
	
	@Test
	public void testFromPathMilestones() {
		String path = "milestones";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.MILESTONES, result);
	}
	
	@Test
	public void testFromPathApplication() {
		String path = "application";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.APPLICATION_FORM, result);
	}

	@Test
	public void fromPathProjectDocument() {
		String path = "project-document";

		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);

		assertEquals(CompetitionSetupSection.PROJECT_DOCUMENT, result);
	}

	@Test
	public void testAllSectionsEditableWhenSetupIsCompleteAndNotYetInAssessment() {
		CompetitionSetupSection homeSection = CompetitionSetupSection.HOME;
		CompetitionSetupSection eligibilitySection = CompetitionSetupSection.ELIGIBILITY;
		CompetitionSetupSection milestonesSection = CompetitionSetupSection.MILESTONES;
		CompetitionSetupSection applicationFormSection = CompetitionSetupSection.APPLICATION_FORM;
		CompetitionSetupSection assessorSection = CompetitionSetupSection.ASSESSORS;
		CompetitionSetupSection initialDetailsSection = CompetitionSetupSection.INITIAL_DETAILS;
		CompetitionSetupSection additionalInfoSection = CompetitionSetupSection.ADDITIONAL_INFO;
		CompetitionSetupSection projectDocumentSection = CompetitionSetupSection.PROJECT_DOCUMENT;

		ZonedDateTime tomorrow = ZonedDateTime.now().plusDays(1);

		CompetitionResource competitionResource = newCompetitionResource()
				.withSetupComplete(true)
				.withStartDate(tomorrow)
				.withFundersPanelDate(tomorrow)
				.build();

		assertFalse(homeSection.preventEdit(competitionResource));
		assertFalse(eligibilitySection.preventEdit(competitionResource));
		assertFalse(milestonesSection.preventEdit(competitionResource));
		assertFalse(applicationFormSection.preventEdit(competitionResource));
		assertFalse(assessorSection.preventEdit(competitionResource));
		assertFalse(initialDetailsSection.preventEdit(competitionResource));
		assertFalse(additionalInfoSection.preventEdit(competitionResource));
		assertFalse(projectDocumentSection.preventEdit(competitionResource));
	}

	@Test
	public void testSectionsEditableWhenCompetitionStartedAndSetupIsCompleteAndNotYetInAssessment() {
		CompetitionSetupSection initialDetailsSection = CompetitionSetupSection.INITIAL_DETAILS;
		CompetitionSetupSection additionalInfoSection = CompetitionSetupSection.ADDITIONAL_INFO;

		ZonedDateTime yesterday = ZonedDateTime.now().minusDays(1);
		ZonedDateTime tomorrow = ZonedDateTime.now().plusDays(1);

		CompetitionResource competitionResource = newCompetitionResource()
				.withSetupComplete(true)
				.withStartDate(yesterday)
				.withFundersPanelDate(tomorrow)
				.build();

		assertFalse(initialDetailsSection.preventEdit(competitionResource));
		assertFalse(additionalInfoSection.preventEdit(competitionResource));
	}

	@Test
	public void testSectionsNotEditableWhenCompetitionStartedAndSetupIsCompleteAndNotYetInAssessment() {
		CompetitionSetupSection homeSection = CompetitionSetupSection.HOME;
		CompetitionSetupSection eligibilitySection = CompetitionSetupSection.ELIGIBILITY;
		CompetitionSetupSection milestonesSection = CompetitionSetupSection.MILESTONES;
		CompetitionSetupSection applicationFormSection = CompetitionSetupSection.APPLICATION_FORM;
		CompetitionSetupSection assessorSection = CompetitionSetupSection.ASSESSORS;
		CompetitionSetupSection initialDetailsSection = CompetitionSetupSection.INITIAL_DETAILS;
		CompetitionSetupSection additionalInfoSection = CompetitionSetupSection.ADDITIONAL_INFO;
		CompetitionSetupSection projectDocumentSection = CompetitionSetupSection.PROJECT_DOCUMENT;

		ZonedDateTime yesterday = ZonedDateTime.now().minusDays(1);

		CompetitionResource competitionResource = newCompetitionResource()
				.withSetupComplete(true)
				.withStartDate(yesterday)
				.withFundersPanelDate(yesterday)
				.build();

		assertTrue(homeSection.preventEdit(competitionResource));
		assertTrue(eligibilitySection.preventEdit(competitionResource));
		assertTrue(milestonesSection.preventEdit(competitionResource));
		assertTrue(applicationFormSection.preventEdit(competitionResource));
		assertTrue(assessorSection.preventEdit(competitionResource));
		assertTrue(initialDetailsSection.preventEdit(competitionResource));
		assertTrue(additionalInfoSection.preventEdit(competitionResource));
		assertTrue(projectDocumentSection.preventEdit(competitionResource));
	}
}
<commit_msg>fixed unit test<commit_after>package org.innovateuk.ifs.competition.resource;

import org.junit.Test;

import java.time.ZonedDateTime;

import static org.innovateuk.ifs.competition.builder.CompetitionResourceBuilder.newCompetitionResource;
import static org.innovateuk.ifs.competition.resource.CompetitionStatus.OPEN;
import static org.junit.Assert.*;

public class CompetitionSetupSectionTest {

	@Test
	public void testFromPathNotRecognised() {
		String path = "something";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertNull(result);
	}
	
	@Test
	public void testFromPathInitial() {
		String path = "initial";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.INITIAL_DETAILS, result);
	}
	
	@Test
	public void testFromPathAdditional() {
		String path = "additional";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.ADDITIONAL_INFO, result);
	}
	
	@Test
	public void testFromPathEligibility() {
		String path = "eligibility";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.ELIGIBILITY, result);
	}
	
	@Test
	public void testFromPathMilestones() {
		String path = "milestones";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.MILESTONES, result);
	}
	
	@Test
	public void testFromPathApplication() {
		String path = "application";
		
		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);
		
		assertEquals(CompetitionSetupSection.APPLICATION_FORM, result);
	}

	@Test
	public void fromPathProjectDocument() {
		String path = "project-document";

		CompetitionSetupSection result = CompetitionSetupSection.fromPath(path);

		assertEquals(CompetitionSetupSection.PROJECT_DOCUMENT, result);
	}

	@Test
	public void testAllSectionsEditableWhenSetupIsCompleteAndNotYetInAssessment() {
		CompetitionSetupSection homeSection = CompetitionSetupSection.HOME;
		CompetitionSetupSection eligibilitySection = CompetitionSetupSection.ELIGIBILITY;
		CompetitionSetupSection milestonesSection = CompetitionSetupSection.MILESTONES;
		CompetitionSetupSection applicationFormSection = CompetitionSetupSection.APPLICATION_FORM;
		CompetitionSetupSection assessorSection = CompetitionSetupSection.ASSESSORS;
		CompetitionSetupSection initialDetailsSection = CompetitionSetupSection.INITIAL_DETAILS;
		CompetitionSetupSection additionalInfoSection = CompetitionSetupSection.ADDITIONAL_INFO;
		CompetitionSetupSection projectDocumentSection = CompetitionSetupSection.PROJECT_DOCUMENT;

		ZonedDateTime tomorrow = ZonedDateTime.now().plusDays(1);

		CompetitionResource competitionResource = newCompetitionResource()
				.withSetupComplete(true)
				.withCompetitionStatus(OPEN)
				.withStartDate(tomorrow)
				.withFundersPanelDate(tomorrow)
				.build();

		assertFalse(homeSection.preventEdit(competitionResource));
		assertFalse(eligibilitySection.preventEdit(competitionResource));
		assertFalse(milestonesSection.preventEdit(competitionResource));
		assertFalse(applicationFormSection.preventEdit(competitionResource));
		assertFalse(assessorSection.preventEdit(competitionResource));
		assertFalse(initialDetailsSection.preventEdit(competitionResource));
		assertFalse(additionalInfoSection.preventEdit(competitionResource));
		assertFalse(projectDocumentSection.preventEdit(competitionResource));
	}

	@Test
	public void testSectionsEditableWhenCompetitionStartedAndSetupIsCompleteAndNotYetInAssessment() {
		CompetitionSetupSection initialDetailsSection = CompetitionSetupSection.INITIAL_DETAILS;
		CompetitionSetupSection additionalInfoSection = CompetitionSetupSection.ADDITIONAL_INFO;

		ZonedDateTime yesterday = ZonedDateTime.now().minusDays(1);
		ZonedDateTime tomorrow = ZonedDateTime.now().plusDays(1);

		CompetitionResource competitionResource = newCompetitionResource()
				.withSetupComplete(true)
				.withStartDate(yesterday)
				.withFundersPanelDate(tomorrow)
				.build();

		assertFalse(initialDetailsSection.preventEdit(competitionResource));
		assertFalse(additionalInfoSection.preventEdit(competitionResource));
	}

	@Test
	public void testSectionsNotEditableWhenCompetitionStartedAndSetupIsCompleteAndNotYetInAssessment() {
		CompetitionSetupSection homeSection = CompetitionSetupSection.HOME;
		CompetitionSetupSection eligibilitySection = CompetitionSetupSection.ELIGIBILITY;
		CompetitionSetupSection milestonesSection = CompetitionSetupSection.MILESTONES;
		CompetitionSetupSection applicationFormSection = CompetitionSetupSection.APPLICATION_FORM;
		CompetitionSetupSection assessorSection = CompetitionSetupSection.ASSESSORS;
		CompetitionSetupSection initialDetailsSection = CompetitionSetupSection.INITIAL_DETAILS;
		CompetitionSetupSection additionalInfoSection = CompetitionSetupSection.ADDITIONAL_INFO;
		CompetitionSetupSection projectDocumentSection = CompetitionSetupSection.PROJECT_DOCUMENT;

		ZonedDateTime yesterday = ZonedDateTime.now().minusDays(1);

		CompetitionResource competitionResource = newCompetitionResource()
				.withSetupComplete(true)
				.withStartDate(yesterday)
				.withFundersPanelDate(yesterday)
				.build();

		assertTrue(homeSection.preventEdit(competitionResource));
		assertTrue(eligibilitySection.preventEdit(competitionResource));
		assertTrue(milestonesSection.preventEdit(competitionResource));
		assertTrue(applicationFormSection.preventEdit(competitionResource));
		assertTrue(assessorSection.preventEdit(competitionResource));
		assertTrue(initialDetailsSection.preventEdit(competitionResource));
		assertTrue(additionalInfoSection.preventEdit(competitionResource));
		assertTrue(projectDocumentSection.preventEdit(competitionResource));
	}
}

{'fraction_non_alphanumeric': 0.07276489352530391, 'fraction_numerical': 0.000689714630571601, 'mean_word_length': 8.006211180124224, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4829076', 'n_tokens_mistral': 3469, 'n_tokens_neox': 2933, 'n_words': 436}