@Test public void testGetUserName() { PowerMockito.mockStatic(GWT.class); PowerMockito.mockStatic(Window.class); when(Window.prompt(anyString(), anyString())).thenReturn("myUserName"); String userName = Authentication.getUserName(); when(Window.prompt(anyString(), anyString())).thenReturn("anotherUserName"); String userNameAfterSecondRequest = Authentication.getUserName(); Assert.assertNotNull(userName); Assert.assertEquals("myUserName", userName); Assert.assertNotNull(userNameAfterSecondRequest); Assert.assertEquals("myUserName", userNameAfterSecondRequest); }
public static String getUserName() { if (username == null) { String s = Window.prompt("What's your name?", ""); if ((s != null) && !s.isEmpty()) { username = s; } } return username; }
Authentication { public static String getUserName() { if (username == null) { String s = Window.prompt("What's your name?", ""); if ((s != null) && !s.isEmpty()) { username = s; } } return username; } }
Authentication { public static String getUserName() { if (username == null) { String s = Window.prompt("What's your name?", ""); if ((s != null) && !s.isEmpty()) { username = s; } } return username; }  }
Authentication { public static String getUserName() { if (username == null) { String s = Window.prompt("What's your name?", ""); if ((s != null) && !s.isEmpty()) { username = s; } } return username; }  static String getUserName(); }
Authentication { public static String getUserName() { if (username == null) { String s = Window.prompt("What's your name?", ""); if ((s != null) && !s.isEmpty()) { username = s; } } return username; }  static String getUserName();  }