UserDetailService { public List<UserDetail> getAllUsers() { EntityManager newEm = emf.createEntityManager(); EntityTransaction newTx = newEm.getTransaction(); newTx.begin(); List users = newEm.createQuery("from UserDetail").getResultList(); newTx.commit(); return users; } UserDetailService(); UserDetail getUserDetail(Long userId); void saveUserDetail(UserDetail userDetail); List<UserDetail> getAllUsers();  }
@Test public void shouldGetAllUsers() throws Exception { List<UserDetail> users = userDetailService.getAllUsers(); assertNotNull(users); assertEquals(3, users.size()); assertEquals("user1", users.get(0).getName()); }