use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class ProjectWatchIT method watchFile.
@Test
public void watchFile() throws Exception {
String watchedProject = createProject("watchedProject").get();
String otherWatchedProject = createProject("otherWatchedProject").get();
setApiUser(user);
// watch file in project as user
watch(watchedProject, "file:a.txt");
// watch other project as user
watch(otherWatchedProject, null);
// push a change to watched file -> should trigger email notification for
// user
setApiUser(admin);
TestRepository<InMemoryRepository> watchedRepo = cloneProject(new Project.NameKey(watchedProject), admin);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), watchedRepo, "TRIGGER", "a.txt", "a1").to("refs/for/master");
r.assertOkStatus();
// assert email notification for user
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(user.emailAddress);
assertThat(m.body()).contains("Change subject: TRIGGER\n");
assertThat(m.body()).contains("Gerrit-PatchSet: 1\n");
sender.clear();
// watch project as user2
TestAccount user2 = accounts.create("user2", "user2@test.com", "User2");
setApiUser(user2);
watch(watchedProject, null);
// push a change to non-watched file -> should not trigger email
// notification for user, only for user2
r = pushFactory.create(db, admin.getIdent(), watchedRepo, "TRIGGER_USER2", "b.txt", "b1").to("refs/for/master");
r.assertOkStatus();
// assert email notification
messages = sender.getMessages();
assertThat(messages).hasSize(1);
m = messages.get(0);
assertThat(m.rcpt()).containsExactly(user2.emailAddress);
assertThat(m.body()).contains("Change subject: TRIGGER_USER2\n");
assertThat(m.body()).contains("Gerrit-PatchSet: 1\n");
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class ProjectWatchIT method watchProjectNotifyOnDraftChange.
@Test
public void watchProjectNotifyOnDraftChange() throws Exception {
String watchedProject = createProject("watchedProject").get();
// create group that can view all drafts
GroupInfo groupThatCanViewDrafts = gApi.groups().create("groupThatCanViewDrafts").get();
grant(new Project.NameKey(watchedProject), "refs/*", Permission.VIEW_DRAFTS, false, new AccountGroup.UUID(groupThatCanViewDrafts.id));
// watch project as user that can't view drafts
setApiUser(user);
watch(watchedProject, null);
// watch project as user that can view all drafts
TestAccount userThatCanViewDrafts = accounts.create("user2", "user2@test.com", "User2", groupThatCanViewDrafts.name);
setApiUser(userThatCanViewDrafts);
watch(watchedProject, null);
// push a draft change to watched project -> should trigger email notification for
// userThatCanViewDrafts, but not for user
setApiUser(admin);
TestRepository<InMemoryRepository> watchedRepo = cloneProject(new Project.NameKey(watchedProject), admin);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), watchedRepo, "TRIGGER", "a", "a1").to("refs/for/master%draft");
r.assertOkStatus();
// assert email notification
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(userThatCanViewDrafts.emailAddress);
assertThat(m.body()).contains("Change subject: TRIGGER\n");
assertThat(m.body()).contains("Gerrit-PatchSet: 1\n");
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class BatchUpdateTest method setUp.
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(new InMemoryModule());
injector.injectMembers(this);
lifecycle = new LifecycleManager();
lifecycle.add(injector);
lifecycle.start();
try (ReviewDb underlyingDb = inMemoryDatabase.getDatabase().open()) {
schemaCreator.create(underlyingDb);
}
db = schemaFactory.open();
Account.Id userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
user = userFactory.create(userId);
project = new Project.NameKey("test");
InMemoryRepository inMemoryRepo = repoManager.createRepository(project);
repo = new TestRepository<>(inMemoryRepo);
requestContext.setContext(new RequestContext() {
@Override
public CurrentUser getUser() {
return user;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
});
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gitiles by GerritCodeReview.
the class PaginatorTest method setUp.
@Before
public void setUp() throws Exception {
repo = new TestRepository<>(new InMemoryRepository(new DfsRepositoryDescription("test")));
walk = new RevWalk(repo.getRepository());
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gitiles by GerritCodeReview.
the class RevisionParserTest method setUp.
@Before
public void setUp() throws Exception {
repo = new TestRepository<>(new InMemoryRepository(new DfsRepositoryDescription("test")));
parser = new RevisionParser(repo.getRepository(), new TestGitilesAccess(repo.getRepository()).forRequest(null), new VisibilityCache(false, CacheBuilder.newBuilder().maximumSize(0)));
}
Aggregations