@Test public void shouldReturnSecondPersonWithEditMav() { Long template = dataInitializer.people.get(1); ModelAndView mav = personController.editPerson(template); assertNotNull(mav); assertEquals("edit", mav.getViewName()); Object object = mav.getModel().get("person"); assertTrue(Person.class.isAssignableFrom(object.getClass())); Person person = (Person) object; assertEquals(template, person.getId()); }
public void shouldReturnNewPersonWithEditMav() { ModelAndView mav = personController.editPerson(null); assertNotNull(mav); assertEquals("edit", mav.getViewName()); Object object = mav.getModel().get("person"); assertTrue(Person.class.isAssignableFrom(object.getClass())); Person person = (Person) object; assertNull(person.getId()); assertNull(person.getFirstName()); assertNull(person.getLastName()); }