@@ -0,0 +1,2749 @@
+package br.usp.ime.academicdevoir.controller;%0A%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.spy;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport br.com.caelum.vraptor.util.test.JSR303MockValidator;%0Aimport br.com.caelum.vraptor.util.test.MockResult;%0Aimport br.usp.ime.academicdevoir.dao.QuestaoDeCodigoDao;%0Aimport br.usp.ime.academicdevoir.dao.TagDao;%0Aimport br.usp.ime.academicdevoir.entidade.Professor;%0Aimport br.usp.ime.academicdevoir.entidade.QuestaoDeCodigo;%0Aimport br.usp.ime.academicdevoir.entidade.Tag;%0Aimport br.usp.ime.academicdevoir.infra.Privilegio;%0Aimport br.usp.ime.academicdevoir.infra.UsuarioSession;%0A%0Apublic class QuestoesDeCodigoControllerTeste %7B%0A%0A    private QuestoesDeCodigoController questoesC;%0A    private QuestaoDeCodigoDao dao;%0A%0A    private MockResult result;%0A%0A    private JSR303MockValidator validator;%0A%0A    private UsuarioSession usuarioSession;%0A    private TagDao tagDao;%0A%0A    @Before%0A    public void SetUp() %7B       %0A        Professor professor = new Professor();%0A        professor.setPrivilegio(Privilegio.ADMINISTRADOR);%0A        %0A        usuarioSession = new UsuarioSession();%0A        usuarioSession.setUsuario(professor);%0A    %0A        dao = mock(QuestaoDeCodigoDao.class);%0A        tagDao = mock(TagDao.class);%0A        result = spy(new MockResult());%0A        validator = spy(new JSR303MockValidator());%0A        questoesC = new QuestoesDeCodigoController(dao, tagDao, result,%0A                validator, usuarioSession);%0A        %0A        when(tagDao.buscaPeloNome(any(String.class))).thenReturn(new Tag(%22tagQualquer%22));%0A    %7D%0A%0A    @Test%0A    public void testeAdiciona() %7B%0A        QuestaoDeCodigo questao = new QuestaoDeCodigo();%0A        questoesC.cadastra(questao, new String(%22tagQualquer%22));%0A    %0A        verify(validator).validate(questao);%0A        verify(validator).onErrorUsePageOf(QuestoesController.class);%0A        verify(dao).salva(questao);%0A        verify(result).redirectTo(questoesC);%0A    %7D%0A%0A    @Test%0A    public void testeAtualiza() %7B%0A        QuestaoDeCodigo questao = new QuestaoDeCodigo();%0A        questoesC.altera(questao, new String(%22tagQualquer%22));%0A        %0A        verify(validator).validate(questao);%0A        verify(validator).onErrorUsePageOf(QuestoesDeCodigoController.class);%0A        verify(dao).atualiza(questao);%0A        verify(result).redirectTo(questoesC);%0A    %7D%0A    %0A    @Test%0A    public void testeRemove() %7B%0A        QuestaoDeCodigo temp = new QuestaoDeCodigo();%0A        when(dao.carrega(0L)).thenReturn(temp);%0A        questoesC.remove(0L);%0A        %0A        verify(dao).remove(temp);%0A        verify(result).redirectTo(questoesC);%0A    %7D%0A%7D

Teste do controller de questoes de codigo