Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.rhd.core.domain; |
| 2 | |||
| 3 | import static br.gov.al.saude.test.ConstantesTestHelper.CronogramaConstantes.ANO_2012; |
||
| 4 | import static br.gov.al.saude.test.ConstantesTestHelper.CronogramaEtapaConstantes.DATA_FINAL_01_06_2013; |
||
| 5 | import static br.gov.al.saude.test.ConstantesTestHelper.CronogramaEtapaConstantes.DATA_INICIAL_01_01_2013; |
||
| 6 | import static br.gov.al.saude.test.ConstantesTestHelper.CronogramaEtapaConstantes.DATA_INICIAL_01_03_2013; |
||
| 7 | import static br.gov.al.saude.test.ConstantesTestHelper.EtapaConstantes.SEQUENCIAL_ETAPA_1; |
||
| 8 | import static br.gov.al.saude.test.ConstantesTestHelper.EtapaConstantes.SEQUENCIAL_ETAPA_3; |
||
| 9 | |||
| 10 | import java.util.ArrayList; |
||
| 11 | import java.util.HashSet; |
||
| 12 | |||
| 13 | import org.jmock.Expectations; |
||
| 14 | import org.jmock.integration.junit4.JMock; |
||
| 15 | import org.junit.Before; |
||
| 16 | import org.junit.Test; |
||
| 17 | import org.junit.runner.RunWith; |
||
| 18 | |||
| 19 | import br.gov.al.saude.framework.core.exception.NegocioException; |
||
| 20 | import br.gov.al.saude.framework.core.generic.GenericRepository; |
||
| 21 | import br.gov.al.saude.framework.core.generic.GenericService; |
||
| 22 | import br.gov.al.saude.framework.core.interfaces.Alterar; |
||
| 23 | import br.gov.al.saude.framework.core.interfaces.Cadastrar; |
||
| 24 | import br.gov.al.saude.framework.core.util.DataUtils; |
||
| 25 | import br.gov.al.saude.framework.core.validador.Validador; |
||
| 26 | import br.gov.al.saude.rhd.core.domain.cronograma.CronogramaService; |
||
| 27 | import br.gov.al.saude.rhd.core.domain.cronograma.impl.CronogramaServiceImpl; |
||
| 28 | import br.gov.al.saude.rhd.core.infrastructure.persistence.jpa.CronogramaRepository; |
||
| 29 | import br.gov.al.saude.rhd.model.Cronograma; |
||
| 30 | import br.gov.al.saude.rhd.model.CronogramaEtapa; |
||
| 31 | import br.gov.al.saude.rhd.model.Etapa; |
||
| 32 | import br.gov.al.saude.rhd.model.dto.PeriodoDTO; |
||
| 33 | import br.gov.al.saude.sca.model.usuario.view.UsuarioView; |
||
| 34 | import br.gov.al.saude.test.builder.CronogramaBuilder; |
||
| 35 | import br.gov.al.saude.test.builder.CronogramaEtapaBuilder; |
||
| 36 | import br.gov.al.saude.test.builder.EtapaBuilder; |
||
| 37 | import br.gov.al.saude.test.unidade.generic.service.ServiceImplTest; |
||
| 38 | import br.gov.al.saude.test.util.CommandSemMensagem; |
||
| 39 | import br.gov.al.saude.test.util.VerificadorLancamentoException; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @author Anderson Gomes |
||
| 43 | * @since 10/05/2013 |
||
| 44 | */ |
||
| 45 | @RunWith(JMock.class) |
||
| 46 | public class CronogramaServiceImplTest extends ServiceImplTest<Cronograma> { |
||
| 47 | |||
| 48 | private static final String MENSAGEM_O_CRONOGRAMA_INFORMADO_JA_EXISTE = "O cronograma informado já existe."; |
||
| 49 | private static final String MENSAGEM_UM_CRONOGRAMA_DEVERA_TER_NO_MINIMO_UMA_ETAPA_VINCULADA = "Um cronograma deverá ter, no mínimo, uma etapa vinculada."; |
||
| 50 | private static final String MENSAGEM_A_DATA_INICIAL_NAO_PODE_SER_POSTERIOR_A_DATA_FINAL = "A data inicial não pode ser posterior a data final."; |
||
| 51 | private static final String MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_FINAL_DA_ETAPA = "Obrigatório informar a data final da etapa"; |
||
| 52 | private static final String MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_INICIAL_DA_ETAPA = "Obrigatório informar a data inicial da etapa"; |
||
| 53 | private static final String MENSAGEM_OBRIGATORIO_INFORMAR_O_ANO = "Obrigatório informar o ano"; |
||
| 54 | private static final String MENSAGEM_ETAPA_JA_VINCULADA_AO_CRONOGRAMA = "A etapa já está vinculada ao cronograma."; |
||
| 55 | private static final String MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO = "Já existe um cronograma vigente no período informado."; |
||
| 56 | |||
| 57 | private static final String DATA_INICIO_02_01_2013 = "02/01/2013"; |
||
| 58 | private static final String DATA_INICIO_19_01_2013 = "19/01/2013"; |
||
| 59 | private static final String DATA_INICIO_20_01_2013 = "20/01/2013"; |
||
| 60 | private static final String DATA_INICIO_21_01_2013 = "21/01/2013"; |
||
| 61 | private static final String DATA_FINAL_20_01_2013 = "20/01/2013"; |
||
| 62 | private static final String DATA_FINAL_21_01_2013 = "21/01/2013"; |
||
| 63 | private static final String DATA_FINAL_26_02_2013 = "26/02/2013"; |
||
| 64 | |||
| 65 | private CronogramaService cronogramaService; |
||
| 66 | private CronogramaRepository cronogramaRepositoryMock; |
||
| 67 | private Cronograma cronograma; |
||
| 68 | private Etapa etapa; |
||
| 69 | private CronogramaEtapa cronogramaEtapa; |
||
| 70 | |||
| 71 | @Before |
||
| 72 | public void inicializarContexto() { |
||
| 73 | super.inicializarContexto(); |
||
| 74 | cronogramaRepositoryMock = getContexto().mock(CronogramaRepository.class); |
||
| 75 | validadorMock = getContexto().mock(Validador.class); |
||
| 76 | cronogramaService = new CronogramaServiceImpl(validadorMock, cronogramaRepositoryMock); |
||
| 77 | cronograma = new CronogramaBuilder().comNumeroAno(ANO_2012).build(); |
||
| 78 | etapa = new EtapaBuilder().comCodigo(SEQUENCIAL_ETAPA_1).build(); |
||
| 79 | cronogramaEtapa = new CronogramaEtapaBuilder() |
||
| 80 | .comEtapa(etapa) |
||
| 81 | .comCronograma(cronograma) |
||
| 82 | .comDataInicialEtapa(DATA_INICIO_20_01_2013) |
||
| 83 | .comDataFinalEtapa(DATA_FINAL_21_01_2013) |
||
| 84 | .build(); |
||
| 85 | cronograma.adicionarCronogramaEtapa(cronogramaEtapa); |
||
| 86 | setEntidade(cronograma); |
||
| 87 | } |
||
| 88 | |||
| 89 | @Override |
||
| 90 | protected GenericService<Cronograma> getService() { |
||
| 91 | return cronogramaService; |
||
| 92 | } |
||
| 93 | |||
| 94 | @Override |
||
| 95 | protected GenericRepository<Cronograma> getRepositoryMock() { |
||
| 96 | return cronogramaRepositoryMock; |
||
| 97 | } |
||
| 98 | |||
| 99 | @Test |
||
| 100 | public void aoConsultarCronogramaPorNumeroAnoDeveriaDelegarParaOhRepositorio() throws Exception { |
||
| 101 | getContexto().checking(new Expectations(){{ |
||
| 102 | oneOf(cronogramaRepositoryMock).consultarCronogramaPorNumeroAno(with(new Long(ANO_2012))); |
||
| 103 | will(returnValue(new ArrayList<Cronograma>())); |
||
| 104 | }}); |
||
| 105 | |||
| 106 | cronogramaService.consultarCronogramaPorNumeroAno(new Long(ANO_2012)); |
||
| 107 | } |
||
| 108 | |||
| 109 | @Test |
||
| 110 | public void aoCadastrarCronogramaComParametroAnoNaoInformadoDeveriaLancarExcecao() throws Exception { |
||
| 111 | preencherCronogramaSemInformarOhAnoDoCronograma(); |
||
| 112 | |||
| 113 | getContexto().checking(new Expectations(){{ |
||
| 114 | oneOf(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 115 | will(throwException(new NegocioException(MENSAGEM_OBRIGATORIO_INFORMAR_O_ANO))); |
||
| 116 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 117 | }}); |
||
| 118 | |||
| 119 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 120 | @Override |
||
| 121 | public void execute() throws Exception { |
||
| 122 | cronogramaService.cadastrar(cronograma); |
||
| 123 | } |
||
| 124 | }, MENSAGEM_OBRIGATORIO_INFORMAR_O_ANO); |
||
| 125 | } |
||
| 126 | |||
| 127 | @Test |
||
| 128 | public void aoCadastrarCronogramaComParametroDataInicialDaEtapaNaoForInformadaDeveriaLancarExcecao() throws Exception { |
||
| 129 | preencherCronogramaSemInformarAhDataInicialDaEtapa(); |
||
| 130 | |||
| 131 | getContexto().checking(new Expectations(){{ |
||
| 132 | oneOf(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 133 | will(throwException(new NegocioException(MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_INICIAL_DA_ETAPA))); |
||
| 134 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 135 | }}); |
||
| 136 | |||
| 137 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 138 | @Override |
||
| 139 | public void execute() throws Exception { |
||
| 140 | cronogramaService.cadastrar(cronograma); |
||
| 141 | } |
||
| 142 | }, MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_INICIAL_DA_ETAPA); |
||
| 143 | } |
||
| 144 | |||
| 145 | @Test |
||
| 146 | public void aoCadastrarCronogramaComParametroDataFinalDaEtapaNaoForInformadaDeveriaLancarExcecao() throws Exception { |
||
| 147 | preencherCronogramaSemInformarAhDataFinalDaEtapa(); |
||
| 148 | |||
| 149 | getContexto().checking(new Expectations(){{ |
||
| 150 | oneOf(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 151 | will(throwException(new NegocioException(MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_FINAL_DA_ETAPA))); |
||
| 152 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 153 | }}); |
||
| 154 | |||
| 155 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 156 | @Override |
||
| 157 | public void execute() throws Exception { |
||
| 158 | cronogramaService.cadastrar(cronograma); |
||
| 159 | } |
||
| 160 | }, MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_FINAL_DA_ETAPA); |
||
| 161 | } |
||
| 162 | |||
| 163 | @Test |
||
| 164 | public void aoCadastrarCronogramaComDataInicialPosteriorAhDataFinalDaEtapaDeveriaLancarExcecao() throws Exception { |
||
| 165 | preencherCronogramaComDataInicialPosteriorAhDataFinalDaEtapa(); |
||
| 166 | |||
| 167 | getContexto().checking(new Expectations(){{ |
||
| 168 | oneOf(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 169 | will(throwException(new NegocioException(MENSAGEM_A_DATA_INICIAL_NAO_PODE_SER_POSTERIOR_A_DATA_FINAL))); |
||
| 170 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 171 | }}); |
||
| 172 | |||
| 173 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 174 | @Override |
||
| 175 | public void execute() throws Exception { |
||
| 176 | cronogramaService.cadastrar(cronograma); |
||
| 177 | } |
||
| 178 | }, MENSAGEM_A_DATA_INICIAL_NAO_PODE_SER_POSTERIOR_A_DATA_FINAL); |
||
| 179 | } |
||
| 180 | |||
| 181 | @Test |
||
| 182 | public void aoCadastrarCronogramaComNenhumaEtapaVinculadaDeveriaLancarExcecao() throws Exception { |
||
| 183 | preencherCronogramaComNenhumaEtapaVinculada(); |
||
| 184 | |||
| 185 | getContexto().checking(new Expectations(){{ |
||
| 186 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 187 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 188 | }}); |
||
| 189 | |||
| 190 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 191 | @Override |
||
| 192 | public void execute() throws Exception { |
||
| 193 | cronogramaService.cadastrar(cronograma); |
||
| 194 | } |
||
| 195 | }, MENSAGEM_UM_CRONOGRAMA_DEVERA_TER_NO_MINIMO_UMA_ETAPA_VINCULADA); |
||
| 196 | } |
||
| 197 | |||
| 198 | @Test |
||
| 199 | public void aoCadastrarCronogramaComCronogramaJaExistenteDeveriaLancarExcecao() throws Exception { |
||
| 200 | |||
| 201 | getContexto().checking(new Expectations(){{ |
||
| 202 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 203 | ignoring(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 204 | oneOf(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 205 | will(returnValue(new Cronograma())); |
||
| 206 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 207 | }}); |
||
| 208 | |||
| 209 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 210 | @Override |
||
| 211 | public void execute() throws Exception { |
||
| 212 | cronogramaService.cadastrar(cronograma); |
||
| 213 | } |
||
| 214 | }, MENSAGEM_O_CRONOGRAMA_INFORMADO_JA_EXISTE); |
||
| 215 | } |
||
| 216 | |||
| 217 | @Test |
||
| 218 | public void aoCadastrarCronogramaComEtapaJaVinculadaDuasVezesDeveriaLancarExcecao() throws Exception { |
||
| 219 | preencherCronogramaComDuasEtapasDeIdIguais(); |
||
| 220 | |||
| 221 | getContexto().checking(new Expectations(){{ |
||
| 222 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 223 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 224 | }}); |
||
| 225 | |||
| 226 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 227 | @Override |
||
| 228 | public void execute() throws Exception { |
||
| 229 | cronogramaService.cadastrar(cronograma); |
||
| 230 | } |
||
| 231 | }, MENSAGEM_ETAPA_JA_VINCULADA_AO_CRONOGRAMA); |
||
| 232 | } |
||
| 233 | |||
| 234 | @Test |
||
| 235 | public void aoCadastrarCronogramaComCronogramaVigenteNoPeriodoDeveriaLancarExcecao() throws Exception { |
||
| 236 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 237 | periodo.setDataInicial(DataUtils.converterStringParaData(DATA_INICIO_19_01_2013)); |
||
| 238 | periodo.setDataFinal(DataUtils.converterStringParaData(DATA_FINAL_21_01_2013)); |
||
| 239 | |||
| 240 | getContexto().checking(new Expectations(){{ |
||
| 241 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 242 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 243 | will(returnValue(null)); |
||
| 244 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 245 | will(returnValue(periodo)); |
||
| 246 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 247 | }}); |
||
| 248 | |||
| 249 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 250 | @Override |
||
| 251 | public void execute() throws Exception { |
||
| 252 | cronogramaService.cadastrar(cronograma); |
||
| 253 | } |
||
| 254 | }, MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO); |
||
| 255 | } |
||
| 256 | |||
| 257 | @Test |
||
| 258 | public void aoCadastrarCronogramaComDataInicialProximoCronogramaAntesDataFinalCronogramaAhCadastrarDeveriaLancarExcecao() throws Exception { |
||
| 259 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 260 | periodo.setDataFinal(DataUtils.converterStringParaData(DATA_FINAL_20_01_2013)); |
||
| 261 | |||
| 262 | getContexto().checking(new Expectations(){{ |
||
| 263 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 264 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 265 | will(returnValue(null)); |
||
| 266 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 267 | will(returnValue(periodo)); |
||
| 268 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 269 | }}); |
||
| 270 | |||
| 271 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 272 | @Override |
||
| 273 | public void execute() throws Exception { |
||
| 274 | cronogramaService.cadastrar(cronograma); |
||
| 275 | } |
||
| 276 | }, MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO); |
||
| 277 | } |
||
| 278 | |||
| 279 | @Test |
||
| 280 | public void aoCadastrarCronogramaComDataInicialProximoCronogramaIgualAhDataFinalCronogramaAhCadastrarDeveriaLancarExcecao() throws Exception { |
||
| 281 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 282 | periodo.setDataFinal(DataUtils.converterStringParaData(DATA_FINAL_21_01_2013)); |
||
| 283 | |||
| 284 | getContexto().checking(new Expectations(){{ |
||
| 285 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 286 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 287 | will(returnValue(null)); |
||
| 288 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 289 | will(returnValue(periodo)); |
||
| 290 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 291 | }}); |
||
| 292 | |||
| 293 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 294 | @Override |
||
| 295 | public void execute() throws Exception { |
||
| 296 | cronogramaService.cadastrar(cronograma); |
||
| 297 | } |
||
| 298 | }, MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO); |
||
| 299 | } |
||
| 300 | |||
| 301 | @Test |
||
| 302 | public void aoCadastrarCronogramaComDataInicialProximoCronogramaAposDataFinalCronogramaAhCadastrarDeveriaDelegarParaOhRepositorio() throws Exception { |
||
| 303 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 304 | periodo.setDataFinal(DataUtils.converterStringParaData(DATA_FINAL_26_02_2013)); |
||
| 305 | getContexto().checking(new Expectations(){{ |
||
| 306 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 307 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 308 | will(returnValue(null)); |
||
| 309 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 310 | will(returnValue(periodo)); |
||
| 311 | oneOf(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 312 | }}); |
||
| 313 | |||
| 314 | cronogramaService.cadastrar(cronograma); |
||
| 315 | } |
||
| 316 | |||
| 317 | @Test |
||
| 318 | public void aoCadastrarCronogramaComDataInicialProximoCronogramaNulaDeveriaDelegarParaOhRepositorio() throws Exception { |
||
| 319 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 320 | periodo.setDataFinal(null); |
||
| 321 | getContexto().checking(new Expectations(){{ |
||
| 322 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 323 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 324 | will(returnValue(null)); |
||
| 325 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 326 | will(returnValue(periodo)); |
||
| 327 | oneOf(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 328 | }}); |
||
| 329 | |||
| 330 | cronogramaService.cadastrar(cronograma); |
||
| 331 | } |
||
| 332 | |||
| 333 | @Test |
||
| 334 | public void aoCadastrarCronogramaComDataFinalCronogramaAnteriorAposDataInicialCronogramaAhCadastrarDeveriaLancarExcecao() throws Exception { |
||
| 335 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 336 | periodo.setDataInicial(DataUtils.converterStringParaData(DATA_INICIO_21_01_2013)); |
||
| 337 | getContexto().checking(new Expectations(){{ |
||
| 338 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 339 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 340 | will(returnValue(null)); |
||
| 341 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 342 | will(returnValue(periodo)); |
||
| 343 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 344 | }}); |
||
| 345 | |||
| 346 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 347 | @Override |
||
| 348 | public void execute() throws Exception { |
||
| 349 | cronogramaService.cadastrar(cronograma); |
||
| 350 | } |
||
| 351 | }, MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO); |
||
| 352 | } |
||
| 353 | |||
| 354 | @Test |
||
| 355 | public void aoCadastrarCronogramaComDataFinalCronogramaAnteriorIgualAhDataInicialCronogramaAhCadastrarDeveriaLancarExcecao() throws Exception { |
||
| 356 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 357 | periodo.setDataInicial(DataUtils.converterStringParaData(DATA_INICIO_20_01_2013)); |
||
| 358 | getContexto().checking(new Expectations(){{ |
||
| 359 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 360 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 361 | will(returnValue(null)); |
||
| 362 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 363 | will(returnValue(periodo)); |
||
| 364 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 365 | }}); |
||
| 366 | |||
| 367 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 368 | @Override |
||
| 369 | public void execute() throws Exception { |
||
| 370 | cronogramaService.cadastrar(cronograma); |
||
| 371 | } |
||
| 372 | }, MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO); |
||
| 373 | } |
||
| 374 | |||
| 375 | @Test |
||
| 376 | public void aoCadastrarCronogramaComDataFinalCronogramaAnteriorAntesDataInicialCronogramaAhCadastrarDeveriaDelegarParaOhRepositorio() throws Exception { |
||
| 377 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 378 | periodo.setDataInicial(DataUtils.converterStringParaData(DATA_INICIO_02_01_2013)); |
||
| 379 | |||
| 380 | getContexto().checking(new Expectations(){{ |
||
| 381 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 382 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 383 | will(returnValue(null)); |
||
| 384 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 385 | will(returnValue(periodo)); |
||
| 386 | oneOf(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 387 | }}); |
||
| 388 | |||
| 389 | cronogramaService.cadastrar(cronograma); |
||
| 390 | } |
||
| 391 | |||
| 392 | @Test |
||
| 393 | public void aoCadastrarCronogramaComDataFinalCronogramaAnteriorNulaDeveriaDelegarParaRepositorio() throws Exception { |
||
| 394 | Etapa etapa2 = new EtapaBuilder().comCodigo(SEQUENCIAL_ETAPA_3).build(); |
||
| 395 | getEntidade().adicionarCronogramaEtapa(new CronogramaEtapaBuilder() |
||
| 396 | .comCronogramaEtapaId(SEQUENCIAL_ETAPA_3, ANO_2012) |
||
| 397 | .comEtapa(etapa2).comCronograma(getEntidade()) |
||
| 398 | .comDataInicialEtapa(DATA_INICIAL_01_01_2013) |
||
| 399 | .comDataFinalEtapa(DATA_FINAL_26_02_2013) |
||
| 400 | .build()); |
||
| 401 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 402 | periodo.setDataInicial(null); |
||
| 403 | getContexto().checking(new Expectations(){{ |
||
| 404 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Cadastrar.class})); |
||
| 405 | ignoring(cronogramaRepositoryMock).consultarPorId(with(same(getEntidade()))); |
||
| 406 | will(returnValue(null)); |
||
| 407 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 408 | will(returnValue(periodo)); |
||
| 409 | oneOf(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 410 | }}); |
||
| 411 | |||
| 412 | cronogramaService.cadastrar(cronograma); |
||
| 413 | } |
||
| 414 | |||
| 415 | @Test |
||
| 416 | public void aoAlterarCronogramaInserindoHistoricoDeveriaDelegarParaOhValidadorComContextoAlterar() throws Exception { |
||
| 417 | getContexto().checking(new Expectations(){{ |
||
| 418 | oneOf(validadorMock).validar(with(any(Cronograma.class)), with(new Class<?>[]{Alterar.class})); |
||
| 419 | ignoring(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 420 | will(returnValue(null)); |
||
| 421 | ignoring(cronogramaRepositoryMock).inserirHistorico(with(same(cronograma)), with(any(UsuarioView.class))); |
||
| 422 | ignoring(cronogramaRepositoryMock).alterar(with(same(cronograma))); |
||
| 423 | }}); |
||
| 424 | cronogramaService.alterarCronogramaInserindoHistorico(cronograma, new UsuarioView()); |
||
| 425 | } |
||
| 426 | |||
| 427 | @Test |
||
| 428 | public void aoAlterarCronogramaInserindoHistoricoQuandoParametroDataInicialDaEtapaNaoForInformadaDeveriaLancarExcecao() throws Exception { |
||
| 429 | getContexto().checking(new Expectations(){{ |
||
| 430 | oneOf(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 431 | will(throwException(new NegocioException(MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_INICIAL_DA_ETAPA))); |
||
| 432 | never(cronogramaRepositoryMock).alterar(cronograma); |
||
| 433 | }}); |
||
| 434 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 435 | @Override |
||
| 436 | public void execute() throws Exception { |
||
| 437 | cronogramaService.alterarCronogramaInserindoHistorico(cronograma, new UsuarioView()); |
||
| 438 | } |
||
| 439 | }, MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_INICIAL_DA_ETAPA); |
||
| 440 | } |
||
| 441 | |||
| 442 | @Test |
||
| 443 | public void aoAlterarCronogramaInserindoHistoricoQuandoParametroDataFinalDaEtapaNaoForInformadaDeveriaLancarExcecao() throws Exception { |
||
| 444 | getContexto().checking(new Expectations(){{ |
||
| 445 | oneOf(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 446 | will(throwException(new NegocioException(MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_FINAL_DA_ETAPA))); |
||
| 447 | never(cronogramaRepositoryMock).alterar(cronograma); |
||
| 448 | }}); |
||
| 449 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 450 | @Override |
||
| 451 | public void execute() throws Exception { |
||
| 452 | cronogramaService.alterarCronogramaInserindoHistorico(cronograma, new UsuarioView()); |
||
| 453 | } |
||
| 454 | }, MENSAGEM_OBRIGATORIO_INFORMAR_A_DATA_FINAL_DA_ETAPA); |
||
| 455 | } |
||
| 456 | |||
| 457 | @Test |
||
| 458 | public void aoAlterarCronogramaInserindoHistoricoComDataInicialPosteriorAhDataFinalDaEtapaDeveriaLancarExcecao() throws Exception { |
||
| 459 | preencherCronogramaComDataInicialPosteriorAhDataFinalDaEtapa(); |
||
| 460 | |||
| 461 | getContexto().checking(new Expectations(){{ |
||
| 462 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 463 | never(cronogramaRepositoryMock).alterar(cronograma); |
||
| 464 | }}); |
||
| 465 | |||
| 466 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 467 | @Override |
||
| 468 | public void execute() throws Exception { |
||
| 469 | cronogramaService.alterarCronogramaInserindoHistorico(cronograma, new UsuarioView()); |
||
| 470 | } |
||
| 471 | }, MENSAGEM_A_DATA_INICIAL_NAO_PODE_SER_POSTERIOR_A_DATA_FINAL); |
||
| 472 | } |
||
| 473 | |||
| 474 | @Test |
||
| 475 | public void aoAlterarCronogramaInserindoHistoricoComNenhumaEtapaVinculadaDeveriaLancarExcecao() throws Exception { |
||
| 476 | preencherCronogramaComNenhumaEtapaVinculada(); |
||
| 477 | |||
| 478 | getContexto().checking(new Expectations(){{ |
||
| 479 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 480 | never(cronogramaRepositoryMock).cadastrar(with(same(getEntidade()))); |
||
| 481 | }}); |
||
| 482 | |||
| 483 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 484 | @Override |
||
| 485 | public void execute() throws Exception { |
||
| 486 | cronogramaService.alterar(cronograma); |
||
| 487 | } |
||
| 488 | }, MENSAGEM_UM_CRONOGRAMA_DEVERA_TER_NO_MINIMO_UMA_ETAPA_VINCULADA); |
||
| 489 | } |
||
| 490 | |||
| 491 | @Test |
||
| 492 | public void aoAlterarCronogramaInserindoHistoricoDeveriaDelegarOhAlterarParaOhRepositorio() throws Exception { |
||
| 493 | getContexto().checking(new Expectations(){{ |
||
| 494 | ignoring(getValidadorMock()).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 495 | ignoring(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 496 | oneOf(cronogramaRepositoryMock).inserirHistorico(with(same(cronograma)), with(any(UsuarioView.class))); |
||
| 497 | oneOf(cronogramaRepositoryMock).alterar(with(same(cronograma))); |
||
| 498 | }}); |
||
| 499 | cronogramaService.alterarCronogramaInserindoHistorico(cronograma, new UsuarioView()); |
||
| 500 | } |
||
| 501 | |||
| 502 | @Test |
||
| 503 | public void aoAlterarCronogramaComEtapaJaVinculadaDuasVezesDeveriaLancarExcecao() throws Exception { |
||
| 504 | preencherCronogramaComDuasEtapasDeIdIguais(); |
||
| 505 | getContexto().checking(new Expectations(){{ |
||
| 506 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 507 | never(cronogramaRepositoryMock).alterar(with(same(getEntidade()))); |
||
| 508 | }}); |
||
| 509 | |||
| 510 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 511 | @Override |
||
| 512 | public void execute() throws Exception { |
||
| 513 | cronogramaService.alterar(cronograma); |
||
| 514 | } |
||
| 515 | }, MENSAGEM_ETAPA_JA_VINCULADA_AO_CRONOGRAMA); |
||
| 516 | } |
||
| 517 | |||
| 518 | @Test |
||
| 519 | public void aoAlterarCronogramaComCronogramaVigenteNoPeriodoDeveriaLancarExcecao() throws Exception { |
||
| 520 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 521 | periodo.setDataInicial(DataUtils.converterStringParaData(DATA_INICIO_19_01_2013)); |
||
| 522 | periodo.setDataFinal(DataUtils.converterStringParaData(DATA_FINAL_21_01_2013)); |
||
| 523 | |||
| 524 | getContexto().checking(new Expectations(){{ |
||
| 525 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 526 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 527 | will(returnValue(periodo)); |
||
| 528 | never(cronogramaRepositoryMock).alterar(with(same(getEntidade()))); |
||
| 529 | }}); |
||
| 530 | |||
| 531 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 532 | @Override |
||
| 533 | public void execute() throws Exception { |
||
| 534 | cronogramaService.alterar(cronograma); |
||
| 535 | } |
||
| 536 | }, MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO); |
||
| 537 | } |
||
| 538 | |||
| 539 | @Test |
||
| 540 | public void aoAlterarCronogramaComDataInicialProximoCronogramaAntesDataFinalCronogramaAhCadastrarDeveriaLancarExcecao() throws Exception { |
||
| 541 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 542 | periodo.setDataFinal(DataUtils.converterStringParaData(DATA_FINAL_20_01_2013)); |
||
| 543 | getContexto().checking(new Expectations(){{ |
||
| 544 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 545 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 546 | will(returnValue(periodo)); |
||
| 547 | never(cronogramaRepositoryMock).alterar(with(same(getEntidade()))); |
||
| 548 | }}); |
||
| 549 | |||
| 550 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 551 | @Override |
||
| 552 | public void execute() throws Exception { |
||
| 553 | cronogramaService.alterar(cronograma); |
||
| 554 | } |
||
| 555 | }, MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO); |
||
| 556 | } |
||
| 557 | |||
| 558 | @Test |
||
| 559 | public void aoAlterarCronogramaComDataInicialProximoCronogramaIgualAhDataFinalCronogramaAhCadastrarDeveriaLancarExcecao() throws Exception { |
||
| 560 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 561 | periodo.setDataFinal(DataUtils.converterStringParaData(DATA_FINAL_21_01_2013)); |
||
| 562 | getContexto().checking(new Expectations(){{ |
||
| 563 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 564 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 565 | will(returnValue(periodo)); |
||
| 566 | never(cronogramaRepositoryMock).alterar(with(same(getEntidade()))); |
||
| 567 | }}); |
||
| 568 | |||
| 569 | VerificadorLancamentoException.verificarMensagemLancamentoExceptionSemRetornoMensagem(new CommandSemMensagem() { |
||
| 570 | @Override |
||
| 571 | public void execute() throws Exception { |
||
| 572 | cronogramaService.alterar(cronograma); |
||
| 573 | } |
||
| 574 | }, MENSAGEM_EXISTE_CRONOGRAMA_PERIODO_INFORMADO); |
||
| 575 | } |
||
| 576 | |||
| 577 | @Test |
||
| 578 | public void aoAlterarCronogramaComDataInicialProximoCronogramaAposDataFinalCronogramaAhCadastrarDeveriaDelegarParaOhRepositorio() throws Exception { |
||
| 579 | Etapa etapa2 = new EtapaBuilder().comCodigo(SEQUENCIAL_ETAPA_3).build(); |
||
| 580 | getEntidade().adicionarCronogramaEtapa(new CronogramaEtapaBuilder() |
||
| 581 | .comCronogramaEtapaId(SEQUENCIAL_ETAPA_3, ANO_2012) |
||
| 582 | .comEtapa(etapa2).comCronograma(getEntidade()) |
||
| 583 | .comDataInicialEtapa(DATA_INICIAL_01_01_2013) |
||
| 584 | .comDataFinalEtapa(DATA_FINAL_26_02_2013) |
||
| 585 | .build()); |
||
| 586 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 587 | periodo.setDataFinal(DataUtils.converterStringParaData(DATA_FINAL_01_06_2013)); |
||
| 588 | getContexto().checking(new Expectations(){{ |
||
| 589 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 590 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 591 | will(returnValue(periodo)); |
||
| 592 | oneOf(cronogramaRepositoryMock).alterar(with(same(getEntidade()))); |
||
| 593 | }}); |
||
| 594 | cronogramaService.alterar(getEntidade()); |
||
| 595 | } |
||
| 596 | |||
| 597 | @Test |
||
| 598 | public void aoAlterarCronogramaComDataInicialProximoCronogramaNulaDeveriaDelegarParaOhRepositorio() throws Exception { |
||
| 599 | final PeriodoDTO periodo = new PeriodoDTO(); |
||
| 600 | periodo.setDataFinal(null); |
||
| 601 | getContexto().checking(new Expectations(){{ |
||
| 602 | ignoring(validadorMock).validar(with(same(getEntidade())), with(new Class<?>[]{Alterar.class})); |
||
| 603 | oneOf(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 604 | will(returnValue(periodo)); |
||
| 605 | oneOf(cronogramaRepositoryMock).alterar(with(same(getEntidade()))); |
||
| 606 | }}); |
||
| 607 | |||
| 608 | cronogramaService.alterar(cronograma); |
||
| 609 | } |
||
| 610 | |||
| 611 | |||
| 612 | @Test |
||
| 613 | public void aoConsultarCronogramaCorrenteDeveriaDelegarParaOhRepositorio() throws Exception { |
||
| 614 | getContexto().checking(new Expectations(){{ |
||
| 615 | oneOf(cronogramaRepositoryMock).consultarCronogramaCorrente(); |
||
| 616 | will(returnValue(new Cronograma())); |
||
| 617 | }}); |
||
| 618 | |||
| 619 | cronogramaService.consultarCronogramaCorrente(); |
||
| 620 | } |
||
| 621 | |||
| 622 | @Override |
||
| 623 | protected void expectativasDeNegocioFuncionalidadeCadastrar() { |
||
| 624 | getContexto().checking(new Expectations(){{ |
||
| 625 | ignoring(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 626 | ignoring(getRepositoryMock()).consultarPorId(with(same(getEntidade()))); |
||
| 627 | will(returnValue(null)); |
||
| 628 | }}); |
||
| 629 | } |
||
| 630 | |||
| 631 | @Override |
||
| 632 | protected void expectativasDeNegocioFuncionalidadeAlterar() { |
||
| 633 | getContexto().checking(new Expectations(){{ |
||
| 634 | ignoring(cronogramaRepositoryMock).consultarPeriodoDeVigenciaDasEtapasCadastradas(with(any(Cronograma.class))); |
||
| 635 | ignoring(getRepositoryMock()).consultarPorId(with(same(getEntidade()))); |
||
| 636 | will(returnValue(null)); |
||
| 637 | }}); |
||
| 638 | } |
||
| 639 | |||
| 640 | private void preencherCronogramaSemInformarOhAnoDoCronograma() { |
||
| 641 | cronograma.setNumeroAno(null); |
||
| 642 | cronograma.adicionarCronogramaEtapa(new CronogramaEtapaBuilder().comEtapa(etapa).comCronograma(cronograma).comDataInicialEtapa(DATA_INICIAL_01_01_2013).build()); |
||
| 643 | } |
||
| 644 | |||
| 645 | private void preencherCronogramaSemInformarAhDataInicialDaEtapa() { |
||
| 646 | cronograma.setCronogramaEtapas(null); |
||
| 647 | cronograma.setNumeroAno(new Long(ANO_2012)); |
||
| 648 | cronograma.adicionarCronogramaEtapa(new CronogramaEtapaBuilder().comEtapa(etapa).comCronograma(cronograma).comDataFinalEtapa(DATA_FINAL_01_06_2013).build()); |
||
| 649 | } |
||
| 650 | |||
| 651 | private void preencherCronogramaSemInformarAhDataFinalDaEtapa() { |
||
| 652 | cronograma.setCronogramaEtapas(null); |
||
| 653 | cronograma.setNumeroAno(new Long(ANO_2012)); |
||
| 654 | cronograma.adicionarCronogramaEtapa(new CronogramaEtapaBuilder().comEtapa(etapa).comCronograma(cronograma).comDataInicialEtapa(DATA_INICIAL_01_01_2013).build()); |
||
| 655 | } |
||
| 656 | |||
| 657 | private void preencherCronogramaComDataInicialPosteriorAhDataFinalDaEtapa() { |
||
| 658 | cronograma.setCronogramaEtapas(null); |
||
| 659 | cronograma.setNumeroAno(new Long(ANO_2012)); |
||
| 660 | cronograma.adicionarCronogramaEtapa(new CronogramaEtapaBuilder().comEtapa(etapa).comCronograma(cronograma).comDataInicialEtapa(DATA_FINAL_01_06_2013).comDataFinalEtapa(DATA_INICIAL_01_01_2013).build()); |
||
| 661 | } |
||
| 662 | |||
| 663 | private void preencherCronogramaComDuasEtapasDeIdIguais() { |
||
| 664 | cronograma.setCronogramaEtapas(null); |
||
| 665 | cronograma.setNumeroAno(new Long(ANO_2012)); |
||
| 666 | Etapa etapa1 = new EtapaBuilder().comCodigo(SEQUENCIAL_ETAPA_1).build(); |
||
| 667 | Etapa etapa2 = new EtapaBuilder().comCodigo(SEQUENCIAL_ETAPA_1).build(); |
||
| 668 | cronograma.adicionarCronogramaEtapa(new CronogramaEtapaBuilder().comEtapa(etapa1).comCronograma(cronograma).comDataInicialEtapa(DATA_INICIAL_01_01_2013).comDataFinalEtapa(DATA_FINAL_01_06_2013).build()); |
||
| 669 | cronograma.adicionarCronogramaEtapa(new CronogramaEtapaBuilder().comEtapa(etapa2).comCronograma(cronograma).comDataInicialEtapa(DATA_INICIAL_01_03_2013).comDataFinalEtapa(DATA_FINAL_01_06_2013).build()); |
||
| 670 | } |
||
| 671 | |||
| 672 | private void preencherCronogramaComNenhumaEtapaVinculada() { |
||
| 673 | cronograma.setCronogramaEtapas(new HashSet<CronogramaEtapa>()); |
||
| 674 | } |
||
| 675 | |||
| 676 | } |