Examples of DefaultIssueFilter


Examples of org.sonar.core.issue.DefaultIssueFilter

  }

  @Override
  public void handle(Request request, Response response) throws Exception {
    UserSession session = UserSession.get();
    DefaultIssueFilter filter = service.find(request.mandatoryParamAsLong("id"), session);

    JsonWriter json = response.newJsonWriter();
    json.beginObject();
    issueFilterWriter.write(session, filter, json);
    json.endObject();
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

  @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()
      .assertJson("{'favoriteFilters': [{'id': 13, 'name': 'Blocker issues', 'user': 'simon', 'shared': true}]}");
  }
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

  @Test
  public void should_find_by_id() {
    IssueFilterDto dto = new IssueFilterDto().setId(1L).setName("My Issue").setUserLogin("john");
    when(issueFilterDao.selectById(1L)).thenReturn(dto);

    DefaultIssueFilter issueFilter = service.findById(1L);
    assertThat(issueFilter).isNotNull();
    assertThat(issueFilter.id()).isEqualTo(1L);
  }
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

  @Test
  public void should_find_issue_filter() {
    IssueFilterDto issueFilterDto = new IssueFilterDto().setId(1L).setName("My Issue").setUserLogin("john");
    when(issueFilterDao.selectById(1L)).thenReturn(issueFilterDto);

    DefaultIssueFilter issueFilter = service.find(1L, userSession);
    assertThat(issueFilter).isNotNull();
    assertThat(issueFilter.id()).isEqualTo(1L);
  }
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

  @Test
  public void should_find_shared_filter_by_id() {
    IssueFilterDto issueFilterDto = new IssueFilterDto().setId(1L).setName("My Issue").setUserLogin("arthur").setShared(true);
    when(issueFilterDao.selectById(1L)).thenReturn(issueFilterDto);

    DefaultIssueFilter issueFilter = service.find(1L, userSession);
    assertThat(issueFilter).isNotNull();
    assertThat(issueFilter.id()).isEqualTo(1L);
  }
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

    }
  }

  @Test
  public void should_save() {
    DefaultIssueFilter issueFilter = new DefaultIssueFilter().setName("My Issue");
    DefaultIssueFilter result = service.save(issueFilter, userSession);
    assertThat(result.name()).isEqualTo("My Issue");
    assertThat(result.user()).isEqualTo("john");

    verify(issueFilterDao).insert(any(IssueFilterDto.class));
  }
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

    verify(issueFilterDao).insert(any(IssueFilterDto.class));
  }

  @Test
  public void should_add_favorite_on_save() {
    DefaultIssueFilter issueFilter = new DefaultIssueFilter().setName("My Issue");
    service.save(issueFilter, userSession);

    verify(issueFilterDao).insert(any(IssueFilterDto.class));
    verify(issueFilterFavouriteDao).insert(any(IssueFilterFavouriteDto.class));
  }
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

  @Test
  public void should_not_save_if_not_logged() {
    UserSession userSession = MockUserSession.create().setLogin(null);
    try {
      DefaultIssueFilter issueFilter = new DefaultIssueFilter().setName("My Issue");
      service.save(issueFilter, userSession);
      fail();
    } catch (Exception e) {
      assertThat(e).isInstanceOf(UnauthorizedException.class).hasMessage("User is not logged in");
    }
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

  @Test
  public void should_not_save_if_name_already_used() {
    when(issueFilterDao.selectByUser(eq("john"))).thenReturn(newArrayList(new IssueFilterDto().setId(1L).setName("My Issue")));
    try {
      DefaultIssueFilter issueFilter = new DefaultIssueFilter().setName("My Issue");
      service.save(issueFilter, userSession);
      fail();
    } catch (Exception e) {
      assertThat(e).isInstanceOf(BadRequestException.class).hasMessage("Name already exists");
    }
View Full Code Here

Examples of org.sonar.core.issue.DefaultIssueFilter

  @Test
  public void should_not_save_shared_filter_if_name_already_used_by_shared_filter() {
    when(issueFilterDao.selectByUser(eq("john"))).thenReturn(Collections.<IssueFilterDto>emptyList());
    when(issueFilterDao.selectSharedFilters()).thenReturn(newArrayList(new IssueFilterDto().setId(1L).setName("My Issue").setUserLogin("henry").setShared(true)));
    DefaultIssueFilter issueFilter = new DefaultIssueFilter().setName("My Issue").setShared(true);
    try {
      service.save(issueFilter, userSession);
      fail();
    } catch (Exception e) {
      assertThat(e).isInstanceOf(BadRequestException.class).hasMessage("Other users already share filters with the same name");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.