@Test public void testGetTopic() throws NotFoundException { Topic expectedTopic = new Topic(user, "title"); when(topicDao.isExist(999L)).thenReturn(true); when(topicDao.get(999L)).thenReturn(expectedTopic); int viewsCount = expectedTopic.getViews(); Topic actualTopic = topicFetchService.get(999L); assertEquals(actualTopic.getViews(), viewsCount + 1); assertEquals(actualTopic, expectedTopic, "Topics aren't equal"); verify(topicDao).isExist(999L); verify(topicDao).get(999L); }