@Test public void shouldBeAbleToSaveMoreVisitorsForOneRegistrant() throws Exception { mockMvc .perform( post("/tickets/epay") .param("visitors[0].name", "Lurch") .param("visitors[0].email", "*****@*****.**") .param("visitors[1].name", "Morticia Adams") .param("visitors[1].email", "*****@*****.**") .param("company", "true") .param("name", "Adams Family") .param("address", "0001 Cemetery Lane") .param("vatNumber", "666") .param("mol", "Gomez Adams") .param("email", "*****@*****.**") .param("paymentType", Registrant.PaymentType.BANK_TRANSFER.toString())) .andExpect(status().isOk()) .andExpect(view().name(TICKETS_EPAY_RESULT_JSP)); List<Registrant> allRegistrants = (List<Registrant>) registrantRepository.findAll(); assertThat(allRegistrants.size(), is(1)); Registrant registrant = allRegistrants.get(0); assertThat(2, is(registrant.getVisitors().size())); assertThat(registrant.getVisitors().get(0).getName(), anyOf(is("Morticia Adams"), is("Lurch"))); assertThat(VisitorStatus.REQUESTING, is(registrant.getVisitors().get(0).getStatus())); }
@Test public void getTicketsEpayShouldReturnEmptyRegistrantAndAllPaymentTypes() throws Exception { mockMvc .perform(get("/tickets/epay")) .andExpect(status().isOk()) .andExpect(view().name(TICKETS_EPAY_REGISTER_JSP)) .andExpect(model().attribute("registrant", new Registrant())) .andExpect( model() .attribute( "paymentTypes", containsInAnyOrder( Registrant.PaymentType.BANK_TRANSFER.toString(), Registrant.PaymentType.EPAY_ACCOUNT.toString(), Registrant.PaymentType.EPAY_CREDIT_CARD.toString()))); }
@Test public void postNonCompanyRegistrantShouldSaveVisitorDataAsRegistrant() throws Exception { mockMvc .perform( post("/tickets/epay") .param("visitors[0].name", "John Doe") .param("visitors[0].email", "*****@*****.**") .param("visitors[0].company", "Example") .param("paymentType", Registrant.PaymentType.BANK_TRANSFER.toString()) .param("company", "false")) .andExpect(status().isOk()) .andExpect(view().name(TICKETS_EPAY_RESULT_JSP)); List<Registrant> allRegistrants = (List<Registrant>) registrantRepository.findAll(); assertThat(allRegistrants.size(), is(1)); Registrant registrant = allRegistrants.get(0); assertThat("John Doe", is(registrant.getName())); assertThat("*****@*****.**", is(registrant.getEmail())); assertThat(false, is(registrant.isCompany())); assertThat(1, is(registrant.getVisitors().size())); assertThat("John Doe", is(registrant.getVisitors().get(0).getName())); assertThat("*****@*****.**", is(registrant.getVisitors().get(0).getEmail())); assertThat("Example", is(registrant.getVisitors().get(0).getCompany())); }