use of br.com.caelum.agiletickets.models.Sessao in project agiletickets by caelum.
the class EspetaculosController method cadastraSessoes.
@Post
@Path("/espetaculo/{espetaculoId}/sessoes")
public void cadastraSessoes(Long espetaculoId, LocalDate inicio, LocalDate fim, LocalTime horario, Periodicidade periodicidade) {
Espetaculo espetaculo = carregaEspetaculo(espetaculoId);
// aqui faz a magica!
// cria sessoes baseado no periodo de inicio e fim passados pelo usuario
List<Sessao> sessoes = espetaculo.criaSessoes(inicio, fim, horario, periodicidade);
agenda.agende(sessoes);
result.include("message", sessoes.size() + " sessões criadas com sucesso");
result.redirectTo(this).lista();
}
use of br.com.caelum.agiletickets.models.Sessao in project agiletickets by caelum.
the class EspetaculosControllerTest method naoDeveReservarZeroIngressos.
@Test(expected = ValidationException.class)
public void naoDeveReservarZeroIngressos() throws Exception {
when(agenda.sessao(1234l)).thenReturn(new Sessao());
controller.reserva(1234l, 0);
verifyZeroInteractions(result);
}
use of br.com.caelum.agiletickets.models.Sessao in project agiletickets by caelum.
the class EspetaculosControllerTest method deveReservarSeASessaoTemIngressosSuficientes.
@Test
public void deveReservarSeASessaoTemIngressosSuficientes() throws Exception {
Espetaculo espetaculo = new Espetaculo();
espetaculo.setTipo(TipoDeEspetaculo.TEATRO);
Sessao sessao = new Sessao();
sessao.setPreco(new BigDecimal("10.00"));
sessao.setTotalIngressos(5);
sessao.setEspetaculo(espetaculo);
when(agenda.sessao(1234l)).thenReturn(sessao);
controller.reserva(1234l, 3);
assertThat(sessao.getIngressosDisponiveis(), is(2));
}
use of br.com.caelum.agiletickets.models.Sessao in project agiletickets by caelum.
the class EspetaculosControllerTest method naoDeveReservarMaisIngressosQueASessaoPermite.
@Test(expected = ValidationException.class)
public void naoDeveReservarMaisIngressosQueASessaoPermite() throws Exception {
Sessao sessao = new Sessao();
sessao.setTotalIngressos(3);
when(agenda.sessao(1234l)).thenReturn(sessao);
controller.reserva(1234l, 5);
verifyZeroInteractions(result);
}
use of br.com.caelum.agiletickets.models.Sessao in project agiletickets by caelum.
the class CalculadoraDePrecosTest method deveAplicar20PorCentoAMaisNosUltimosIngressosQuandoForOrquestra.
@Test
public void deveAplicar20PorCentoAMaisNosUltimosIngressosQuandoForOrquestra() {
Sessao sessao = SessaoTestDataBuilder.umaSessao().deUmEspetaculoDoTipo(TipoDeEspetaculo.ORQUESTRA).comTotalIngressos(70).comIngressoReservados(40).comOPreco(1000.0).comDuracaoEmMinutos(60).build();
BigDecimal precoTotal = CalculadoraDePrecos.calcula(sessao, 1);
assertEquals(0, BigDecimal.valueOf(1200.0).compareTo(precoTotal));
}
Aggregations