package ch.epfl.sweng.project;

import org.junit.Assert;
import org.junit.Test;

import ch.epfl.sweng.project.Model.Challenge;
import ch.epfl.sweng.project.Model.CheckPoint;
import ch.epfl.sweng.project.Model.Run;
import ch.epfl.sweng.project.Model.Track;

public class ChallengeTest {
    private Run createTestRun() {
        Track testTrack = new Track();
        testTrack.add(new CheckPoint(2,2));

        Run testRun = new Run("test");
        testRun.setTrack(testTrack);
        testRun.setDuration(10);

        return testRun;
    }

    @Test(expected = IllegalArgumentException.class)
    public void nullOpponentNameThrowsException() {
        Run myRun = createTestRun();
        Run opponentRun = createTestRun();
        Challenge challenge = new Challenge(null, myRun, opponentRun);
    }

    @Test(expected = IllegalArgumentException.class)
    public void emptyOpponentNameThrowsException() {
        Run myRun = createTestRun();
        Run opponentRun = createTestRun();
        Challenge challenge = new Challenge("", myRun, opponentRun);
    }

    @Test(expected = IllegalArgumentException.class)
    public void nullMyRunThrowsException() {
        Challenge challenge = new Challenge("someone", null, createTestRun());
    }

    @Test(expected = IllegalArgumentException.class)
    public void nullOpponentRunThrowsException() {
        Challenge challenge = new Challenge("someone", createTestRun(), null);
    }

    @Test
    public void getters() {
        String opponentName = "someone";
        Run myRun = createTestRun();
        Run opponentRun = createTestRun();
        Challenge challenge = new Challenge(opponentName, myRun, opponentRun);

        Assert.assertTrue(opponentName.equals(challenge.getOpponentName()));
        Assert.assertEquals(myRun.getDuration(), challenge.getMyRun().getDuration());
        Assert.assertEquals(opponentRun.getDuration(), challenge.getOpponentRun().getDuration());
    }

    @Test
    public void setId() {
        String opponentName = "someone";
        Run myRun = createTestRun();
        Run opponentRun = createTestRun();
        Challenge challenge = new Challenge(opponentName, myRun, opponentRun);

        long id = 1234;
        challenge.setId(id);
        Assert.assertEquals(id, challenge.getId());
    }
}

@@ -647,35 +647,118 @@
 ) %7B%0A        
-Run myRun =
+Challenge challenge = new Challenge(null, Challenge.Type.DISTANCE, 100, true, createTestRun(),
  createTestR
@@ -765,121 +765,453 @@
 un()
+)
 ;%0A    
+%7D%0A%0A
     
-Run opponentRun = createTestRun();%0A        Challenge challenge = new Challenge(null, myRun, opponen
+@Test(expected = IllegalArgumentException.class)%0A    public void emptyOpponentNameThrowsException() %7B%0A        Challenge challenge = new Challenge(%22%22, Challenge.Type.TIME, 100, true, createTestRun(), createTestRun());%0A    %7D%0A%0A    @Test(expected = IllegalArgumentException.class)%0A    public void nullMyRunThrowsException() %7B%0A        Challenge challenge = new Challenge(%22someone%22, Challenge.Type.TIME, 100, false, null, createTes
 tRun
+()
 );%0A 
@@ -1281,37 +1281,36 @@
 public void 
-empty
+null
 Opponent
 NameThrowsEx
@@ -1289,36 +1289,35 @@
 oid nullOpponent
-Name
+Run
 ThrowsException(
@@ -1332,79 +1332,215 @@
     
-Run myRun = createTestRun();%0A        Run opponentRun = createTestRun();
+Challenge challenge = new Challenge(%22someone%22, Challenge.Type.TIME, 100, false, createTestRun(), null);%0A    %7D%0A%0A    @Test(expected = IllegalArgumentException.class)%0A    public void nullTypeThrowsException() %7B
 %0A   
@@ -1585,29 +1585,68 @@
 ge(%22
-%22, myRun, opponen
+someone%22, null, 100, false, createTestRun(), createTes
 tRun
+()
 );%0A 
@@ -1717,32 +1717,35 @@
 ublic void n
-ullMyRun
+egativeGoal
 ThrowsExcept
@@ -1807,20 +1807,69 @@
 meone%22, 
-null
+Challenge.Type.DISTANCE, -100, false, createTestRun()
 , create
@@ -1952,39 +1952,32 @@
 public void 
-nullOpponentRun
+zeroGoal
 ThrowsExcept
@@ -2038,16 +2038,51 @@
 omeone%22,
+ Challenge.Type.DISTANCE, 0, false,
  createT
@@ -2083,36 +2083,47 @@
 reateTestRun(), 
-null
+createTestRun()
 );%0A    %7D%0A%0A    @T
@@ -2187,32 +2187,145 @@
 me = %22someone%22;%0A
+        Challenge.Type type = Challenge.Type.DISTANCE;%0A        double goal = 123;%0A        boolean isWon = false;%0A
         Run myRu
@@ -2437,32 +2437,51 @@
 ge(opponentName,
+ type, goal, isWon,
  myRun, opponent
@@ -2560,24 +2560,194 @@
 ntName()));%0A
+        Assert.assertTrue(type == challenge.getType());%0A        Assert.assertEquals(goal, challenge.getGoal(), 0);%0A        Assert.assertTrue(isWon == challenge.isWon());%0A
         Asse
@@ -3139,16 +3139,49 @@
 entName,
+ Challenge.Type.TIME, 100, false,
  myRun, 

Add some tests to Challenge class for new getters and constructor