Package net.petrikainulainen.spring.datajpa.dto

Examples of net.petrikainulainen.spring.datajpa.dto.SearchDTO


    public String showList(Model model) {
        LOGGER.debug("Rendering person list page");

        List<Person> persons = personService.findAll();
        model.addAttribute(MODEL_ATTRIBUTE_PERSONS, persons);
        model.addAttribute(MODEL_ATTRIBUTE_SEARCH_CRITERIA, new SearchDTO());

        return PERSON_LIST_VIEW;
    }
View Full Code Here


    public String showList(Model model) {
        LOGGER.debug("Rendering person list page");

        List<Person> persons = personService.findAll();
        model.addAttribute(MODEL_ATTRIBUTE_PERSONS, persons);
        model.addAttribute(MODEL_ATTRIBUTE_SEARCHCRITERIA, new SearchDTO());

        return PERSON_LIST_VIEW;
    }
View Full Code Here

        controller.setPersonService(personServiceMock);
    }

    @Test
    public void count() {
        SearchDTO searchCriteria = createSearchDTO();
        when(personServiceMock.count(searchCriteria.getSearchTerm())).thenReturn(PERSON_COUNT);

        long personCount = controller.count(searchCriteria);

        verify(personServiceMock, times(1)).count(searchCriteria.getSearchTerm());
        verifyNoMoreInteractions(personServiceMock);

        assertEquals(PERSON_COUNT, personCount);
    }
View Full Code Here

        assertEquals(expectedView, view);
    }
   
    @Test
         public void searchWhenNoPersonsIsFound() {
        SearchDTO searchCriteria = createSearchDTO();
        List<Person> expected = new ArrayList<Person>();
        when(personServiceMock.search(searchCriteria.getSearchTerm(), searchCriteria.getPageIndex())).thenReturn(expected);

        List<PersonDTO> actual = controller.search(searchCriteria);

        verify(personServiceMock, times(1)).search(searchCriteria.getSearchTerm(), searchCriteria.getPageIndex());
        verifyNoMoreInteractions(personServiceMock);

        assertDtos(expected, actual);
    }
View Full Code Here

        assertDtos(expected, actual);
    }

    @Test
    public void search() {
        SearchDTO searchCriteria = createSearchDTO();
        List<Person> expected = createModels();
        when(personServiceMock.search(searchCriteria.getSearchTerm(), searchCriteria.getPageIndex())).thenReturn(expected);

        List<PersonDTO> actual = controller.search(searchCriteria);

        verify(personServiceMock, times(1)).search(searchCriteria.getSearchTerm(), searchCriteria.getPageIndex());
        verifyNoMoreInteractions(personServiceMock);

        assertDtos(expected, actual);
    }
View Full Code Here

            assertEquals(model.getLastName(), dto.getLastName());
        }
    }

    private SearchDTO createSearchDTO() {
        SearchDTO dto = new SearchDTO();
        dto.setPageIndex(PAGE_INDEX);
        dto.setSearchTerm(SEARCH_TERM);
        return dto;
    }
View Full Code Here

        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

        assertNull(searchCriteria.getSearchTerm());
    }

    @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

    public String showList(Model model) {
        LOGGER.debug("Rendering person list page");

        List<Person> persons = personService.findAll();
        model.addAttribute(MODEL_ATTRIBUTE_PERSONS, persons);
        model.addAttribute(MODEL_ATTRIBUTE_SEARCH_CRITERIA, new SearchDTO());

        return PERSON_LIST_VIEW;
    }
View Full Code Here

        assertEquals(expectedView, view);
    }
   
    @Test
    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

TOP

Related Classes of net.petrikainulainen.spring.datajpa.dto.SearchDTO

Copyright © 2018 www.massapicom. 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.