本文整理汇总了Java中com.google.gerrit.extensions.api.GerritApi类的典型用法代码示例。如果您正苦于以下问题:Java GerritApi类的具体用法?Java GerritApi怎么用?Java GerritApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GerritApi类属于com.google.gerrit.extensions.api包,在下文中一共展示了GerritApi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ServerContext
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
private ServerContext(GerritServer server) throws Exception {
this.server = server;
Injector i = server.getTestInjector();
if (adminId == null) {
adminId = i.getInstance(AccountCreator.class).admin().getId();
}
ctx = i.getInstance(OneOffRequestContext.class).openAs(adminId);
GerritApi gApi = i.getInstance(GerritApi.class);
try {
// ServerContext ctor is called multiple times but the group can be only created once
gApi.groups().id("Group");
} catch (ResourceNotFoundException e) {
GroupInput in = new GroupInput();
in.members = Collections.singletonList("admin");
in.name = "Group";
gApi.groups().create(in);
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:StandaloneSiteTest.java
示例2: setUpChange
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
private void setUpChange() throws Exception {
project = new Project.NameKey("project");
try (ServerContext ctx = startServer()) {
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
gApi.projects().create(project.get());
ChangeInput in = new ChangeInput(project.get(), "master", "Test change");
in.newBranch = true;
changeId = gApi.changes().create(in).info().changeId;
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:ReindexIT.java
示例3: configure
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Override
protected void configure() {
bind(GerritApi.class).to(GerritApiImpl.class);
install(new com.google.gerrit.server.api.accounts.Module());
install(new com.google.gerrit.server.api.changes.Module());
install(new com.google.gerrit.server.api.config.Module());
install(new com.google.gerrit.server.api.groups.Module());
install(new com.google.gerrit.server.api.projects.Module());
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:Module.java
示例4: reindexFromScratch
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test
public void reindexFromScratch() throws Exception {
setUpChange();
MoreFiles.deleteRecursively(sitePaths.index_dir, RecursiveDeleteOption.ALLOW_INSECURE);
Files.createDirectory(sitePaths.index_dir);
assertServerStartupFails();
runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace");
assertReady(ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion());
try (ServerContext ctx = startServer()) {
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
// Query change index
assertThat(gApi.changes().query("message:Test").get().stream().map(c -> c.changeId))
.containsExactly(changeId);
// Query account index
assertThat(gApi.accounts().query("admin").get().stream().map(a -> a._accountId))
.containsExactly(adminId.get());
// Query group index
assertThat(
gApi.groups()
.query("Group")
.withOption(MEMBERS)
.get()
.stream()
.flatMap(g -> g.members.stream())
.map(a -> a._accountId))
.containsExactly(adminId.get());
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:ReindexIT.java
示例5: migrateOneChange
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test
public void migrateOneChange() throws Exception {
assertNoAutoMigrateConfig(gerritConfig);
assertNoAutoMigrateConfig(noteDbConfig);
assertNotesMigrationState(NotesMigrationState.REVIEW_DB);
setUpOneChange();
migrate();
assertNotesMigrationState(NotesMigrationState.NOTE_DB);
try (ServerContext ctx = startServer()) {
GitRepositoryManager repoManager = ctx.getInjector().getInstance(GitRepositoryManager.class);
try (Repository repo = repoManager.openRepository(project)) {
assertThat(repo.exactRef(RefNames.changeMetaRef(changeId))).isNotNull();
}
try (ReviewDb db = openUnderlyingReviewDb(ctx)) {
Change c = db.changes().get(changeId);
assertThat(c).isNotNull();
NoteDbChangeState state = NoteDbChangeState.parse(c);
assertThat(state).isNotNull();
assertThat(state.getPrimaryStorage()).isEqualTo(PrimaryStorage.NOTE_DB);
assertThat(state.getRefState()).isEmpty();
ChangeInput in = new ChangeInput(project.get(), "master", "NoteDb-only change");
in.newBranch = true;
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
Change.Id id2 = new Change.Id(gApi.changes().create(in).info()._number);
assertThat(db.changes().get(id2)).isNull();
}
}
assertNoAutoMigrateConfig(gerritConfig);
assertAutoMigrateConfig(noteDbConfig, false);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:35,代码来源:StandaloneNoteDbMigrationIT.java
示例6: setUpOneChange
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
private void setUpOneChange() throws Exception {
project = new Project.NameKey("project");
try (ServerContext ctx = startServer()) {
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
gApi.projects().create("project");
ChangeInput in = new ChangeInput(project.get(), "master", "Test change");
in.newBranch = true;
changeId = new Change.Id(gApi.changes().create(in).info()._number);
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:StandaloneNoteDbMigrationIT.java
示例7: testInvalidHost
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test(expectedExceptions = RestApiException.class)
public void testInvalidHost() throws Exception {
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritAuthData.Basic authData = new GerritAuthData.Basic("http://averyinvaliddomainforgerritresttest.com:8089");
GerritApi gerritClient = gerritRestApiFactory.create(authData);
gerritClient.changes().query().get();
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:8,代码来源:GerritRestClientTest.java
示例8: testUserAuth
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
/**
* Tests authentication with a login which us handled by HTTP auth (preemptive authentication is assumed)
* (path: "/a/changes/" isn't mapped -> status 404).
*/
@Test
public void testUserAuth() throws Exception {
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritApi gerritClient = gerritRestApiFactory.create(new GerritAuthData.Basic(jettyUrl, "foo", "bar"));
boolean catched = false;
try {
gerritClient.changes().query().get();
} catch (HttpStatusException e) {
catched = true;
// 404 because this url does not provide a valid response (not set up in this test case)
Truth.assertThat(e.getStatusCode()).isEqualTo(404);
}
Truth.assertThat(catched).isTrue();
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:19,代码来源:GerritRestClientTest.java
示例9: testInvalidUserAuth
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
/**
* Tests authentication with an invalid HTTP login (preemptive authentication is assumed). Status 401 expected.
*/
@Test
public void testInvalidUserAuth() throws Exception {
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritApi gerritClient = gerritRestApiFactory.create(new GerritAuthData.Basic(jettyUrl, "foox", "bar"));
boolean catched = false;
try {
gerritClient.changes().query().get();
} catch (HttpStatusException e) {
catched = true;
Truth.assertThat(e.getStatusCode()).isEqualTo(401);
Truth.assertThat(e.getStatusText().toLowerCase()).contains("unauthorized");
}
Truth.assertThat(catched).isTrue();
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:18,代码来源:GerritRestClientTest.java
示例10: testVersion
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test
public void testVersion() throws Exception {
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritApi gerritClient = gerritRestApiFactory.create(new GerritAuthData.Basic(jettyUrl));
String version = gerritClient.config().server().getVersion();
Truth.assertThat(version).isEqualTo("2.10");
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:8,代码来源:GerritRestClientTest.java
示例11: testBasicRestCallToLocalhost
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test(enabled = false) // requires running Gerrit instance
public void testBasicRestCallToLocalhost() throws Exception {
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritApi gerritClient = gerritRestApiFactory.create(new GerritAuthData.Basic("http://localhost:8080"));
List<ChangeInfo> changes = gerritClient.changes().query().get();
System.out.println(String.format("Got %s changes.", changes.size()));
System.out.println(changes);
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:9,代码来源:GerritRestClientTest.java
示例12: testBasicRestCallToLocalhostProjects
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test(enabled = false) // requires running Gerrit instance
public void testBasicRestCallToLocalhostProjects() throws Exception {
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritApi gerritClient = gerritRestApiFactory.create(new GerritAuthData.Basic("http://localhost:8080"));
List<ProjectInfo> projects = gerritClient.projects().list().get();
System.out.println(String.format("Got %s projects.", projects.size()));
System.out.println(projects);
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:9,代码来源:GerritRestClientTest.java
示例13: testBasicRestCallToLocalhostProjectsQuery
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test(enabled = false) // requires running Gerrit instance
public void testBasicRestCallToLocalhostProjectsQuery() throws Exception {
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritApi gerritClient = gerritRestApiFactory.create(new GerritAuthData.Basic("http://localhost:8080"));
List<ProjectInfo> projects = gerritClient.projects().list().withLimit(1).withDescription(true).get();
System.out.println(String.format("Got %s projects.", projects.size()));
System.out.println(projects);
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:9,代码来源:GerritRestClientTest.java
示例14: DefaultReviewers
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Inject
DefaultReviewers(
GerritApi gApi,
@Assisted Change change,
@Assisted Set<Account> reviewers) {
this.gApi = gApi;
this.change = change;
this.reviewers = reviewers;
}
开发者ID:davido,项目名称:gerrit-reviewers-plugin,代码行数:10,代码来源:DefaultReviewers.java
示例15: perform
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException {
List<ReportInfo> issueInfos = readSonarReports(listener, filePath);
if (issueInfos == null) {
throw new AbortException(getLocalized("jenkins.plugin.validation.path.no.project.config.available"));
}
Multimap<String, Issue> file2issues = generateFilenameToIssuesMapFilteredByPredicates(issueInfos);
// Step 3 - Prepare Gerrit REST API client
// Check Gerrit configuration is available
String gerritNameEnvVar = getEnvVar(run, listener, GERRIT_NAME_ENV_VAR_NAME);
GerritTrigger trigger = GerritTrigger.getTrigger(run.getParent());
String gerritServerName = gerritNameEnvVar != null ? gerritNameEnvVar : trigger != null ? trigger.getServerName() : null;
if (gerritServerName == null) {
throw new AbortException(getLocalized("jenkins.plugin.error.gerrit.server.empty"));
}
IGerritHudsonTriggerConfig gerritConfig = GerritManagement.getConfig(gerritServerName);
if (gerritConfig == null) {
throw new AbortException(getLocalized("jenkins.plugin.error.gerrit.config.empty"));
}
if (!gerritConfig.isUseRestApi()) {
throw new AbortException(getLocalized("jenkins.plugin.error.gerrit.restapi.off"));
}
if (gerritConfig.getGerritHttpUserName() == null) {
throw new AbortException(getLocalized("jenkins.plugin.error.gerrit.user.empty"));
}
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritAuthData.Basic authData = new GerritAuthData.Basic(
gerritConfig.getGerritFrontEndUrl(),
isOverrideCredentials() ? httpUsername : gerritConfig.getGerritHttpUserName(),
isOverrideCredentials() ? httpPassword : gerritConfig.getGerritHttpPassword(),
gerritConfig.isUseRestApi());
GerritApi gerritApi = gerritRestApiFactory.create(authData);
try {
String changeNStr = getEnvVar(run, listener, GERRIT_CHANGE_NUMBER_ENV_VAR_NAME);
if (changeNStr == null) {
throw new AbortException(getLocalized("jenkins.plugin.error.gerrit.change.number.empty"));
}
int changeNumber = Integer.parseInt(changeNStr);
String patchsetNStr = getEnvVar(run, listener, GERRIT_PATCHSET_NUMBER_ENV_VAR_NAME);
if (patchsetNStr == null) {
throw new AbortException(getLocalized("jenkins.plugin.error.gerrit.patchset.number.empty"));
}
int patchSetNumber = Integer.parseInt(patchsetNStr);
RevisionApi revision = gerritApi.changes().id(changeNumber).revision(patchSetNumber);
logMessage(listener, "jenkins.plugin.connected.to.gerrit", Level.INFO, new Object[]{gerritServerName, changeNumber, patchSetNumber});
// Step 4 - Filter issues by changed files
final Map<String, FileInfo> files = revision.files();
file2issues = Multimaps.filterKeys(file2issues, new Predicate<String>() {
@Override
public boolean apply(@Nullable String input) {
return input != null && files.keySet().contains(input);
}
});
// logResultMap(file2issues, "Filter issues by changed files: {0} elements");
if (isChangedLinesOnly()) {
// Step 4a - Filter issues by changed lines in file only
filterIssuesByChangedLines(file2issues, revision);
// logResultMap(file2issues, "Filter issues by changed lines: {0} elements");
}
// Step 6 - Send review to Gerrit
ReviewInput reviewInput = getReviewResult(file2issues);
// Step 7 - Post review
revision.review(reviewInput);
logMessage(listener, "jenkins.plugin.review.sent", Level.INFO);
} catch (RestApiException e) {
LOGGER.log(Level.SEVERE, "Unable to post review: " + e.getMessage(), e);
throw new AbortException("Unable to post review: " + e.getMessage());
}
}
开发者ID:aquarellian,项目名称:sonar-gerrit-plugin,代码行数:80,代码来源:SonarToGerritPublisher.java
示例16: onlineUpgradeChanges
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test
public void onlineUpgradeChanges() throws Exception {
int prevVersion = ChangeSchemaDefinitions.INSTANCE.getPrevious().getVersion();
int currVersion = ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion();
// Before storing any changes, switch back to the previous version.
GerritIndexStatus status = new GerritIndexStatus(sitePaths);
status.setReady(CHANGES, currVersion, false);
status.setReady(CHANGES, prevVersion, true);
status.save();
assertReady(prevVersion);
setOnlineUpgradeConfig(false);
setUpChange();
setOnlineUpgradeConfig(true);
IndexUpgradeController u = new IndexUpgradeController(1);
try (ServerContext ctx = startServer(u.module())) {
assertSearchVersion(ctx, prevVersion);
assertWriteVersions(ctx, prevVersion, currVersion);
// Updating and searching old schema version works.
Provider<InternalChangeQuery> queryProvider =
ctx.getInjector().getProvider(InternalChangeQuery.class);
assertThat(queryProvider.get().byKey(new Change.Key(changeId))).hasSize(1);
assertThat(queryProvider.get().byTopicOpen("topic1")).isEmpty();
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
gApi.changes().id(changeId).topic("topic1");
assertThat(queryProvider.get().byTopicOpen("topic1")).hasSize(1);
u.runUpgrades();
assertThat(u.getStartedAttempts())
.containsExactly(UpgradeAttempt.create(CHANGES, prevVersion, currVersion));
assertThat(u.getSucceededAttempts())
.containsExactly(UpgradeAttempt.create(CHANGES, prevVersion, currVersion));
assertThat(u.getFailedAttempts()).isEmpty();
assertReady(currVersion);
assertSearchVersion(ctx, currVersion);
assertWriteVersions(ctx, currVersion);
// Updating and searching new schema version works.
assertThat(queryProvider.get().byTopicOpen("topic1")).hasSize(1);
assertThat(queryProvider.get().byTopicOpen("topic2")).isEmpty();
gApi.changes().id(changeId).topic("topic2");
assertThat(queryProvider.get().byTopicOpen("topic1")).isEmpty();
assertThat(queryProvider.get().byTopicOpen("topic2")).hasSize(1);
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:51,代码来源:ReindexIT.java
示例17: ReviewerManager
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Inject
public ReviewerManager(GerritApi gApi, OneOffRequestContext requestContext) {
this.gApi = gApi;
this.requestContext = requestContext;
}
开发者ID:GerritCodeReview,项目名称:plugins_owners,代码行数:6,代码来源:ReviewerManager.java
示例18: GerritFacade
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
public GerritFacade(GerritApi gerritApi, GerritPatchset gerritPatchset) {
this.gerritApi = gerritApi;
this.gerritPatchset = gerritPatchset;
}
开发者ID:TouK,项目名称:sputnik,代码行数:5,代码来源:GerritFacade.java
示例19: testGetChanges
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test
public void testGetChanges() throws Exception {
GerritApi gerritClient = getGerritApiWithJettyHost();
List<ChangeInfo> changes = gerritClient.changes().query().get();
Truth.assertThat(changes.size()).isEqualTo(3);
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:7,代码来源:GerritRestClientTest.java
示例20: testGetSelfAccount
import com.google.gerrit.extensions.api.GerritApi; //导入依赖的package包/类
@Test
public void testGetSelfAccount() throws Exception {
GerritApi gerritClient = getGerritApiWithJettyHost();
AccountInfo accountInfo = gerritClient.accounts().self().get();
Truth.assertThat(accountInfo.name).isEqualTo("John Doe");
}
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:7,代码来源:GerritRestClientTest.java
注:本文中的com.google.gerrit.extensions.api.GerritApi类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论