Subversion Repositories Integrator Subversion

Rev

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

package br.gov.al.saude.srv.core.application;

import java.util.ArrayList;

import org.jmock.Expectations;
import org.junit.Before;
import org.junit.Test;

import br.gov.al.saude.framework.core.generic.GenericFacade;
import br.gov.al.saude.framework.core.generic.GenericService;
import br.gov.al.saude.srv.core.application.cargo.CargoFacade;
import br.gov.al.saude.srv.core.application.cargo.impl.CargoFacadeImpl;
import br.gov.al.saude.srv.core.domain.cargo.CargoService;
import br.gov.al.saude.srv.model.Cargo;
import br.gov.al.saude.srv.model.dto.CargoDTO;
import br.gov.al.saude.srv.model.dto.ParametroConsultaCargoDTO;
import br.gov.al.saude.test.unidade.generic.facade.FacadeImplTest;

public class CargoFacadeImplTest extends FacadeImplTest<Cargo> {

        private CargoFacade cargoFacade;
        private CargoService cargoServiceMock;
       
        @Before
        public void inicializarContexto() {
                super.inicializarContexto();
                cargoServiceMock = getContexto().mock(CargoService.class);
                cargoFacade = new CargoFacadeImpl(cargoServiceMock);
        }
       
        @Override
        protected GenericFacade<Cargo> getFacade() {
                return cargoFacade;
        }

        @Override
        protected GenericService<Cargo> getServiceMock() {
                return cargoServiceMock;
        }
       
        @Test
        public void aoConsultarDeveriaDelegarParaOhService() throws Exception {
                getContexto().checking(new Expectations(){{
                        oneOf(cargoServiceMock).consultar(with(any(ParametroConsultaCargoDTO.class)));
                        will(returnValue(new ArrayList<Cargo>()));
                }});
               
                ((CargoFacade) getFacade()).consultar(new ParametroConsultaCargoDTO());
        }
       
        @Test
        public void aoObterQuantideRegistrosConsultarCargosAtivosDeveriaDelegarParaOhService() throws Exception {
                getContexto().checking(new Expectations(){{
                        oneOf(cargoServiceMock).obterQuantideRegistrosConsultarCargosAtivos(with(any(ParametroConsultaCargoDTO.class)));
                }});
               
                cargoFacade.obterQuantideRegistrosConsultarCargosAtivos(new ParametroConsultaCargoDTO());
        }
       
        @Test
        public void aoConsultarCargosAtivosDeveriaDelegarParaOhService() throws Exception {
                getContexto().checking(new Expectations(){{
                        oneOf(cargoServiceMock).consultarCargosAtivos(with(any(ParametroConsultaCargoDTO.class)));
                        will(returnValue(new ArrayList<CargoDTO>()));
                }});
               
                cargoFacade.consultarCargosAtivos(new ParametroConsultaCargoDTO());
        }
       
        @Test
        public void aoObterQuantidadeRegistrosDeveriaDelegarParaOhService() throws Exception {
                getContexto().checking(new Expectations(){{
                        oneOf(cargoServiceMock).obterQuantidadeDeRegistros(with(any(ParametroConsultaCargoDTO.class)));
                }});
               
                cargoFacade.obterQuantidadeDeRegistros(new ParametroConsultaCargoDTO());
        }

}