/** * Tests the submission of the form that edits a Reporter * * @throws Exception */ @Test public void testSubmitEditReporter() throws Exception { Reporter edited = new Reporter(1L, "5 Reliance Cresc", "0423222234", "*****@*****.**"); when(reporterServiceMock.save(edited)).thenReturn(edited); mockMvc .perform( post("/reporters/1/edit") .param("address", "5 Reliance Cresc") .param("phoneNumber", "0423222234") .param("emailAddress", "*****@*****.**")) .andExpect(status().isFound()) .andExpect(redirectedUrl("/reporters/1")); verify(reporterServiceMock, atLeastOnce()).save(edited); }
/** * Test the submission of a new registered user * * @throws Exception */ @Test public void testProcessReporterRegistration() throws Exception { Reporter unsaved = new Reporter("5 Reliance Cresc", "0423111234", "*****@*****.**"); Reporter saved = new Reporter(1L, "5 Reliance Cresc", "0423111234", "*****@*****.**"); when(reporterServiceMock.save(unsaved)).thenReturn(saved); mockMvc .perform( post("/reporters/report") .param("address", "5 Reliance Cresc") .param("phoneNumber", "0423111234") .param("emailAddress", "*****@*****.**")) .andExpect(status().isFound()) .andExpect(redirectedUrl("/reporters/1")); verify(reporterServiceMock, atLeastOnce()).save(unsaved); }