Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.scs.core.domain; |
| 2 | |||
| 3 | import org.jmock.Expectations; |
||
| 4 | import org.jmock.Mockery; |
||
| 5 | import org.jmock.integration.junit4.JMock; |
||
| 6 | import org.jmock.integration.junit4.JUnit4Mockery; |
||
| 7 | import org.junit.Before; |
||
| 8 | import org.junit.Test; |
||
| 9 | import org.junit.runner.RunWith; |
||
| 10 | |||
| 11 | import br.gov.al.saude.scs.core.domain.municipio.MunicipioService; |
||
| 12 | import br.gov.al.saude.scs.core.domain.municipio.impl.MunicipioServiceImpl; |
||
| 13 | import br.gov.al.saude.scs.core.infrastructure.persistence.jpa.municipio.MunicipioRepository; |
||
| 14 | |||
| 15 | @RunWith(JMock.class) |
||
| 16 | public class MunicipioServiceImplTest{ |
||
| 17 | |||
| 18 | private MunicipioService municipioService; |
||
| 19 | private MunicipioRepository municipioRepositoryMock; |
||
| 20 | private Mockery contexto; |
||
| 21 | |||
| 22 | @Before |
||
| 23 | public void inicializarContexto() { |
||
| 24 | contexto = new JUnit4Mockery(); |
||
| 25 | municipioRepositoryMock = getContexto().mock(MunicipioRepository.class); |
||
| 26 | municipioService = new MunicipioServiceImpl(municipioRepositoryMock); |
||
| 27 | } |
||
| 28 | |||
| 29 | @Test |
||
| 30 | public void aoListarMunicipiosInformandoCodidoUfDeveriaDelegarParaOhRepositorio(){ |
||
| 31 | getContexto().checking(new Expectations(){{ |
||
| 32 | oneOf(municipioRepositoryMock).listar(with(any(String.class))); |
||
| 33 | }}); |
||
| 34 | municipioService.listar(new String("AL")); |
||
| 35 | } |
||
| 36 | |||
| 37 | @Test |
||
| 38 | public void aoListarMunicipiosInformandoCodidoUfNuloDeveriaNaoDelegarParaOhRepositorio(){ |
||
| 39 | getContexto().checking(new Expectations(){{ |
||
| 40 | never(municipioRepositoryMock).listar(with(any(String.class))); |
||
| 41 | }}); |
||
| 42 | municipioService.listar(null); |
||
| 43 | } |
||
| 44 | |||
| 45 | @Test |
||
| 46 | public void aoListarMunicipiosInformandoCodidoUfVazioDeveriaNaoDelegarParaOhRepositorio(){ |
||
| 47 | getContexto().checking(new Expectations(){{ |
||
| 48 | never(municipioRepositoryMock).listar(with(any(String.class))); |
||
| 49 | }}); |
||
| 50 | municipioService.listar(new String()); |
||
| 51 | } |
||
| 52 | |||
| 53 | public Mockery getContexto() { |
||
| 54 | return contexto; |
||
| 55 | } |
||
| 56 | |||
| 57 | |||
| 58 | } |