@Test public void postCompanyRegistrantShouldSaveInvoiceData() throws Exception { mockMvc .perform( post("/tickets/epay") .param("visitors[0].name", "John Doe") .param("visitors[0].email", "*****@*****.**") .param("visitors[0].company", "Example") .param("company", "true") .param("name", "Adams Family") .param("address", "0001 Cemetery Lane") .param("eik", "666") .param("vatNumber", "666") .param("mol", "Gomez Adams") .param("email", "*****@*****.**") .param("paymentType", Registrant.PaymentType.EPAY_CREDIT_CARD.toString())) .andExpect(status().isOk()) .andExpect(view().name(TICKETS_EPAY_BUY_JSP)); List<Registrant> allRegistrants = (List<Registrant>) registrantRepository.findAll(); assertThat(allRegistrants.size(), is(1)); Registrant registrant = allRegistrants.get(0); assertThat("Adams Family", is(registrant.getName())); assertThat("*****@*****.**", is(registrant.getEmail())); assertThat("Adams Family", is(registrant.getName())); assertThat("0001 Cemetery Lane", is(registrant.getAddress())); assertThat("BG666", is(registrant.getVatNumber())); assertThat("666", is(registrant.getEik())); assertThat("Gomez Adams", is(registrant.getMol())); assertThat(true, 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())); assertThat(VisitorStatus.REQUESTING, is(registrant.getVisitors().get(0).getStatus())); }
@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 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())); }