package edu.fiu.jtlex.data;

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

import org.junit.jupiter.api.Assertions;
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.TLinkType;
import edu.fiu.jtlex.data.ILink.ALinkType;
import edu.fiu.jtlex.data.ILink.SLinkType;
import edu.fiu.jtlex.data.ILink.LinkTag;
import edu.fiu.jtlex.data.ILink.Origintype;
//import edu.fiu.jtlex.data.ILink.TLinkRelType;


class LinkTest {

	//test for Tlink Constructor
	/**
	 * Test case ID: testTLinkConstructor()
	 * Purpose: Test Tlink constructor when passing a tag other than TLINK
	 * Test set up: Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
	 *				Signal signalTest = new Signal (123,"123");
	 *				Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
	 *					signalTest,123);
	 * Test input:  testing =new Link(LinkTag.ALINK,0,"asd",eventTest,"123",eventTest,TLinkRelType.AFTER,Origintype.MANUALLY);
	 * Expected output: error: IllegalArgumentException
	 */
	@Test
	void testTLinkConstructor(){

		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		Assertions.assertThrows(IllegalArgumentException.class, () -> {
			new Link(LinkTag.ALINK,0,"asd",intanceTest,signalTest,intanceTest, TLinkType.AFTER  ,Origintype.MANUALLY);
		  });
	}
	
	

	/**
	 * Test case ID: testTLinkConstructor2()
	 * Purpose: Test Tlink constructor when passing null for srelType
	 * Test set up: Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
	 *				Signal signalTest = new Signal (123,"123");
	 *				Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
	 *					signalTest,123);
	 * Test input:testing = new Link(LinkTag.TLINK,0,"asd",eventTest,"123",eventTest,null,Origintype.MANUALLY);
	 * Expected output: error: NullPointerException
	 */
	
	
	@Test
	void testTLinkConstructor2(){
		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		
		Assertions.assertThrows(NullPointerException.class, () -> {
			new Link(LinkTag.TLINK,0,"asd",intanceTest,signalTest,intanceTest,null,Origintype.MANUALLY);
		  });
	}
	

	/**
	 * Test case ID: testTLinkConstructor3()
	 * Purpose: Test Tlink constructor when passing null for eventInstance
	 * Test set up: Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
	 *				Signal signalTest = new Signal (123,"123");
	 *				Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
	 *					signalTest,123);
	 * Test input:testing = new Link(LinkTag.TLINK,0,"asd",null,"123",eventTest,TLinkRelType.AFTER,Origintype.MANUALLY);
	 * Expected output: error: NullPointerException
	 */
	@Test
	void testTLinkConstructor3(){
		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		
		
		Assertions.assertThrows(NullPointerException.class, () -> {
			new Link(LinkTag.TLINK,0,"asd",null,signalTest,intanceTest,TLinkType.AFTER,Origintype.MANUALLY);
		  });
	}
	
	
	
	
	//test for S link constructor
	/**
	 * Test case ID: testSLinkConstructor()
	 * Purpose: Test Slink constructor when passing a tag other than SLINK
	 * Test set up: Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
	 *				Signal signalTest = new Signal (123,"123");
	 *				Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
	 *					signalTest,123);
	 * Test input: testing = new Link(LinkTag.TLINK,0,"asd",eventTest,"123",eventTest,SLinkRelType.COUNTER_FACTIVE);
	 * Expected output: error: IllegalArgumentException
	 */
	@Test
	void testSLinkConstructor(){
		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		
		Assertions.assertThrows(IllegalArgumentException.class, () -> {
			new Link(LinkTag.TLINK,0,"asd",intanceTest,signalTest,intanceTest,SLinkType.COUNTER_FACTIVE);
		  });
	}
	
	/**
	 * Test case ID: testSLinkConstructor()
	 * Purpose: Test Slink constructor when passing a null for eventInstance
	 * Test set up:	Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
	 *				Signal signalTest = new Signal (123,"123");
	 *				Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
	 *					signalTest,123);
	 * Test input: testing = new Link(LinkTag.SLINK,0,"asd",null,"123",eventTest,SLinkRelType.COUNTER_FACTIVE);
	 * Expected output: error: NullPointerException
	 */
	@Test
	void testSLinkConstructor2(){
		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		
		
		Assertions.assertThrows(NullPointerException.class, () -> {
			new Link(LinkTag.SLINK,0,"asd",null,signalTest,intanceTest,SLinkType.COUNTER_FACTIVE);
		  });
	}
	
	
	
	//test for A link constructor
	/**
	 * Test case ID: testALinkConstructor()
	 * Purpose: Test Alink constructor when passing a tag other than ALINK
	 * Test set up: Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
	 *				Signal signalTest = new Signal (123,"123");
	 *				Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
	 *					signalTest,123);
	 * Test input:  testing = new Link(LinkTag.TLINK,0,"asd",eventTest,"123",eventTest,ALinkRelType.CONTINUES);
	 * Expected output: error: IllegalArgumentException
	 */
	@Test
	void testALinkConstructor(){
		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		
		Assertions.assertThrows(IllegalArgumentException.class, () -> {
			new Link(LinkTag.TLINK,0,"asd",intanceTest,signalTest,intanceTest,ALinkType.CONTINUES);
		  });
	}
	
	
	
	/**
	 * Test case ID: testALinkConstructor()
	 * Purpose: Test Alink constructor when passing a null for eventInstance
	 * Test set up: Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
	 *				Signal signalTest = new Signal (123,"123");
	 *				Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
	 *					signalTest,123);
	 * Test input:  testing =  new Link(LinkTag.ALINK,0,"asd",null,"123",eventTest,ALinkRelType.CONTINUES);
	 * Expected output: error:NullPointerException
	 */
	@Test
	void testALinkConstructor2(){
		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		
		Assertions.assertThrows(NullPointerException.class, () -> {
			new Link(LinkTag.ALINK,0,"asd",null,signalTest,intanceTest,ALinkType.CONTINUES);
		  });
	}
	
	//testing getters
	
	/**
	 * Test case ID: testgetLinkIDgetter()
	 * Purpose: Test getLinkID getter
	 * Test set up:	Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
	 *				Signal signalTest = new Signal (123,"123");
	 *				Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
	 *					signalTest,123);
	 * Test input:  testing.getLinkID(
	 * Expected output: testing.getLinkID == 111
	 */
	@Test
	void testgetLinkIDgetter() {
		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		
		
		Link testing = new Link(LinkTag.TLINK,111,"asd",intanceTest,signalTest,intanceTest,TLinkType.AFTER,Origintype.MANUALLY);
		assertEquals(testing.getLinkID(), 111);
		
	}
	
	
	/**
	 * Test case ID: testgetRelType()
	 * Purpose: Test getRelType getter
	 * Test set up: Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
					Signal signalTest = new Signal (123,"123");
					Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
						signalTest,123);
	 * Test input: testing.getRelType()
	 * Expected output: testing.getRelType() == TLinkRelType.AFTER
	 */
	@Test
	void testgetRelType() {
		Event eventTest = new Event (123, EventClass.ASPECTUAL,"asd");
		Signal signalTest = new Signal (123,"123");
		Instance intanceTest = new Instance(123,eventTest, Tense.INFINITIVE,Aspect.PERFECTIVE, Pos.NOUN, Polarity.NEG, "asd",
				signalTest,"123");
		
		Link testing = new Link(LinkTag.TLINK,111,"asd",intanceTest,signalTest,intanceTest,TLinkType.AFTER,Origintype.MANUALLY);
		assertEquals(testing.getRelType(), TLinkType.AFTER);
		
	}
	
	
	

}
