当前位置: 首页>>代码示例>>Java>>正文


Java ChangeApi类代码示例

本文整理汇总了Java中com.google.gerrit.extensions.api.changes.ChangeApi的典型用法代码示例。如果您正苦于以下问题:Java ChangeApi类的具体用法?Java ChangeApi怎么用?Java ChangeApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChangeApi类属于com.google.gerrit.extensions.api.changes包,在下文中一共展示了ChangeApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cherryPickSetChangeId

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void cherryPickSetChangeId() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master");
  CherryPickInput in = new CherryPickInput();
  in.destination = "foo";
  String id = "Ideadbeefdeadbeefdeadbeefdeadbeefdeadbe3f";
  in.message = "it goes to foo branch\n\nChange-Id: " + id;

  gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
  ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());

  assertThat(orig.get().messages).hasSize(1);
  ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);

  ChangeInfo changeInfo = cherry.get();

  // The cherry-pick honors the ChangeId specified in the input message:
  RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
  assertThat(revInfo).isNotNull();
  assertThat(revInfo.commit.message).endsWith(id + "\n");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:RevisionIT.java

示例2: cherryPickConflict

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void cherryPickConflict() throws Exception {
  PushOneCommit.Result r = createChange();
  CherryPickInput in = new CherryPickInput();
  in.destination = "foo";
  in.message = "it goes to stable branch";
  gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());

  PushOneCommit push =
      pushFactory.create(
          db,
          admin.getIdent(),
          testRepo,
          PushOneCommit.SUBJECT,
          PushOneCommit.FILE_NAME,
          "another content");
  push.to("refs/heads/foo");

  String triplet = project.get() + "~master~" + r.getChangeId();
  ChangeApi orig = gApi.changes().id(triplet);
  assertThat(orig.get().messages).hasSize(1);

  exception.expect(ResourceConflictException.class);
  exception.expectMessage("Cherry pick failed: merge conflict");
  orig.revision(r.getCommit().name()).cherryPick(in);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:RevisionIT.java

