diff --git a/pom.xml b/pom.xml
index 39068fb8c..b48e0c990 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,6 +38,11 @@
provided
+
+ commons-httpclient
+ commons-httpclient
+ 3.1
+
org.postgresql
postgresql
@@ -69,6 +74,7 @@
0.8.3
+ jacoco-initialize
prepare-agent
diff --git a/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java b/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java
new file mode 100644
index 000000000..45c2b02ee
--- /dev/null
+++ b/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java
@@ -0,0 +1,81 @@
+package br.ce.wcaquino.taskbackend.controller;
+
+import java.time.LocalDate;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+import br.ce.wcaquino.taskbackend.model.Task;
+import br.ce.wcaquino.taskbackend.repo.TaskRepo;
+import br.ce.wcaquino.taskbackend.utils.ValidationException;
+
+public class TaskControllerTest {
+
+ @Mock
+ private TaskRepo taskRepo;
+
+
+ @InjectMocks
+ private TaskController controller;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void naoDeveSalvarTarefasSemDescricao() {
+ Task todo = new Task();
+ //todo.setTask("Descricao");
+ todo.setDueDate(LocalDate.now());
+
+ try {
+ controller.save(todo);
+ } catch (ValidationException e) {
+ Assert.assertEquals("Fill the task description", e.getMessage());
+ }
+ }
+
+ @Test
+ public void naoDeveSalvarTarefasSemData() {
+ Task todo = new Task();
+ todo.setTask("Descricao");
+ //todo.setDueDate(LocalDate.now());
+
+ try {
+ controller.save(todo);
+ } catch (ValidationException e) {
+ Assert.assertEquals("Fill the due date", e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void naoDeveSalvarTarefascomDataPassada() {
+ Task todo = new Task();
+ todo.setTask("Descricao");
+ todo.setDueDate(LocalDate.of(2010,01,01));
+
+ try {
+ controller.save(todo);
+ } catch (ValidationException e) {
+ Assert.assertEquals("Due date must not be in past", e.getMessage());
+ }
+
+ }
+ @Test
+ public void deveSalvarTarefasComSucesso() throws ValidationException {
+ Task todo = new Task();
+ todo.setTask("Descricao");
+ todo.setDueDate(LocalDate.now());
+ controller.save(todo);
+ Mockito.verify(taskRepo).save(todo);
+
+ }
+
+}
diff --git a/src/test/java/br/ce/wcaquino/taskbackend/utils/DateUtilsTest.java b/src/test/java/br/ce/wcaquino/taskbackend/utils/DateUtilsTest.java
new file mode 100644
index 000000000..a5df345b5
--- /dev/null
+++ b/src/test/java/br/ce/wcaquino/taskbackend/utils/DateUtilsTest.java
@@ -0,0 +1,32 @@
+package br.ce.wcaquino.taskbackend.utils;
+
+import java.time.LocalDate;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DateUtilsTest {
+
+
+ @Test
+ public void deveRetornarTrueParaDatasFuturas() {
+ LocalDate date = LocalDate.of(2030, 01, 01);
+ Assert.assertTrue(DateUtils.isEqualOrFutureDate(date));
+
+ }
+
+ @Test
+ public void deveRetornarFalseParaDatasPassadas() {
+ LocalDate date = LocalDate.of(2010, 01, 01);
+ Assert.assertFalse(DateUtils.isEqualOrFutureDate(date));
+
+ }
+
+ @Test
+ public void deveRetornarTrueParaDatasAtual() {
+ LocalDate date = LocalDate.now();
+ Assert.assertTrue(DateUtils.isEqualOrFutureDate(date));
+
+ }
+
+}