Package org.sonar.server.user

Examples of org.sonar.server.user.MockUserSession


      .assertJson(getClass(), "logged_in_page.json");
  }

  @Test
  public void logged_in_app_with_favorites() throws Exception {
    MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123);
    when(service.findFavoriteFilters(session)).thenReturn(Arrays.asList(
      new DefaultIssueFilter().setId(6L).setName("My issues"),
      new DefaultIssueFilter().setId(13L).setName("Blocker issues")
    ));
    tester.newGetRequest("api/issue_filters", "app").execute()
View Full Code Here


      .assertJson(getClass(), "logged_in_page_with_favorites.json");
  }

  @Test
  public void logged_in_app_with_selected_filter() throws Exception {
    MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123);
    when(service.find(13L, session)).thenReturn(
      new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("eric")
    );

    tester.newGetRequest("api/issue_filters", "app").setParam("id", "13").execute()
View Full Code Here

  }

  @Test
  public void app_selected_filter_can_not_be_modified() throws Exception {
    // logged-in user is 'eric' but filter is owned by 'simon'
    MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none");
    when(service.find(13L, session)).thenReturn(
      new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("simon").setShared(true)
    );

    tester.newGetRequest("api/issue_filters", "app").setParam("id", "13").execute()
View Full Code Here

      .assertJson("{'favoriteFilters': []}");
  }

  @Test
  public void favorites_of_logged_in_user() throws Exception {
    MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123);
    when(service.findFavoriteFilters(session)).thenReturn(Arrays.asList(
      new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("simon").setShared(true)
    ));

    tester.newGetRequest("api/issue_filters", "favorites").execute()
View Full Code Here

  }

  @Test
  public void show_filter() throws Exception {
    // logged-in user is 'eric' but filter is owned by 'simon'
    MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none");
    when(service.find(13L, session)).thenReturn(
      new DefaultIssueFilter().setId(13L).setName("Blocker issues").setDescription("All Blocker Issues").setData("severity=BLOCKER").setUser("simon").setShared(true)
    );

    tester.newGetRequest("api/issue_filters", "show").setParam("id", "13").execute()
View Full Code Here

      .assertJson(getClass(), "show_filter.json");
  }

  @Test
  public void show_unknown_filter() throws Exception {
    MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none");
    when(service.find(42L, session)).thenThrow(new NotFoundException("Filter 42 does not exist"));

    try {
      tester.newGetRequest("api/issue_filters", "show").setParam("id", "42").execute();
      fail();
View Full Code Here

TOP

Related Classes of org.sonar.server.user.MockUserSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.