Package net.petrikainulainen.spring.testmvc.todo.exception

Examples of net.petrikainulainen.spring.testmvc.todo.exception.TodoNotFoundException


        Todo found = repository.findOne(id);
        LOGGER.debug("Found to-do entry: {}", found);

        if (found == null) {
            throw new TodoNotFoundException("No to-entry found with id: " + id);
        }

        return found;
    }
View Full Code Here


        assertTodo(expected, actual);
    }

    @Test(expected = TodoNotFoundException.class)
    public void deleteByIdWhenTodoIsNotFound() throws TodoNotFoundException {
        when(serviceMock.deleteById(TodoTestUtil.ID)).thenThrow(new TodoNotFoundException(""));

        controller.deleteById(TodoTestUtil.ID);

        verify(serviceMock, times(1)).deleteById(TodoTestUtil.ID);
        verifyNoMoreInteractions(serviceMock);
View Full Code Here

    }

    @Test(expected = TodoNotFoundException.class)
    public void updateWhenTodoIsNotFound() throws FormValidationError, TodoNotFoundException {
        TodoDTO dto = TodoTestUtil.createDTO(TodoTestUtil.ID, TodoTestUtil.DESCRIPTION, TodoTestUtil.TITLE);
        when(serviceMock.update(dto)).thenThrow(new TodoNotFoundException(""));

        controller.update(dto, TodoTestUtil.ID);

        verify(serviceMock, times(1)).update(dto);
        verifyNoMoreInteractions(serviceMock);
View Full Code Here

        assertTodo(expected, actual);
    }

    @Test(expected = TodoNotFoundException.class)
    public void findByIdWhenTodoIsNotFound() throws TodoNotFoundException {
        when(serviceMock.findById(TodoTestUtil.ID)).thenThrow(new TodoNotFoundException(""));

        controller.findById(TodoTestUtil.ID);

        verify(serviceMock, times(1)).findById(TodoTestUtil.ID);
        verifyNoMoreInteractions(serviceMock);
View Full Code Here

        Todo found = repository.findOne(id);
        LOGGER.debug("Found to-do entry: {}", found);

        if (found == null) {
            throw new TodoNotFoundException("No to-entry found with id: " + id);
        }

        return found;
    }
View Full Code Here

    @Test(expected = TodoNotFoundException.class)
    public void deleteByIdWhenToDoIsNotFound() throws TodoNotFoundException {
        RedirectAttributesModelMap attributes = new RedirectAttributesModelMap();

        when(serviceMock.deleteById(TodoTestUtil.ID)).thenThrow(new TodoNotFoundException(""));

        controller.deleteById(TodoTestUtil.ID, attributes);

        verify(serviceMock, times(1)).deleteById(TodoTestUtil.ID);
        verifyNoMoreInteractions(serviceMock);
View Full Code Here

    @Test(expected = TodoNotFoundException.class)
    public void findByIdWhenToDoIsNotFound() throws TodoNotFoundException {
        BindingAwareModelMap model = new BindingAwareModelMap();

        when(serviceMock.findById(TodoTestUtil.ID)).thenThrow(new TodoNotFoundException(""));

        controller.findById(TodoTestUtil.ID, model);

        verify(serviceMock, times(1)).findById(TodoTestUtil.ID);
        verifyNoMoreInteractions(serviceMock);
View Full Code Here

    @Test(expected = TodoNotFoundException.class)
    public void showUpdateTodoFormWhenToDoIsNotFound() throws TodoNotFoundException {
        BindingAwareModelMap model = new BindingAwareModelMap();

        when(serviceMock.findById(TodoTestUtil.ID)).thenThrow(new TodoNotFoundException(""));

        controller.showUpdateTodoForm(TodoTestUtil.ID, model);

        verify(serviceMock, times(1)).findById(TodoTestUtil.ID);
        verifyNoMoreInteractions(serviceMock);
View Full Code Here

    @Test(expected = TodoNotFoundException.class)
    public void updateWhenToDoIsNotFound() throws TodoNotFoundException {
        TodoDTO formObject = TodoTestUtil.createFormObject(TodoTestUtil.ID, TodoTestUtil.DESCRIPTION_UPDATED, TodoTestUtil.TITLE_UPDATED);

        when(serviceMock.update(formObject)).thenThrow(new TodoNotFoundException(""));

        MockHttpServletRequest mockRequest = new MockHttpServletRequest("POST", "/todo/add");
        BindingResult result = bindAndValidate(mockRequest, formObject);

        RedirectAttributesModelMap attributes = new RedirectAttributesModelMap();
View Full Code Here

        verifyNoMoreInteractions(todoServiceMock);
    }

    @Test
    public void findById_TodoEntryNotFound_ShouldRender404View() throws Exception {
        when(todoServiceMock.findById(ID)).thenThrow(new TodoNotFoundException(""));

        mockMvc.perform(get("/todo/{id}", ID))
                .andExpect(status().isNotFound())
                .andExpect(view().name(ErrorController.VIEW_NOT_FOUND))
                .andExpect(forwardedUrl("/WEB-INF/jsp/error/404.jsp"));
View Full Code Here

TOP

Related Classes of net.petrikainulainen.spring.testmvc.todo.exception.TodoNotFoundException

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.