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.unidade.UnidadeService; |
||
| 12 | import br.gov.al.saude.scs.core.domain.unidade.impl.UnidadeServiceImpl; |
||
| 13 | import br.gov.al.saude.scs.core.infrastructure.persistence.jpa.unidade.UnidadeRepository; |
||
| 14 | |||
| 15 | @RunWith(JMock.class) |
||
| 16 | public class UnidadeServiceImplTest{ |
||
| 17 | |||
| 18 | private UnidadeRepository unidadeRepositoryMock; |
||
| 19 | private UnidadeService unidadeService; |
||
| 20 | private Mockery contexto; |
||
| 21 | |||
| 22 | @Before |
||
| 23 | public void inicializarContexto() { |
||
| 24 | contexto = new JUnit4Mockery(); |
||
| 25 | unidadeRepositoryMock = getContexto().mock(UnidadeRepository.class); |
||
| 26 | unidadeService = new UnidadeServiceImpl(unidadeRepositoryMock); |
||
| 27 | } |
||
| 28 | |||
| 29 | @Test |
||
| 30 | public void aoListarUnidadesDeveriaDelegarParaOhRepositorio(){ |
||
| 31 | getContexto().checking(new Expectations(){{ |
||
| 32 | oneOf(unidadeRepositoryMock).listar(); |
||
| 33 | }}); |
||
| 34 | unidadeService.listar(); |
||
| 35 | } |
||
| 36 | |||
| 37 | public Mockery getContexto() { |
||
| 38 | return contexto; |
||
| 39 | } |
||
| 40 | |||
| 41 | |||
| 42 | } |