package edu.fiu.jtlex.data;

import static org.junit.jupiter.api.Assertions.*;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.junit.jupiter.api.Test;
import edu.fiu.jtlex.data.IEvent.EventClass;
import edu.fiu.jtlex.data.IInstance.Aspect;
import edu.fiu.jtlex.data.IInstance.Polarity;
import edu.fiu.jtlex.data.IInstance.Pos;
import edu.fiu.jtlex.data.IInstance.Tense;
import edu.fiu.jtlex.data.ILink.LinkTag;
import edu.fiu.jtlex.data.ILink.Origintype;
import edu.fiu.jtlex.data.ILink.TLinkType;
import edu.fiu.jtlex.data.ITimex.FunctionInDocument;
import edu.fiu.jtlex.data.ITimex.TimexMod;
import edu.fiu.jtlex.data.ITimex.TimexType;

class TextTest {
	
	private final Event event = new Event(1,EventClass.ASPECTUAL, null);
	private final ISignal signal = new Signal(1, "on");
	private final Instance eventInstance = new Instance (1, event, Tense.FUTURE, Aspect.NONE, Pos.ADJECTIVE, Polarity.NEG,
			null, signal, "1");
	Set<IInstance> eventInstances = new HashSet<>(Arrays.asList(eventInstance));
	Set<ITimex> timexes = new HashSet<ITimex>(Arrays.asList(new Timex(1, TimexType.DATE, "0d", TimexMod.APPROX, false, 0, FunctionInDocument.NONE,
			2, 3, "every", "w", "something")));
	Set<ILink> links = new HashSet<ILink>(Arrays.asList(new Link(LinkTag.TLINK, 1, "word", eventInstance, null, eventInstance,
			TLinkType.AFTER, Origintype.CLOSURE)));
	Set<ITimex> emptyTimex = new HashSet<>();
	Set<IInstance> emptyInstance = new HashSet<>();
	Set<ILink> emptyLink = new HashSet<>();
	String text = "some text";
	String nullText = null;
	String emptyText = "";
	String whitespaceText = "        ";

	@Test
	void testConstructor(){
		new Text(text, text, timexes, links, eventInstances);
	}

	@Test
	void testRawTextNull() {
		assertThrows(NullPointerException.class, ()-> new Text(nullText, text, timexes, links,eventInstances));
	}
	
	@Test
	void testRawTextEmpty() {
		assertThrows(IllegalArgumentException.class, ()-> new Text(emptyText, text, timexes, links,eventInstances));
	}
	
	@Test
	void testRawTextWhitespace() {
		assertThrows(IllegalArgumentException.class, ()-> new Text(whitespaceText, text, timexes, links,eventInstances));
	}
	
	@Test
	void testTextNull() {
		assertThrows(NullPointerException.class, ()-> new Text(text, nullText, timexes, links,eventInstances));
	}
	
	@Test
	void testTextEmpty() {
		assertThrows(IllegalArgumentException.class, ()-> new Text(text, emptyText, timexes, links,eventInstances));
	}
	
	@Test
	void testRawWhitespace() {
		assertThrows(IllegalArgumentException.class, ()-> new Text(text, whitespaceText, timexes, links,eventInstances));
	}
	
	@Test
	void testTimexesEmpty() {
		assertThrows(IllegalArgumentException.class, ()-> new Text(text, text, emptyTimex, links,eventInstances));
	}
	
	@Test
	void testInstancesEmpty() {
		assertThrows(IllegalArgumentException.class, ()-> new Text(text, text, timexes, links,emptyInstance));
	}
	
	@Test
	void testLinkEmpty() {
		assertThrows(IllegalArgumentException.class, ()-> new Text(text, text, timexes, emptyLink,eventInstances));
	}
	
	
	
	
	
}
