@Test public void testLoginUser() throws Exception { User user = createUser(); api.createUser(user); String token = api.loginUser(user.getUsername(), user.getPassword()); assertTrue(token.startsWith("logged in user session:")); }
@Test public void testCreateUser() throws Exception { User user = createUser(); api.createUser(user); User fetched = api.getUserByName(user.getUsername()); assertEquals(user.getId(), fetched.getId()); }
private User createUser() { User user = new User(); user.setId(System.currentTimeMillis()); user.setUsername("fred"); user.setFirstName("Fred"); user.setLastName("Meyer"); user.setEmail("*****@*****.**"); user.setPassword("xxXXxx"); user.setPhone("408-867-5309"); user.setUserStatus(123); return user; }
@Test public void testCreateUsersWithList() throws Exception { User user1 = createUser(); user1.setUsername("abc123"); User user2 = createUser(); user2.setUsername("123abc"); api.createUsersWithListInput(Arrays.asList(new User[] {user1, user2})); User fetched = api.getUserByName(user1.getUsername()); assertEquals(user1.getId(), fetched.getId()); }