@Test
  public void prepopulatedFields() throws Exception {
    assume().that(notesMigration.enabled()).isFalse();
    TestRepository<Repo> repo = createProject("repo");
    Change change = newChange(repo, null, null, null, null).insert();

    db = new DisabledReviewDb();
    requestContext.setContext(newRequestContext(userId));
    // Use QueryProcessor directly instead of API so we get ChangeDatas back.
    List<ChangeData> cds =
        queryProcessor.queryChanges(queryBuilder.parse(change.getId().toString())).changes();
    assertThat(cds).hasSize(1);

    ChangeData cd = cds.get(0);
    cd.change();
    cd.patchSets();
    cd.currentApprovals();
    cd.changedLines();
    cd.reviewedBy();

    // TODO(dborowitz): Swap out GitRepositoryManager somehow? Will probably be
    // necessary for notedb anyway.
    cd.isMergeable();

    // Don't use ExpectedException since that wouldn't distinguish between
    // failures here and on the previous calls.
    try {
      cd.messages();
    } catch (AssertionError e) {
      assertThat(e.getMessage()).isEqualTo(DisabledReviewDb.MESSAGE);
    }
  }
Example #2
0
 private List<List<ChangeInfo>> query0() throws OrmException, QueryParseException {
   int cnt = queries.size();
   List<QueryResult> results = imp.queryChanges(qb.parse(queries));
   List<List<ChangeInfo>> res = json.create(options).formatQueryResults(results);
   for (int n = 0; n < cnt; n++) {
     List<ChangeInfo> info = res.get(n);
     if (results.get(n).moreChanges()) {
       info.get(info.size() - 1)._moreChanges = true;
     }
   }
   return res;
 }