@Test
  public void testFindUser() throws Exception {

    // Stub the value that will returned on call to userService.findUserByName
    User stubbedUser = new User("userAfterSave");
    Mockito.when(userService.findUserByName("user1")).thenReturn(stubbedUser);

    // make the call
    User user = userManager.findUser("user1");

    // Verify if findUserByName method was invoked on userService call
    Mockito.verify(userService).findUserByName("user1");

    Assert.assertEquals("userAfterSave", user.getUserName());
  }
Ejemplo n.º 2
0
  @Test
  public void getReporter() {
    Issue issue = new Issue(null, Utils.getTestIssue());
    assertNotNull(issue.getReporter());

    User reporter = issue.getReporter();

    assertEquals(reporter.getDisplayName(), "Joseph McCarthy");
    assertEquals(reporter.getName(), "joseph");
    assertTrue(reporter.isActive());
    assertEquals(reporter.getEmail(), "*****@*****.**");

    Map<String, String> avatars = reporter.getAvatarUrls();

    assertNotNull(avatars);
    assertEquals(avatars.size(), 4);

    assertEquals(
        "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=16",
        avatars.get("16x16"));
    assertEquals(
        "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=24",
        avatars.get("24x24"));
    assertEquals(
        "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=32",
        avatars.get("32x32"));
    assertEquals(
        "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=48",
        avatars.get("48x48"));
  }