Package net.petrikainulainen.spring.testmvc.todo.model

Examples of net.petrikainulainen.spring.testmvc.todo.model.Todo


        verifyZeroInteractions(todoServiceMock);
    }

    @Test
    public void update_TodoEntryFound_ShouldUpdateTodoEntryAndRenderViewTodoEntryView() throws Exception {
        Todo updated = new TodoBuilder()
                .id(ID)
                .description(DESCRIPTION)
                .title(TITLE)
                .build();
View Full Code Here


    @RequestMapping(value = "/api/todo", method = RequestMethod.POST)
    @ResponseBody
    public TodoDTO add(@Valid @RequestBody TodoDTO dto) {
        LOGGER.debug("Adding a new to-do entry with information: {}", dto);

        Todo added = service.add(dto);
        LOGGER.debug("Added a to-do entry with information: {}", added);

       return createDTO(added);
    }
View Full Code Here

    @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public TodoDTO deleteById(@PathVariable("id") Long id) throws TodoNotFoundException {
        LOGGER.debug("Deleting a to-do entry with id: {}", id);

        Todo deleted = service.deleteById(id);
        LOGGER.debug("Deleted to-do entry with information: {}", deleted);

        return createDTO(deleted);
    }
View Full Code Here

    @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.GET)
    @ResponseBody
    public TodoDTO findById(@PathVariable("id") Long id) throws TodoNotFoundException {
        LOGGER.debug("Finding to-do entry with id: {}", id);

        Todo found = service.findById(id);
        LOGGER.debug("Found to-do entry with information: {}", found);

        return createDTO(found);
    }
View Full Code Here

    @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.PUT)
    @ResponseBody
    public TodoDTO update(@Valid @RequestBody TodoDTO dto, @PathVariable("id") Long todoId) throws TodoNotFoundException {
        LOGGER.debug("Updating a to-do entry with information: {}", dto);

        Todo updated = service.update(dto);
        LOGGER.debug("Updated the information of a to-entry to: {}", updated);

        return createDTO(updated);
    }
View Full Code Here

        ArgumentCaptor<Todo> toDoArgument = ArgumentCaptor.forClass(Todo.class);
        verify(repositoryMock, times(1)).save(toDoArgument.capture());
        verifyNoMoreInteractions(repositoryMock);

        Todo model = toDoArgument.getValue();

        assertNull(model.getId());
        assertThat(model.getDescription(), is(dto.getDescription()));
        assertThat(model.getTitle(), is(dto.getTitle()));
    }
View Full Code Here

        assertThat(model.getTitle(), is(dto.getTitle()));
    }

    @Test
    public void deleteById_TodoEntryFound_ShouldDeleteTodoEntryAndReturnIt() throws TodoNotFoundException {
        Todo model = new TodoBuilder()
                .id(ID)
                .description(DESCRIPTION)
                .title(TITLE)
                .build();

        when(repositoryMock.findOne(ID)).thenReturn(model);

        Todo actual = service.deleteById(ID);

        verify(repositoryMock, times(1)).findOne(ID);
        verify(repositoryMock, times(1)).delete(model);
        verifyNoMoreInteractions(repositoryMock);
View Full Code Here

        assertThat(actual, is(models));
    }

    @Test
    public void findById_TodoEntryFound_ShouldReturnFoundTodoEntry() throws TodoNotFoundException {
        Todo model = new TodoBuilder()
                .id(ID)
                .description(DESCRIPTION)
                .title(TITLE)
                .build();

        when(repositoryMock.findOne(ID)).thenReturn(model);

        Todo actual = service.findById(ID);

        verify(repositoryMock, times(1)).findOne(ID);
        verifyNoMoreInteractions(repositoryMock);

        assertThat(actual, is(model));
View Full Code Here

                .id(ID)
                .description(DESCRIPTION_UPDATED)
                .title(TITLE_UPDATED)
                .build();

        Todo model = new TodoBuilder()
                .id(ID)
                .description(DESCRIPTION)
                .title(TITLE)
                .build();

        when(repositoryMock.findOne(dto.getId())).thenReturn(model);

        Todo actual = service.update(dto);

        verify(repositoryMock, times(1)).findOne(dto.getId());
        verifyNoMoreInteractions(repositoryMock);

        assertThat(model.getId(), is(dto.getId()));
View Full Code Here

        if (result.hasErrors()) {
            LOGGER.debug("Add to-do form was submitted with binding errors. Rendering form view.");
            return VIEW_TODO_ADD;
        }

        Todo added = service.add(dto);
        LOGGER.debug("Added a to-do entry with information: {}", added);

        addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_TODO_ADDED, added.getTitle());
        attributes.addAttribute(PARAMETER_TODO_ID, added.getId());

        return createRedirectViewPath(REQUEST_MAPPING_TODO_VIEW);
    }
View Full Code Here

TOP

Related Classes of net.petrikainulainen.spring.testmvc.todo.model.Todo

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.