package org.synyx.urlaubsverwaltung.sicknote.web;

import org.junit.Before;
import org.junit.Test;
import org.synyx.urlaubsverwaltung.period.DayLength;
import org.synyx.urlaubsverwaltung.person.Person;
import org.synyx.urlaubsverwaltung.sicknote.SickNote;
import org.synyx.urlaubsverwaltung.sicknote.SickNoteType;

import java.time.LocalDate;

import static org.assertj.core.api.Assertions.assertThat;

public class SickNoteFormTest {

    private final LocalDate day2019_04_16 = LocalDate.of(2019, 4, 16);
    private final Integer id = 1;
    private final Person person = new Person();
    private final SickNoteType type = new SickNoteType();
    private final DayLength dayLength = DayLength.FULL;
    private final String comment = "my comment";

    private SickNoteForm sut;

    @Before
    public void setUp() {
        sut = new SickNoteForm();

        sut.setId(id);
        sut.setPerson(person);
        sut.setSickNoteType(type);
        sut.setStartDate(day2019_04_16);
        sut.setEndDate(day2019_04_16);
        sut.setDayLength(dayLength);
        sut.setAubStartDate(day2019_04_16);
        sut.setAubEndDate(day2019_04_16);
        sut.setComment(comment);
    }

    @Test
    public void checkGeneratedSickNote() {

        SickNote sickNote = sut.generateSickNote();


        assertThat(sickNote.getId()).isEqualTo(id);
        assertThat(sickNote.getPerson()).isEqualTo(person);
        assertThat(sickNote.getSickNoteType()).isEqualTo(type);
        assertThat(sickNote.getStartDate()).isEqualTo(day2019_04_16);
        assertThat(sickNote.getEndDate()).isEqualTo(day2019_04_16);
        assertThat(sickNote.getDayLength()).isEqualTo(dayLength);
        assertThat(sickNote.getAubStartDate()).isEqualTo(day2019_04_16);
        assertThat(sickNote.getAubEndDate()).isEqualTo(day2019_04_16);
    }

    @Test
    public void checkCopyConstructur() {
        SickNote sickNote = sut.generateSickNote();

        SickNoteForm sickNoteForm = new SickNoteForm(sickNote);

        assertThat(sickNoteForm.getId()).isEqualTo(id);
        assertThat(sickNoteForm.getPerson()).isEqualTo(person);
        assertThat(sickNoteForm.getSickNoteType()).isEqualTo(type);
        assertThat(sickNoteForm.getStartDate()).isEqualTo(day2019_04_16);
        assertThat(sickNoteForm.getEndDate()).isEqualTo(day2019_04_16);
        assertThat(sickNoteForm.getDayLength()).isEqualTo(dayLength);
        assertThat(sickNoteForm.getAubStartDate()).isEqualTo(day2019_04_16);
        assertThat(sickNoteForm.getAubEndDate()).isEqualTo(day2019_04_16);
    }

    @Test
    public void verifyToString() {
        String stringRepresentation = "SickNoteForm{" +
            "id=1, " +
            "person=Person[id=<null>," +
                "loginName=<null>," +
                "lastName=<null>," +
                "firstName=<null>," +
                "email=<null>," +
                "permissions=[]" +
            "], " +
            "sickNoteType=SickNoteType[category=<null>," +
                "messageKey=<null>,id=<null>" +
            "], " +
            "startDate=2019-04-16, " +
            "endDate=2019-04-16, " +
            "dayLength=FULL, " +
            "aubStartDate=2019-04-16, " +
            "aubEndDate=2019-04-16, " +
            "comment='my comment'" +
        "}";

        assertThat(sut.toString()).isEqualTo(stringRepresentation);
    }
}

@@ -2555,818 +2555,7 @@
    %7D
-%0A%0A    @Test%0A    public void verifyToString() %7B%0A        String stringRepresentation = %22SickNoteForm%7B%22 +%0A            %22id=1, %22 +%0A            %22person=Person%5Bid=%3Cnull%3E,%22 +%0A                %22loginName=%3Cnull%3E,%22 +%0A                %22lastName=%3Cnull%3E,%22 +%0A                %22firstName=%3Cnull%3E,%22 +%0A                %22email=%3Cnull%3E,%22 +%0A                %22permissions=%5B%5D%22 +%0A            %22%5D, %22 +%0A            %22sickNoteType=SickNoteType%5Bcategory=%3Cnull%3E,%22 +%0A                %22messageKey=%3Cnull%3E,id=%3Cnull%3E%22 +%0A            %22%5D, %22 +%0A            %22startDate=2019-04-16, %22 +%0A            %22endDate=2019-04-16, %22 +%0A            %22dayLength=FULL, %22 +%0A            %22aubStartDate=2019-04-16, %22 +%0A            %22aubEndDate=2019-04-16, %22 +%0A            %22comment='my comment'%22 +%0A        %22%7D%22;%0A%0A        assertThat(sut.toString()).isEqualTo(stringRepresentation);%0A    %7D
 %0A%7D%0A

remove unit test for tostring method