Beispiel #1
0
 @Test
 public void testCreate() {
   when(jdoTemplate.makePersistent(user)).thenReturn(user);
   User result = userService.create(user);
   verify(jdoTemplate).makePersistent(user);
   assertEquals("bill", result.getName());
 }
Beispiel #2
0
 @Test
 public void testDelete() {
   when(jdoTemplate.getObjectById(User.class, user.getId())).thenReturn(user);
   Response result = userService.delete(user.getId());
   verify(jdoTemplate).getObjectById(User.class, user.getId());
   verify(jdoTemplate).deletePersistent(user);
   assertEquals(200, result.getStatus());
 }
Beispiel #3
0
 @Test
 public void testShow() {
   String filter = "id=='asa'";
   String queryString = "select from " + User.class.getName() + " where " + filter;
   when(jdoTemplate.find(queryString)).thenReturn(users);
   Collection<User> result = userService.show(filter);
   verify(jdoTemplate).find(queryString);
   assertEquals(1, result.size());
 }
Beispiel #4
0
 @Test
 public void testUpdate() {
   when(jdoTemplate.getObjectById(User.class, user.getId())).thenReturn(user);
   when(jdoTemplate.makePersistent(user)).thenReturn(user);
   User result = userService.update(user);
   verify(jdoTemplate).getObjectById(User.class, user.getId());
   verify(jdoTemplate).makePersistent(user);
   assertEquals("bill", result.getName());
 }
Beispiel #5
0
 @Before
 public void testSetup() {
   userService = new UserRestfulService(persistenceManagerFactory);
   userService.setJdoTemplate(jdoTemplate);
   user = new User();
   user.setId("asa");
   user.setName("bill");
   users = new ArrayList();
   users.add(user);
 }