Examples of BindingAwareModelMap


Examples of org.springframework.validation.support.BindingAwareModelMap

    @Test
    public void showSearchResultPage() {
        SearchDTO searchCriteria = createSearchDTO();

        Model model = new BindingAwareModelMap();
        String view = controller.showSearchResultPage(searchCriteria, model);

        SearchDTO modelAttribute = (SearchDTO) model.asMap().get(PersonController.MODEL_ATTRIBUTE_SEARCH_CRITERIA);

        assertEquals(searchCriteria.getPageIndex(), modelAttribute.getPageIndex());
        assertEquals(searchCriteria.getSearchTerm(), modelAttribute.getSearchTerm());

        assertEquals(PersonController.PERSON_SEARCH_RESULT_VIEW, view);
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

    public void search() {
        SearchDTO searchCriteria = createSearchDTO();
        List<Person> expected = new ArrayList<Person>();
        when(personServiceMock.search(searchCriteria.getSearchTerm())).thenReturn(expected);
       
        BindingAwareModelMap model = new BindingAwareModelMap();
        String view = controller.search(searchCriteria, model);
       
        verify(personServiceMock, times(1)).search(searchCriteria.getSearchTerm());
        verifyNoMoreInteractions(personServiceMock);
       
        assertEquals(PersonController.PERSON_SEARCH_RESULT_VIEW, view);
        List<Person> actual = (List<Person>) model.asMap().get(PersonController.MODEL_ATTRIBUTE_PERSONS);
        assertEquals(expected, actual);
    }
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

        return dto;
    }
   
    @Test
    public void showCreatePersonForm() {
        Model model = new BindingAwareModelMap();
       
        String view = controller.showCreatePersonForm(model);
       
        verifyZeroInteractions(personServiceMock);
       
        assertEquals(PersonController.PERSON_ADD_FORM_VIEW, view);

        PersonDTO added = (PersonDTO) model.asMap().get(PersonController.MODEL_ATTIRUTE_PERSON);
        assertNotNull(added);
       
        assertNull(added.getId());
        assertNull(added.getFirstName());
        assertNull(added.getLastName());
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

    @Test
    public void showEditPersonForm() {
        Person person = PersonTestUtil.createModelObject(PERSON_ID, FIRST_NAME, LAST_NAME);
        when(personServiceMock.findById(PERSON_ID)).thenReturn(person);
       
        Model model = new BindingAwareModelMap();
        RedirectAttributes attributes = new RedirectAttributesModelMap();
       
        String view = controller.showEditPersonForm(PERSON_ID, model, attributes);
       
        verify(personServiceMock, times(1)).findById(PERSON_ID);
        verifyNoMoreInteractions(personServiceMock);
       
        assertEquals(PersonController.PERSON_EDIT_FORM_VIEW, view);
       
        PersonDTO formObject = (PersonDTO) model.asMap().get(PersonController.MODEL_ATTIRUTE_PERSON);

        assertNotNull(formObject);
        assertEquals(person.getId(), formObject.getId());
        assertEquals(person.getFirstName(), formObject.getFirstName());
        assertEquals(person.getLastName(), formObject.getLastName());
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

    public void showEditPersonFormWhenPersonIsNotFound() {
        when(personServiceMock.findById(PERSON_ID)).thenReturn(null);
       
        initMessageSourceForErrorMessage(PersonController.ERROR_MESSAGE_KEY_EDITED_PERSON_WAS_NOT_FOUND);
       
        Model model = new BindingAwareModelMap();
        RedirectAttributes attributes = new RedirectAttributesModelMap();
       
        String view = controller.showEditPersonForm(PERSON_ID, model, attributes);
       
        verify(personServiceMock, times(1)).findById(PERSON_ID);
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

    @Test
    public void showList() {
        List<Person> persons = new ArrayList<Person>();
        when(personServiceMock.findAll()).thenReturn(persons);
       
        Model model = new BindingAwareModelMap();
        String view = controller.showList(model);
       
        verify(personServiceMock, times(1)).findAll();
        verifyNoMoreInteractions(personServiceMock);
       
        assertEquals(PersonController.PERSON_LIST_VIEW, view);
        assertEquals(persons, model.asMap().get(PersonController.MODEL_ATTRIBUTE_PERSONS));
       
        SearchDTO searchCriteria = (SearchDTO) model.asMap().get(PersonController.MODEL_ATTRIBUTE_SEARCH_CRITERIA);
        assertNotNull(searchCriteria);
        assertNull(searchCriteria.getSearchTerm());
    }
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

        assertEquals(expectedView, view);
    }
   
    @Test
    public void showCreatePersonForm() {
        Model model = new BindingAwareModelMap();
       
        String view = controller.showCreatePersonForm(model);
       
        verifyZeroInteractions(personServiceMock);
       
        assertEquals(PersonController.PERSON_ADD_FORM_VIEW, view);

        PersonDTO added = (PersonDTO) model.asMap().get(PersonController.MODEL_ATTIRUTE_PERSON);
        assertNotNull(added);
       
        assertNull(added.getId());
        assertNull(added.getFirstName());
        assertNull(added.getLastName());
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

    @Test
    public void showEditPersonForm() {
        Person person = PersonTestUtil.createModelObject(PERSON_ID, FIRST_NAME, LAST_NAME);
        when(personServiceMock.findById(PERSON_ID)).thenReturn(person);
       
        Model model = new BindingAwareModelMap();
        RedirectAttributes attributes = new RedirectAttributesModelMap();
       
        String view = controller.showEditPersonForm(PERSON_ID, model, attributes);
       
        verify(personServiceMock, times(1)).findById(PERSON_ID);
        verifyNoMoreInteractions(personServiceMock);
       
        assertEquals(PersonController.PERSON_EDIT_FORM_VIEW, view);
       
        PersonDTO formObject = (PersonDTO) model.asMap().get(PersonController.MODEL_ATTIRUTE_PERSON);

        assertNotNull(formObject);
        assertEquals(person.getId(), formObject.getId());
        assertEquals(person.getFirstName(), formObject.getFirstName());
        assertEquals(person.getLastName(), formObject.getLastName());
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

    public void showEditPersonFormWhenPersonIsNotFound() {
        when(personServiceMock.findById(PERSON_ID)).thenReturn(null);
       
        initMessageSourceForErrorMessage(PersonController.ERROR_MESSAGE_KEY_EDITED_PERSON_WAS_NOT_FOUND);
       
        Model model = new BindingAwareModelMap();
        RedirectAttributes attributes = new RedirectAttributesModelMap();
       
        String view = controller.showEditPersonForm(PERSON_ID, model, attributes);
       
        verify(personServiceMock, times(1)).findById(PERSON_ID);
View Full Code Here

Examples of org.springframework.validation.support.BindingAwareModelMap

    @Test
    public void showList() {
        List<Person> persons = new ArrayList<Person>();
        when(personServiceMock.findAll()).thenReturn(persons);
       
        Model model = new BindingAwareModelMap();
        String view = controller.showList(model);
       
        verify(personServiceMock, times(1)).findAll();
        verifyNoMoreInteractions(personServiceMock);
       
        assertEquals(PersonController.PERSON_LIST_VIEW, view);
        assertEquals(persons, model.asMap().get(PersonController.MODEL_ATTRIBUTE_PERSONS));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.