package br.gov.servicos.editor.frontend;

import org.junit.Before;
import org.junit.Test;
import org.springframework.security.core.userdetails.User;

import static java.util.Collections.emptyList;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class ApiControllerTest {

    private ApiController controller;

    public static final User USUARIO = new User("Fulano de Tal", "", emptyList());

    @Before
    public void setUp() throws Exception {
        controller = new ApiController();
    }

    @Test
    public void pingDeveRetornarLoginEHorario() throws Exception {
        ApiController.Ping ping = controller.ping(USUARIO);

        assertThat(ping.getLogin(), is("Fulano de Tal"));
        assertThat(System.currentTimeMillis() - ping.getHorario(), is(lessThan(1000L)));
    }
}
@@ -79,24 +79,129 @@
 junit.Test;%0A
+import org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0A
 import org.s
@@ -423,16 +423,93 @@
 rtThat;%0A
+import static org.mockito.Mockito.verify;%0A%0A@RunWith(MockitoJUnitRunner.class)
 %0Apublic 
@@ -539,47 +539,8 @@
  %7B%0A%0A
-    private ApiController controller;%0A%0A
     
@@ -615,24 +615,111 @@
 tyList());%0A%0A
+    @Mock%0A    VCGE vcge;%0A%0A    @Mock%0A    Orgaos orgaos;%0A%0A    ApiController controller;%0A%0A
     @Before%0A
@@ -800,16 +800,28 @@
 troller(
+vcge, orgaos
 );%0A    %7D
@@ -1112,10 +1112,288 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void listaOrgaosDisponiveis() throws Exception %7B%0A        controller.orgaos();%0A        verify(orgaos).get();%0A    %7D%0A%0A    @Test%0A    public void listaCategoriasDoVcgeDisponiveis() throws Exception %7B%0A        controller.vcge();%0A        verify(vcge).get();%0A    %7D
 %0A%7D

Corrige testes