@Test public void delete() { // setup mockNoteBookService.delete(TEST_NOTEBOOK_ID); EasyMock.expectLastCall(); EasyMock.replay(mockNoteBookService); // method under test controller.delete(TEST_NOTEBOOK_ID); // check results EasyMock.verify(mockNoteBookService); }
@Test public void get() { // setup EasyMock.expect(mockNoteBookService.findById(TEST_NOTEBOOK_ID)).andReturn(noteBook); EasyMock.replay(mockNoteBookService); // method under test NoteBook actual = controller.get(TEST_NOTEBOOK_ID); // check results assertNotNull(actual); assertEquals(noteBook.getName(), actual.getName()); EasyMock.verify(mockNoteBookService); }
@Test public void post() { // setup EasyMock.expect(mockNoteBookService.create(noteBook)).andReturn(noteBook); EasyMock.replay(mockNoteBookService); // method under test NoteBook actual = controller.post(noteBook); // check results assertNotNull(actual); assertNotNull(actual.getId()); assertEquals(noteBook.getName(), actual.getName()); EasyMock.verify(mockNoteBookService); }
@Test public void getAll() { // setup List<NoteBook> noteBooks = new ArrayList<NoteBook>(1); noteBooks.add(noteBook); EasyMock.expect(mockNoteBookService.findAll()).andReturn(noteBooks); EasyMock.replay(mockNoteBookService); // method under test List<NoteBook> actual = controller.getAll(); // check results assertNotNull(actual); assertEquals(1, actual.size()); EasyMock.verify(mockNoteBookService); }