@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); } }
public List<ChangeData> query(Predicate<ChangeData> p) throws OrmException { try { return qp.queryChanges(p).changes(); } catch (QueryParseException e) { throw new OrmException(e); } }
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; }
@VisibleForTesting Iterable<ChangeData> byCommitsOnBranchNotMerged( Schema<ChangeData> schema, Branch.NameKey branch, List<String> hashes, int batchSize) throws OrmException { List<Predicate<ChangeData>> commits = commits(schema, hashes); int numBatches = (hashes.size() / batchSize) + 1; List<Predicate<ChangeData>> queries = new ArrayList<>(numBatches); for (List<Predicate<ChangeData>> batch : Iterables.partition(commits, batchSize)) { queries.add(commitsOnBranchNotMerged(branch, batch)); } try { return FluentIterable.from(qp.queryChanges(queries)) .transformAndConcat( new Function<QueryResult, List<ChangeData>>() { @Override public List<ChangeData> apply(QueryResult in) { return in.changes(); } }); } catch (QueryParseException e) { throw new OrmException(e); } }