package fi.github.marsojm.runnersnotes.core.entities;

import org.junit.Test;

import java.util.Date;
import java.util.List;

import static org.junit.Assert.*;

/**
 * Created by Marko on 3.9.2015.
 */
public class NoteTest {


    @Test
    public  void testCreateNote() throws Exception {
        Note n = new Note(new Date(), 20, 20, "");
    }

    @Test
    public void testValidate() throws Exception {
        Note n = new Note(new Date(), 20, 20, "");
        List<String> errors = n.validate();
        assertEquals(0, errors.size());
    }

    @Test
    public void testValidateWithTwoErrors() throws Exception {
        Note n = new Note(new Date(), -1, -1, "");
        List<String> errors = n.validate();
        assertEquals(2, errors.size());
    }


    @Test
    public void testValidateNegativeDistance() throws Exception {
        Note n = new Note(new Date(), -1, 20, "");
        List<String> errors = n.validate();
        assertEquals(1, errors.size());
        assertEquals("Distance must be greater than zero!", errors.get(0));
    }

    @Test
    public void testValidateNegativeDuration() throws Exception {
        Note n = new Note(new Date(), 1, -1, "");
        List<String> errors = n.validate();
        assertEquals(1, errors.size());
        assertEquals("Duration must be greater than zero!", errors.get(0));
    }

}
@@ -1347,9 +1347,273 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testValidateWithNullDate() throws Exception %7B%0A        Note n = new Note(null, 1, 1, %22%22);%0A        List%3CString%3E errors = n.validate();%0A        assertEquals(1, errors.size());%0A        assertEquals(%22Invalid date!%22, errors.get(0));%0A    %7D%0A    %0A
 %7D

Add test for null date