Package org.sonar.server.activity.index

Examples of org.sonar.server.activity.index.ActivityQuery


    this.save(session, ActivityDto.createFor(log)
      .setType(type));
  }

  public ActivityQuery newActivityQuery() {
    return new ActivityQuery();
  }
View Full Code Here


    SearchOptions.definePageParams(action);
  }

  @Override
  public void handle(Request request, Response response) {
    ActivityQuery query = logService.newActivityQuery();
    SearchOptions searchOptions = SearchOptions.create(request);
    QueryContext queryContext = mapping.newQueryOptions(searchOptions);

    Result<Activity> results = logService.search(query, queryContext);
View Full Code Here

  @Override
  public void handle(Request request, Response response) {
    checkUserRights();

    ActivityQuery query = logService.newActivityQuery();
    query.setTypes(Arrays.asList(Activity.Type.ANALYSIS_REPORT));

    SearchOptions searchOptions = SearchOptions.create(request);
    QueryContext queryContext = mapping.newQueryOptions(searchOptions);

    Result<Activity> results = logService.search(query, queryContext);
View Full Code Here

  @Test
  public void current_time_zone() {
    service.write(dbSession, Activity.Type.QPROFILE, "now");
    dbSession.commit();

    Activity activity = service.search(new ActivityQuery(), new QueryContext()).getHits().get(0);
    assertThat(System.currentTimeMillis() - activity.time().getTime()).isLessThan(1000L);
  }
View Full Code Here

    assertThat(dao.findAll(dbSession)).hasSize(max);
    assertThat(index.findAll().getHits()).hasSize(max);

    // 2. assert scrollable
    int count = 0;
    SearchResponse result = index.search(new ActivityQuery(), new QueryContext().setScroll(true));
    Iterator<Activity> logs = new Result<Activity>(index, result).scroll();
    while (logs.hasNext()) {
      logs.next();
      count++;
    }
    assertThat(count).isEqualTo(max);

    // 3 assert synchronize above IndexQueue threshold
    tester.clearIndexes();
    tester.get(Platform.class).executeStartupTasks();
    result = index.search(new ActivityQuery(), new QueryContext().setScroll(true));
    logs = new Result<Activity>(index, result).scroll();
    count = 0;
    while (logs.hasNext()) {
      logs.next();
      count++;
View Full Code Here

    assertThat(dao.findAll(dbSession)).hasSize(max);
    assertThat(index.findAll().getHits()).hasSize(max);

    // 2. assert scrollable
    int count = 0;
    SearchResponse result = index.search(new ActivityQuery(), new QueryContext().setScroll(true));
    Iterator<Activity> logs = new Result<Activity>(index, result).scroll();
    while (logs.hasNext()) {
      logs.next();
      count++;
    }
    assertThat(count).isEqualTo(max);

    // 3 assert synchronize above IndexQueue threshold
    tester.clearIndexes();
    tester.get(Platform.class).executeStartupTasks();
    result = index.search(new ActivityQuery(), new QueryContext().setScroll(true));
    logs = new Result<Activity>(index, result).scroll();
    count = 0;
    while (logs.hasNext()) {
      logs.next();
      count++;
View Full Code Here

    service.write(dbSession, Activity.Type.SERVER, getActivity());
    service.write(dbSession, Activity.Type.SERVER, testValue);
    service.write(dbSession, Activity.Type.QPROFILE, getActivity());
    dbSession.commit();

    assertThat(service.search(new ActivityQuery(),
      new QueryContext()).getHits()).hasSize(4);

    assertThat(service.search(new ActivityQuery()
      .setTypes(ImmutableSet.of(Activity.Type.SERVER)),
      new QueryContext()).getHits()).hasSize(2);

    assertThat(service.search(new ActivityQuery()
      .setTypes(ImmutableSet.of(Activity.Type.QPROFILE)),
      new QueryContext()).getHits()).hasSize(1);
  }
View Full Code Here

    activity.setCreatedAt(t1.toDate());
    dao.insert(dbSession, activity);
    dbSession.commit();
    DateTime t2 = new DateTime().plusHours(1);

    assertThat(service.search(new ActivityQuery(),
      new QueryContext()).getHits()).hasSize(3);

    assertThat(service.search(new ActivityQuery()
      .setSince(t0.minusSeconds(5).toDate()),
      new QueryContext()).getHits()).hasSize(3);

    assertThat(service.search(new ActivityQuery()
      .setSince(t1.minusSeconds(5).toDate()),
      new QueryContext()).getHits()).hasSize(1);

    assertThat(service.search(new ActivityQuery()
      .setSince(t2.minusSeconds(5).toDate()),
      new QueryContext()).getHits()).hasSize(0);

    assertThat(service.search(new ActivityQuery()
      .setTo(t1.minusSeconds(5).toDate()),
      new QueryContext()).getHits()).hasSize(2);

    assertThat(service.search(new ActivityQuery()
      .setSince(t1.minusSeconds(5).toDate())
      .setTo(t2.plusSeconds(5).toDate()),
      new QueryContext()).getHits()).hasSize(1);
  }
View Full Code Here

TOP

Related Classes of org.sonar.server.activity.index.ActivityQuery

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.