Subversion Repositories Integrator Subversion

Rev

Blame | Last modification | View Log | Download | RSS feed

package br.gov.al.saude.scs.core.domain;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import br.gov.al.saude.scs.core.domain.municipio.MunicipioService;
import br.gov.al.saude.scs.core.domain.municipio.impl.MunicipioServiceImpl;
import br.gov.al.saude.scs.core.infrastructure.persistence.jpa.municipio.MunicipioRepository;

@RunWith(JMock.class)
public class MunicipioServiceImplTest{

        private MunicipioService municipioService;
        private MunicipioRepository municipioRepositoryMock;
        private Mockery contexto;
       
        @Before
        public void inicializarContexto() {
                contexto = new JUnit4Mockery();
                municipioRepositoryMock = getContexto().mock(MunicipioRepository.class);
                municipioService = new MunicipioServiceImpl(municipioRepositoryMock);
        }
       
        @Test
        public void aoListarMunicipiosInformandoCodidoUfDeveriaDelegarParaOhRepositorio(){
                getContexto().checking(new Expectations(){{
                        oneOf(municipioRepositoryMock).listar(with(any(String.class)));
                }});
                municipioService.listar(new String("AL"));
        }
       
        @Test
        public void aoListarMunicipiosInformandoCodidoUfNuloDeveriaNaoDelegarParaOhRepositorio(){
                getContexto().checking(new Expectations(){{
                        never(municipioRepositoryMock).listar(with(any(String.class)));
                }});
                municipioService.listar(null);
        }
       
        @Test
        public void aoListarMunicipiosInformandoCodidoUfVazioDeveriaNaoDelegarParaOhRepositorio(){
                getContexto().checking(new Expectations(){{
                        never(municipioRepositoryMock).listar(with(any(String.class)));
                }});
                municipioService.listar(new String());
        }
       
        public Mockery getContexto() {
                return contexto;
        }
       
       
}