@@ -0,0 +1,2400 @@
+package net.notejam.spring.note;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.security.test.context.support.WithMockUser;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0A%0Aimport net.notejam.spring.pad.Pad;%0Aimport net.notejam.spring.pad.PadService;%0Aimport net.notejam.spring.test.IntegrationTest;%0Aimport net.notejam.spring.user.UserService;%0A%0A/**%0A * An integration test for the %7B@link NoteService%7D.%0A *%0A * @author markus@malkusch.de%0A * @see %3Ca href=%22bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK%22%3EDonations%3C/a%3E%0A */%0A@IntegrationTest%0A@RunWith(SpringJUnit4ClassRunner.class)%0Apublic class NoteServiceTest %7B%0A%0A    @Autowired%0A    private UserService userService;%0A%0A    @Autowired%0A    private PadService padService;%0A%0A    @Autowired%0A    private NoteService service;%0A%0A    /**%0A     * Tests saveNote() without pad.%0A     */%0A    @Test%0A    @WithMockUser(%22testSaveNote@example.net%22)%0A    public void testSaveNoteWithoutPad() %7B%0A        userService.signUp(%22testSaveNote@example.net%22, %22password%22);%0A%0A        Note note = service.buildNote(null);%0A        note.setName(%22name%22);%0A        note.setText(%22text%22);%0A%0A        service.saveNote(note, null);%0A%0A        assertEquals(note, service.getNote(note.getId()).get());%0A    %7D%0A%0A    /**%0A     * Tests saveNote() with pad.%0A     */%0A    @Test%0A    @WithMockUser(%22testSaveNote2@example.net%22)%0A    public void testSaveNoteWithPad() %7B%0A        userService.signUp(%22testSaveNote2@example.net%22, %22password%22);%0A%0A        Pad pad = padService.buildPad();%0A        pad.setName(%22test%22);%0A        padService.savePad(pad);%0A%0A        Note note = service.buildNote(pad.getId());%0A        note.setName(%22name%22);%0A        note.setText(%22text%22);%0A%0A        service.saveNote(note, pad);%0A%0A        assertEquals(note, service.getNote(note.getId()).get());%0A    %7D%0A%0A    /**%0A     * Tests deleteNote().%0A     */%0A    @Test%0A    @WithMockUser(%22deleteNote@example.net%22)%0A    public void testDeleteNote() %7B%0A        userService.signUp(%22deleteNote@example.net%22, %22password%22);%0A%0A        Note note = service.buildNote(null);%0A        note.setName(%22name%22);%0A        note.setText(%22text%22);%0A%0A        service.saveNote(note, null);%0A%0A        service.deleteNote(note);%0A        assertFalse(service.getNote(note.getId()).isPresent());%0A    %7D%0A%0A%7D%0A

Test NoteService