Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.scs.core.application; |
| 2 | |||
| 3 | import java.util.ArrayList; |
||
| 4 | import java.util.List; |
||
| 5 | |||
| 6 | import org.jmock.Expectations; |
||
| 7 | import org.jmock.integration.junit4.JMock; |
||
| 8 | import org.junit.Before; |
||
| 9 | import org.junit.Test; |
||
| 10 | import org.junit.runner.RunWith; |
||
| 11 | |||
| 12 | import br.gov.al.saude.framework.core.generic.GenericFacade; |
||
| 13 | import br.gov.al.saude.framework.core.generic.GenericService; |
||
| 14 | import br.gov.al.saude.sca.model.usuario.view.UsuarioView; |
||
| 15 | import br.gov.al.saude.scg.model.view.PessoaFisicaView; |
||
| 16 | import br.gov.al.saude.scs.core.application.turma.TurmaFacade; |
||
| 17 | import br.gov.al.saude.scs.core.application.turma.impl.TurmaFacadeImpl; |
||
| 18 | import br.gov.al.saude.scs.core.domain.turma.TurmaService; |
||
| 19 | import br.gov.al.saude.scs.model.Capacitacao; |
||
| 20 | import br.gov.al.saude.scs.model.Turma; |
||
| 21 | import br.gov.al.saude.scs.model.TurmaParticipante; |
||
| 22 | import br.gov.al.saude.scs.model.dto.ConsultaTurmaDTO; |
||
| 23 | import br.gov.al.saude.scs.parametros.ParametrosConsultarDespesasTurma; |
||
| 24 | import br.gov.al.saude.scs.parametros.ParametrosConsultarTurma; |
||
| 25 | import br.gov.al.saude.test.unidade.generic.facade.FacadeImplTest; |
||
| 26 | |||
| 27 | @RunWith(JMock.class) |
||
| 28 | public class TurmaFacadeImplTest extends FacadeImplTest<Turma> { |
||
| 29 | |||
| 30 | private TurmaFacade turmaFacade; |
||
| 31 | private TurmaService turmaServiceMock; |
||
| 32 | |||
| 33 | @Before |
||
| 34 | public void inicializarContexto() { |
||
| 35 | super.inicializarContexto(); |
||
| 36 | turmaServiceMock = getContexto().mock(TurmaService.class); |
||
| 37 | turmaFacade = new TurmaFacadeImpl(turmaServiceMock); |
||
| 38 | } |
||
| 39 | |||
| 40 | @Override |
||
| 41 | protected GenericFacade<Turma> getFacade() { |
||
| 42 | return turmaFacade; |
||
| 43 | } |
||
| 44 | |||
| 45 | @Override |
||
| 46 | protected GenericService<Turma> getServiceMock() { |
||
| 47 | return turmaServiceMock; |
||
| 48 | } |
||
| 49 | |||
| 50 | @Test |
||
| 51 | public void aoConsultarTurmaDeveriaDelegarParaOhService() throws Exception { |
||
| 52 | getContexto().checking(new Expectations(){{ |
||
| 53 | oneOf(turmaServiceMock).consultarTurma(with(any(Integer.class)), with(any(Integer.class)), with(any(ConsultaTurmaDTO.class))); |
||
| 54 | will(returnValue(with(any(List.class)))); |
||
| 55 | }}); |
||
| 56 | turmaFacade.consultarTurma(1, 5, new ConsultaTurmaDTO(new Capacitacao(), new Turma(), 2013)); |
||
| 57 | } |
||
| 58 | |||
| 59 | @Test |
||
| 60 | public void aoDetalharTurmaDeveriaDelegarParaOhService() throws Exception { |
||
| 61 | getContexto().checking(new Expectations(){{ |
||
| 62 | oneOf(turmaServiceMock).detalharTurma(with(any(Long.class))); |
||
| 63 | will(returnValue(with(any(Turma.class)))); |
||
| 64 | }}); |
||
| 65 | turmaFacade.detalharTurma(1l); |
||
| 66 | } |
||
| 67 | |||
| 68 | @Test |
||
| 69 | public void aoConsultarPessoaDeveriaDelegarParaOhService() throws Exception { |
||
| 70 | getContexto().checking(new Expectations(){{ |
||
| 71 | oneOf(turmaServiceMock).consultarPessoa(with(any(Long.class))); |
||
| 72 | will(returnValue(with(any(PessoaFisicaView.class)))); |
||
| 73 | }}); |
||
| 74 | turmaFacade.consultarPessoa(1l); |
||
| 75 | } |
||
| 76 | |||
| 77 | @Test |
||
| 78 | public void aoConsultarTurmaDtoDeveriaDelegarParaOhService(){ |
||
| 79 | getContexto().checking(new Expectations(){{ |
||
| 80 | oneOf(turmaServiceMock).consultarTurmaDTO(with(any(ParametrosConsultarTurma.class))); |
||
| 81 | }}); |
||
| 82 | turmaFacade.consultarTurmaDTO(new ParametrosConsultarTurma()); |
||
| 83 | } |
||
| 84 | |||
| 85 | @Test |
||
| 86 | public void aoObterQuantidadeRegistrosConsultarTurmaDtoDeveriaDelegarParaOhService(){ |
||
| 87 | getContexto().checking(new Expectations(){{ |
||
| 88 | oneOf(turmaServiceMock).obterQuantidadeRegistrosConsultarTurmaDTO(with(any(ParametrosConsultarTurma.class))); |
||
| 89 | }}); |
||
| 90 | turmaFacade.obterQuantidadeRegistrosConsultarTurmaDTO(new ParametrosConsultarTurma()); |
||
| 91 | } |
||
| 92 | |||
| 93 | @Test |
||
| 94 | public void aoObterQuantidadeDeRegistrosConsultarTurmaDeveriaDelegarParaOhService(){ |
||
| 95 | getContexto().checking(new Expectations(){{ |
||
| 96 | oneOf(turmaServiceMock).obterQuantidadeDeRegistrosConsultarTurma(with(any(ConsultaTurmaDTO.class))); |
||
| 97 | }}); |
||
| 98 | turmaFacade.obterQuantidadeDeRegistrosConsultarTurma(new ConsultaTurmaDTO()); |
||
| 99 | } |
||
| 100 | |||
| 101 | @Test |
||
| 102 | public void aoListarOrgaoDeveriaDelegarParaOhService() throws Exception { |
||
| 103 | getContexto().checking(new Expectations(){{ |
||
| 104 | oneOf(turmaServiceMock).listarOrgaos(); |
||
| 105 | will(returnValue(with(any(List.class)))); |
||
| 106 | }}); |
||
| 107 | turmaFacade.listarOrgaos(); |
||
| 108 | } |
||
| 109 | |||
| 110 | @Test |
||
| 111 | public void aoVerificarAlertasDoParticipanteDeveriaDelegarParaOhService() throws Exception { |
||
| 112 | getContexto().checking(new Expectations(){{ |
||
| 113 | oneOf(turmaServiceMock).verificarAlertasDoParticipante(with(any(Long.class))); |
||
| 114 | will(returnValue(with(any(String.class)))); |
||
| 115 | }}); |
||
| 116 | turmaFacade.verificarAlertasDoParticipante(1l); |
||
| 117 | } |
||
| 118 | |||
| 119 | @Test |
||
| 120 | public void aoVerificarRestricoesDoParticipanteDeveriaDelegarParaOhService() throws Exception { |
||
| 121 | getContexto().checking(new Expectations(){{ |
||
| 122 | oneOf(turmaServiceMock).verificarFaltasDoParticipante(with(any(UsuarioView.class)), with(any(TurmaParticipante.class))); |
||
| 123 | will(returnValue(with(any(String.class)))); |
||
| 124 | }}); |
||
| 125 | turmaFacade.verificarFaltasDoParticipante(new UsuarioView(), new TurmaParticipante()); |
||
| 126 | } |
||
| 127 | |||
| 128 | @Test |
||
| 129 | public void aoConsultarTurmaComParticipantesDeveriaDelegarParaOhService() throws Exception { |
||
| 130 | getContexto().checking(new Expectations(){{ |
||
| 131 | oneOf(turmaServiceMock).consultarTurmaComParticipantes(with(any(Long.class))); |
||
| 132 | will(returnValue(with(any(Turma.class)))); |
||
| 133 | }}); |
||
| 134 | turmaFacade.consultarTurmaComParticipantes(1l); |
||
| 135 | } |
||
| 136 | |||
| 137 | @Test |
||
| 138 | public void aoConsultarDespesasTurmaDeveriaDelegarParaOhService() throws Exception { |
||
| 139 | getContexto().checking(new Expectations(){{ |
||
| 140 | oneOf(turmaServiceMock).consultarDespesasTurma(with(any(ParametrosConsultarDespesasTurma.class))); |
||
| 141 | }}); |
||
| 142 | turmaFacade.consultarDespesasTurma(new ParametrosConsultarDespesasTurma()); |
||
| 143 | } |
||
| 144 | |||
| 145 | @Test |
||
| 146 | public void aoConsultarIndicadorDeServidorDeveriaDelegarParaOhService() throws Exception { |
||
| 147 | getContexto().checking(new Expectations(){{ |
||
| 148 | oneOf(turmaServiceMock).consultarIndicadorDeServidor(with(any(PessoaFisicaView.class))); |
||
| 149 | }}); |
||
| 150 | turmaFacade.consultarIndicadorDeServidor(new PessoaFisicaView()); |
||
| 151 | } |
||
| 152 | |||
| 153 | @Test |
||
| 154 | @SuppressWarnings("unchecked") |
||
| 155 | public void aoVerificarAlertaDeRestricaoDoParticipanteDeveriaDelegarParaOhService() throws Exception { |
||
| 156 | getContexto().checking(new Expectations(){{ |
||
| 157 | oneOf(turmaServiceMock).verificarAlertaDeRestricaoDoParticipante(with(any(TurmaParticipante.class)), with(any(List.class))); |
||
| 158 | }}); |
||
| 159 | turmaFacade.verificarAlertaDeRestricaoDoParticipante(new TurmaParticipante(), new ArrayList<TurmaParticipante>()); |
||
| 160 | } |
||
| 161 | } |