package io.growingabit.app.model;

import static com.google.common.truth.Truth.assertThat;

import java.util.Random;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.junit.Before;
import org.junit.Test;

public class StudentDataTest {

  private StudentData studentData;
  private Random random;

  @Before
  public void setup() {
    this.studentData = new StudentData();
    this.random = new Random();

  }

  @Test
  public void validDate() {
    final String birthDate = (this.random.nextInt(28) + 1) + "/" + (this.random.nextInt(12) + 1) + "/" + (this.random.nextInt(100) + 1900);
    this.studentData.setBirthdate(birthDate);

    assertThat(this.studentData.getBirthdate()).isEqualTo(birthDate);
  }

  @Test(expected = IllegalArgumentException.class)
  public void notAcceptFutureDate() {
    final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("dd/MM/yyyy");
    final String birthDate = dateTimeFormatter.print(new DateTime().plusDays(this.random.nextInt(1000)));
    this.studentData.setBirthdate(birthDate);
  }

  @Test(expected = IllegalArgumentException.class)
  public void notAcceptInvalidDate() {
    final String birthDate = "a non valid date";
    this.studentData.setBirthdate(birthDate);
  }

  @Test(expected = IllegalArgumentException.class)
  public void notAcceptNullDate() {
    final String birthDate = (this.random.nextInt(28) + 1) + "/" + (this.random.nextInt(12) + 1) + "/" + (this.random.nextInt(100) + 1900);
    this.studentData.setBirthdate(null);
  }

  @Test(expected = IllegalArgumentException.class)
  public void notAcceptEmptyDate() {
    final String birthDate = (this.random.nextInt(28) + 1) + "/" + (this.random.nextInt(12) + 1) + "/" + (this.random.nextInt(100) + 1900);
    this.studentData.setBirthdate("");
  }


}

@@ -110,16 +110,17 @@
 Random;%0A
+%0A
 import o
@@ -1407,417 +1407,137 @@
     
-final String birthDate = (this.random.nextInt(28) + 1) + %22/%22 + (this.random.nextInt(12) + 1) + %22/%22 + (this.random.nextInt(100) + 1900);%0A    this.studentData.setBirthdate(null);%0A  %7D%0A%0A  @Test(expected = IllegalArgumentException.class)%0A  public void notAcceptEmptyDate() %7B%0A    final String birthDate = (this.random.nextInt(28) + 1) + %22/%22 + (this.random.nextInt(12) + 1) + %22/%22 + (this.random.nextInt(100) + 1900);
+this.studentData.setBirthdate(null);%0A  %7D%0A%0A  @Test(expected = IllegalArgumentException.class)%0A  public void notAcceptEmptyDate() %7B
 %0A   

Fix StudentDataTest