/** Test of method {@link HelloWorldService#retrieveAll()}. */ @Test public void testRetrieveAll() { // Mock result List<HelloWorld> mockResult = new ArrayList<HelloWorld>(); HelloWorld mockHello = new HelloWorld(); mockHello.setFirstName("first name"); mockHello.setLastName("last name"); mockResult.add(mockHello); // Mock call method Mockito.when(mockHelloWorldDao.retrieveAll()).thenReturn(mockResult); // Call service List<HelloWorld> result = helloWorldService.retrieveAll(); Assert.assertNotNull(result); Assert.assertEquals(1, result.size()); Assert.assertEquals("first name", result.get(0).getFirstName()); Assert.assertEquals("last name", result.get(0).getLastName()); }
/** Init. */ @Before public void init() { helloWorldService = new HelloWorldServiceImpl(); helloWorldService.setHelloWorldDao(mockHelloWorldDao); }