@Test public void test_applyPreviousValue() { List<User> filteredList = Lists.newArrayList(new User("Fede", 20), new User("Peter", 12), new User("John", 41)); Function<User, User> getType = new Function<User, User>() { public User apply(User input) { input.setName(input.getName()+"someValue"); return input; } }; Collection<User> result = Collections2.transform(filteredList, getType); System.out.println(result); }
public class MyApplication{ public static void main(String[] args){ User user = new User("Tom"); System.out.println(user.getName()); } }
User bob = new User("Bob"); if (bob.equals("Bob")) { ... }
public class Datasource { public Observable<List<User>> users() { return Observable.just(Arrays.asList( new User("1", "Foo"), new User("2", "Bar") )); } public Observable<List<Pet>> pets(User user) { return Observable.just(Arrays.asList( new Pet(user.getName() + "'s cat"), new Pet(user.getName() + "'s dog") )); } }
for(int counter = 0; counter<userList.length; counter++) { User obj = new User(); obj.getName(); }
User john = new User("John"); String johnsName = john.getName();
public static void main(String args[]) { User u = new User(); u.setName("pradeep"); User u1 = new User(); u1.setName("Ajeet"); User u2 = new User(); u2.setName("sameer"); List<User> list = new ArrayList<User>(); list.add(u); list.add(u1); list.add(u2); Collections.sort(list); for (User user : list) { System.out.println(user.getName()); } }
Storage storage = new Storage(); User john = new User("John"); storage.put(john, 25); System.out.println(storage.get(new User("John"))); // we modify the reference which is used as a key in our map john.toUpperCase(); System.out.println(john.getName()); System.out.println(storage.get(new User("John")));
//following will create a user User user = new User("UserName1","password","type"); //following will add a user in setOf users SetOfUsers instance = new SetOfUsers(); instance.add(user); //so now you have a set of users having a user with name as "UserName1" now do following User result = instance.findUserByName("UserName1"); assertEquals("UserName1", result.getName());
private UserTransaction userTransactions = new UserTransaction(); private UserDao userDao = mock(UserDao.class); @Test public void testGet() { User user = new User(); user.setName("Raman"); // creating a custom expression List<Map<String,Object>> myList = new ArrayList<Map<String,Object>>(); Map<String,Object> map = new HashMap<String,Object>(); map.put("expression","eq"); map.put("property","name"); map.put("value","raman"); myList.add(map); // replacing exp with the list created userTransactions.setExp(myList); // return user when calling getByCriteria(myList) when(userDao.getByCriteria(myList)).thenReturn(user); ServiceResponse<User> response = userTransactions.get("raman"); User result = response.getResponse(); assertEquals("Raman", result.getName()); assertEquals(0, response.getErrors().size()); }
User user = new User(); user.setAge(25); user.setName("Shahid");
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import org.junit.*; public class LoginTest extends WebDriverTest /* This would be your own superclass, from which you inherit the WebDriver instance. */ { private User user = new User(); @Before public void setUp() { user.setName("Test Tommy"); user.setPassword("foobar"); } @Test public void userNameShouldBeShownAfterLogin() { // Go to your page and do the login, then wait for page load. String userNameOnPage = driver.findElement(By.id("usernameAfterLogin")); assertThat(userNameOnPage, is(equalTo(user.getName()))); } }