Search in sources :

Example 1 with DisabledReviewDb

use of com.google.gerrit.testutil.DisabledReviewDb in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method prepopulatedFields.

@Test
public void prepopulatedFields() throws Exception {
    assume().that(notesMigration.readChanges()).isFalse();
    TestRepository<Repo> repo = createProject("repo");
    Change change = insert(repo, newChange(repo));
    db = new DisabledReviewDb();
    requestContext.setContext(newRequestContext(userId));
    // Use QueryProcessor directly instead of API so we get ChangeDatas back.
    List<ChangeData> cds = queryProcessor.query(queryBuilder.parse(change.getId().toString())).entities();
    assertThat(cds).hasSize(1);
    ChangeData cd = cds.get(0);
    cd.change();
    cd.patchSets();
    cd.currentApprovals();
    cd.changedLines();
    cd.reviewedBy();
    cd.reviewers();
    cd.unresolvedCommentCount();
    // TODO(dborowitz): Swap out GitRepositoryManager somehow? Will probably be
    // necessary for NoteDb anyway.
    cd.isMergeable();
    exception.expect(DisabledReviewDb.Disabled.class);
    cd.messages();
}
Also used : Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) Change(com.google.gerrit.reviewdb.client.Change) DisabledReviewDb(com.google.gerrit.testutil.DisabledReviewDb) Test(org.junit.Test)

Example 2 with DisabledReviewDb

use of com.google.gerrit.testutil.DisabledReviewDb in project gerrit by GerritCodeReview.

the class AcceptanceTestRequestScope method disableDb.

public Context disableDb() {
    Context old = current.get();
    SchemaFactory<ReviewDb> sf = new SchemaFactory<ReviewDb>() {

        @Override
        public ReviewDb open() {
            return new DisabledReviewDb();
        }
    };
    Context ctx = new Context(sf, old.session, old.user, old.created);
    current.set(ctx);
    local.setContext(ctx);
    return old;
}
Also used : RequestContext(com.google.gerrit.server.util.RequestContext) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext) SchemaFactory(com.google.gwtorm.server.SchemaFactory) DisabledReviewDb(com.google.gerrit.testutil.DisabledReviewDb) ReviewDb(com.google.gerrit.reviewdb.server.ReviewDb) DisabledReviewDb(com.google.gerrit.testutil.DisabledReviewDb)

Example 3 with DisabledReviewDb

use of com.google.gerrit.testutil.DisabledReviewDb in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method prepopulateOnlyRequestedFields.

@Test
public void prepopulateOnlyRequestedFields() throws Exception {
    assume().that(notesMigration.readChanges()).isFalse();
    TestRepository<Repo> repo = createProject("repo");
    Change change = insert(repo, newChange(repo));
    db = new DisabledReviewDb();
    requestContext.setContext(newRequestContext(userId));
    // Use QueryProcessor directly instead of API so we get ChangeDatas back.
    List<ChangeData> cds = queryProcessor.setRequestedFields(ImmutableSet.of(ChangeField.PATCH_SET.getName(), ChangeField.CHANGE.getName())).query(queryBuilder.parse(change.getId().toString())).entities();
    assertThat(cds).hasSize(1);
    ChangeData cd = cds.get(0);
    cd.change();
    cd.patchSets();
    exception.expect(DisabledReviewDb.Disabled.class);
    cd.currentApprovals();
}
Also used : Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) Change(com.google.gerrit.reviewdb.client.Change) DisabledReviewDb(com.google.gerrit.testutil.DisabledReviewDb) Test(org.junit.Test)

Aggregations

DisabledReviewDb (com.google.gerrit.testutil.DisabledReviewDb)3 Change (com.google.gerrit.reviewdb.client.Change)2 Repo (com.google.gerrit.testutil.InMemoryRepositoryManager.Repo)2 Test (org.junit.Test)2 ReviewDb (com.google.gerrit.reviewdb.server.ReviewDb)1 RequestContext (com.google.gerrit.server.util.RequestContext)1 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)1 SchemaFactory (com.google.gwtorm.server.SchemaFactory)1