Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.srv.core.application; |
| 2 | |||
| 3 | import java.util.ArrayList; |
||
| 4 | |||
| 5 | import org.jmock.Expectations; |
||
| 6 | import org.junit.Before; |
||
| 7 | import org.junit.Test; |
||
| 8 | |||
| 9 | import br.gov.al.saude.framework.core.generic.GenericFacade; |
||
| 10 | import br.gov.al.saude.framework.core.generic.GenericService; |
||
| 11 | import br.gov.al.saude.srv.core.application.cargo.CargoFacade; |
||
| 12 | import br.gov.al.saude.srv.core.application.cargo.impl.CargoFacadeImpl; |
||
| 13 | import br.gov.al.saude.srv.core.domain.cargo.CargoService; |
||
| 14 | import br.gov.al.saude.srv.model.Cargo; |
||
| 15 | import br.gov.al.saude.srv.model.dto.CargoDTO; |
||
| 16 | import br.gov.al.saude.srv.model.dto.ParametroConsultaCargoDTO; |
||
| 17 | import br.gov.al.saude.test.unidade.generic.facade.FacadeImplTest; |
||
| 18 | |||
| 19 | public class CargoFacadeImplTest extends FacadeImplTest<Cargo> { |
||
| 20 | |||
| 21 | private CargoFacade cargoFacade; |
||
| 22 | private CargoService cargoServiceMock; |
||
| 23 | |||
| 24 | @Before |
||
| 25 | public void inicializarContexto() { |
||
| 26 | super.inicializarContexto(); |
||
| 27 | cargoServiceMock = getContexto().mock(CargoService.class); |
||
| 28 | cargoFacade = new CargoFacadeImpl(cargoServiceMock); |
||
| 29 | } |
||
| 30 | |||
| 31 | @Override |
||
| 32 | protected GenericFacade<Cargo> getFacade() { |
||
| 33 | return cargoFacade; |
||
| 34 | } |
||
| 35 | |||
| 36 | @Override |
||
| 37 | protected GenericService<Cargo> getServiceMock() { |
||
| 38 | return cargoServiceMock; |
||
| 39 | } |
||
| 40 | |||
| 41 | @Test |
||
| 42 | public void aoConsultarDeveriaDelegarParaOhService() throws Exception { |
||
| 43 | getContexto().checking(new Expectations(){{ |
||
| 44 | oneOf(cargoServiceMock).consultar(with(any(ParametroConsultaCargoDTO.class))); |
||
| 45 | will(returnValue(new ArrayList<Cargo>())); |
||
| 46 | }}); |
||
| 47 | |||
| 48 | ((CargoFacade) getFacade()).consultar(new ParametroConsultaCargoDTO()); |
||
| 49 | } |
||
| 50 | |||
| 51 | @Test |
||
| 52 | public void aoObterQuantideRegistrosConsultarCargosAtivosDeveriaDelegarParaOhService() throws Exception { |
||
| 53 | getContexto().checking(new Expectations(){{ |
||
| 54 | oneOf(cargoServiceMock).obterQuantideRegistrosConsultarCargosAtivos(with(any(ParametroConsultaCargoDTO.class))); |
||
| 55 | }}); |
||
| 56 | |||
| 57 | cargoFacade.obterQuantideRegistrosConsultarCargosAtivos(new ParametroConsultaCargoDTO()); |
||
| 58 | } |
||
| 59 | |||
| 60 | @Test |
||
| 61 | public void aoConsultarCargosAtivosDeveriaDelegarParaOhService() throws Exception { |
||
| 62 | getContexto().checking(new Expectations(){{ |
||
| 63 | oneOf(cargoServiceMock).consultarCargosAtivos(with(any(ParametroConsultaCargoDTO.class))); |
||
| 64 | will(returnValue(new ArrayList<CargoDTO>())); |
||
| 65 | }}); |
||
| 66 | |||
| 67 | cargoFacade.consultarCargosAtivos(new ParametroConsultaCargoDTO()); |
||
| 68 | } |
||
| 69 | |||
| 70 | @Test |
||
| 71 | public void aoObterQuantidadeRegistrosDeveriaDelegarParaOhService() throws Exception { |
||
| 72 | getContexto().checking(new Expectations(){{ |
||
| 73 | oneOf(cargoServiceMock).obterQuantidadeDeRegistros(with(any(ParametroConsultaCargoDTO.class))); |
||
| 74 | }}); |
||
| 75 | |||
| 76 | cargoFacade.obterQuantidadeDeRegistros(new ParametroConsultaCargoDTO()); |
||
| 77 | } |
||
| 78 | |||
| 79 | } |