示例3: create

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi create(ChangeInput in) throws RestApiException {
    if (in.branch == null) {
        throw new IllegalArgumentException("Branch must be set in change creation input.");
    }

    String url = "/changes/";
    String changeInput = changesParser.generateChangeInput(in);
    JsonElement result = gerritRestClient.postRequest(url, changeInput);
    ChangeInfo info = changesParser.parseSingleChangeInfo(result);
    return new ChangeApiRestClient(gerritRestClient,
        this,
        changesParser,
        commentsParser,
        includedInInfoParser,
        fileInfoParser,
        diffInfoParser,
        addReviewerResultParser,
        reviewResultParser,
        suggestedReviewerInfoParser,
        reviewerInfoParser,
        editInfoParser,
        info.id);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:25,代码来源:ChangesRestClient.java

示例4: revert

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi revert(RevertInput revertInput) throws RestApiException {
    String request = getRequestPath() + "/revert";
    String json = gerritRestClient.getGson().toJson(revertInput);
    gerritRestClient.postRequest(request, json);
    return new ChangeApiRestClient(gerritRestClient,
        changesRestClient,
        changesParser,
        commentsParser,
        includedInInfoParser,
        fileInfoParser,
        diffInfoParser,
        addReviewerResultParser,
        reviewResultParser,
        suggestedReviewerInfoParser,
        reviewerInfoParser,
        editInfoParser,
        id);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:20,代码来源:ChangeApiRestClient.java

示例5: testCreate

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void testCreate() throws Exception {
    ChangesCreateTestCase testCase = new ChangesCreateTestCase().expectUrl("/changes/");
    ChangeInput changeInput = new ChangeInput();
    changeInput.branch = "master";
    String changeInputJsonString = "{}";
    GerritRestClient gerritRestClient = setupGerritRestClient(testCase, changeInputJsonString);
    ChangeInfo changeInfo = new ChangeInfo();
    changeInfo.id = "id";
    ChangesParser changesParser = setupChangesParserForCreate(changeInput,
        changeInputJsonString, changeInfo);

    ChangesRestClient changes = new ChangesRestClient(gerritRestClient, changesParser, null, null, null, null, null, null, null, null, null);

    ChangeApi changeApi = changes.create(changeInput);

    Truth.assertThat(changeApi.id()).isEqualTo(changeInfo.id);
    EasyMock.verify(gerritRestClient, changesParser);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:20,代码来源:ChangesRestClientTest.java

示例6: testAddReviewer

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void testAddReviewer() throws Exception {
    GerritRestClient gerritRestClient = getGerritRestClient(
            "/changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/reviewers",
            "{\"reviewer\":\"jdoe\",\"confirmed\":true}");
    ChangesRestClient changesRestClient = getChangesRestClient(gerritRestClient);

    ChangeApi changeApi = changesRestClient.id("myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940");

    AddReviewerInput input = new AddReviewerInput();
    input.reviewer = "jdoe";
    input.confirmed = true;

    changeApi.addReviewer(input);

    EasyMock.verify(gerritRestClient);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:18,代码来源:ChangeApiRestClientTest.java

示例7: cherryPick

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi cherryPick(CherryPickInput input) throws RestApiException {
  try {
    return changes.id(cherryPickCommit.apply(commitResource, input)._number);
  } catch (Exception e) {
    throw asRestApiException("Cannot cherry pick", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:CommitApiImpl.java

示例8: revert

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi revert(RevertInput in) throws RestApiException {
  try {
    return changeApi.id(revert.apply(change, in)._number);
  } catch (Exception e) {
    throw asRestApiException("Cannot revert change", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:ChangeApiImpl.java

示例9: rebase

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi rebase(RebaseInput in) throws RestApiException {
  try {
    return changes.id(rebase.apply(revision, in)._number);
  } catch (Exception e) {
    throw asRestApiException("Cannot rebase ps", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:RevisionApiImpl.java

示例10: cherryPick

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
  try {
    return changes.id(cherryPick.apply(revision, in)._number);
  } catch (Exception e) {
    throw asRestApiException("Cannot cherry pick", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:RevisionApiImpl.java

示例11: create

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi create(ChangeInput in) throws RestApiException {
  try {
    ChangeInfo out = createChange.apply(TopLevelResource.INSTANCE, in).value();
    return api.create(changes.parse(new Change.Id(out._number)));
  } catch (Exception e) {
    throw asRestApiException("Cannot create change", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:ChangesImpl.java

示例12: cherryPickwithNoTopic

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void cherryPickwithNoTopic() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master");
  CherryPickInput in = new CherryPickInput();
  in.destination = "foo";
  in.message = "it goes to stable branch";
  gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
  ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());

  ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
  assertThat(cherry.get().topic).isNull();
  cherry.current().review(ReviewInput.approve());
  cherry.current().submit();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RevisionIT.java

示例13: patch

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void patch() throws Exception {
  PushOneCommit.Result r = createChange();
  ChangeApi changeApi = gApi.changes().id(r.getChangeId());
  BinaryResult bin = changeApi.revision(r.getCommit().name()).patch();
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  bin.writeTo(os);
  String res = new String(os.toByteArray(), UTF_8);
  ChangeInfo change = changeApi.get();
  RevisionInfo rev = change.revisions.get(change.currentRevision);
  DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
  String date = df.format(rev.commit.author.date);
  assertThat(res).isEqualTo(String.format(PATCH, r.getCommit().name(), date, r.getChangeId()));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RevisionIT.java

示例14: patchWithPath

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void patchWithPath() throws Exception {
  PushOneCommit.Result r = createChange();
  ChangeApi changeApi = gApi.changes().id(r.getChangeId());
  BinaryResult bin = changeApi.revision(r.getCommit().name()).patch(FILE_NAME);
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  bin.writeTo(os);
  String res = new String(os.toByteArray(), UTF_8);
  assertThat(res).isEqualTo(PATCH_FILE_ONLY);

  exception.expect(ResourceNotFoundException.class);
  exception.expectMessage("File not found: nonexistent-file.");
  changeApi.revision(r.getCommit().name()).patch("nonexistent-file");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RevisionIT.java

示例15: projectChangeNumberReturnsChangeWhenProjectContainsSlashes

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void projectChangeNumberReturnsChangeWhenProjectContainsSlashes() throws Exception {
  Project.NameKey p = createProject("foo/bar");
  ChangeInfo ci = gApi.changes().create(new ChangeInput(p.get(), "master", "msg")).get();
  ChangeApi cApi = gApi.changes().id(p.get(), ci._number);
  assertThat(cApi.get().changeId).isEqualTo(ci.changeId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:ChangeIdIT.java


注:本文中的com.google.gerrit.extensions.api.changes.ChangeApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。