• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Repo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: perform

import com.jcabi.github.Repo; //导入依赖的package包/类
@Override
public void perform(
    final Command command, final Log log) throws IOException {
    try {
        log.logger().info("Starring repository...");
        final Repo repo = command.issue().repo();
        if(!repo.stars().starred()) {
            repo.stars().star();
        }
        log.logger().info("Repository starred!");
    } catch (final IOException ex) {
        log.logger().warn(
            "IOException when starring repository, could not star the repo."
        );
    }
    this.next().perform(command, log);
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:18,代码来源:StarRepo.java


示例2: clonesRepo

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * CloneRepo provides the scripts necessary to clone the Github Repo.
 */
@Test
public void clonesRepo() {
    final Repo repo = Mockito.mock(Repo.class);
    Mockito.when(repo.coordinates()).thenReturn(
        new Coordinates.Simple("amihaiemil/testrepo")
    );
    final Scripts original = Mockito.mock(Scripts.class);
    Mockito.when(original.asText()).thenReturn("cloc .");

    final Scripts clone = new CloneRepo(repo, original);

    final StringBuilder expected = new StringBuilder();
    expected.append("git clone [email protected]:amihaiemil/testrepo.git")
        .append("\n")
        .append("cd testrepo").append("\n")
        .append("pwd").append("\n")
        .append("cloc .").append("\n");

    MatcherAssert.assertThat(
        clone.asText(), Matchers.equalTo(expected.toString())
    );
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:26,代码来源:CloneRepoTestCase.java


示例3: returnsMissingComdorYaml

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * JsonMention can return the .comdor.yml
 * if it is missing from the repository.
 * @throws Exception If something goes wrong.
 */
@Test
public void returnsMissingComdorYaml() throws Exception {
    final MkGithub gh = new MkGithub("amihaiemil");
    final Repo repo = gh.repos().create(
        new Repos.RepoCreate("charlesrepo", false)
    );
    final Command mention = new MockConcrete(
        Json.createObjectBuilder().build(),
        repo.issues().create("for test", "body")
    );
    final ComdorYaml yaml = mention.comdorYaml();
    MatcherAssert.assertThat(yaml, Matchers.notNullValue());
    MatcherAssert.assertThat(
        yaml instanceof ComdorYaml.Missing,
        Matchers.is(true)
    );
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:23,代码来源:JsonMentionTestCase.java


示例4: perform

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * Star the repository.
 * @return Always returns true, since it's not a critical step.
 */
public void perform(Command command, Logger logger) throws IOException {
    try {
        logger.info("Starring repository...");
        Repo repo = command.issue().repo();
        if(!repo.stars().starred()) {
            repo.stars().star();
        }
        logger.info("Repository starred!");
    } catch (IOException e) {
        logger.error("Error when starring repository: " + e.getMessage(), e);
        //We do not rethrow it here since starring the repo is not
        //a critical matter
    }
    this.next().perform(command, logger);
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:20,代码来源:StarRepo.java


示例5: repoHasGhPagesBranch

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * CommandedRepo can tell when the repo has a gh-pages branch.
 * @throws Exception If something goes wrong.
 */
@Test
public void repoHasGhPagesBranch() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK))
        .start(port);
    try {
        CachedRepo crepo = Mockito.spy(
            new CachedRepo(Mockito.mock(Repo.class))
        );
        Mockito.when(crepo.json()).thenReturn(Json
            .createObjectBuilder()
            .add(
                "branches_url",
                "http://localhost:" + port + "/branches{/branch}"
            ).build()
        );
        assertTrue(
            "Expected a gh-pages branch!",
            crepo.hasGhPagesBranch()
        );
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:30,代码来源:CachedRepoTestCase.java


示例6: repoHasNoGhPagesBranch

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * CommandedRepo can tell when the repo doesn't
 * have a gh-pages branch.
 * @throws Exception If something goes wrong.
 */
@Test
public void repoHasNoGhPagesBranch() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_FOUND))
        .start(port);
    try {
        CachedRepo crepo = Mockito.spy(
            new CachedRepo(Mockito.mock(Repo.class))
        );
        Mockito.when(crepo.json()).thenReturn(Json
            .createObjectBuilder()
            .add(
                "branches_url",
                "http://localhost:" + port + "/branches{/branch}"
            ).build()
        );
        assertFalse(
            "Unexpected gh-pages branch!",
            crepo.hasGhPagesBranch()
        );
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:31,代码来源:CachedRepoTestCase.java


示例7: getsAuthorEmail

import com.jcabi.github.Repo; //导入依赖的package包/类
@Test
public void getsAuthorEmail() throws Exception {
    MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    
    MkGithub authorGh = new MkGithub(storage, "amihaiemil");
    authorGh.users().self().emails().add(Arrays.asList("[email protected]"));
    Repo authorRepo = authorGh.randomRepo();
    Comment com = authorRepo.issues().create("", "").comments().post("@charlesmike do something");

    Github agentGh = new MkGithub(storage, "charlesmike");
    Issue issue = agentGh.repos().get(authorRepo.coordinates()).issues().get(com.issue().number());
    Command comm = Mockito.mock(Command.class);
    
    JsonObject authorInfo = Json.createObjectBuilder().add("login", "amihaiemil").build();
    JsonObject json = Json.createObjectBuilder()
        .add("user", authorInfo)
        .add("body", com.json().getString("body"))
        .add("id", 2)
        .build();
    Mockito.when(comm.json()).thenReturn(json);
    Mockito.when(comm.issue()).thenReturn(issue);

    ValidCommand vc = new ValidCommand(comm);
    assertTrue(vc.authorEmail().equals("[email protected]"));
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:26,代码来源:ValidCommandTestCase.java


示例8: starsRepo

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * StarRepo can successfully star a given repository.
 * @throws Exception If something goes wrong.
 */
@Test
public void starsRepo() throws Exception {
    Logger logger = Mockito.mock(Logger.class);
    Mockito.doNothing().when(logger).info(Mockito.anyString());
    Mockito.doThrow(new IllegalStateException("Unexpected error; test failed")).when(logger).error(Mockito.anyString());
    
    Github gh = new MkGithub("amihaiemil");
    Repo repo =  gh.repos().create(
        new RepoCreate("amihaiemil.github.io", false)
    );
    Command com = Mockito.mock(Command.class);
    Issue issue = Mockito.mock(Issue.class);
    Mockito.when(issue.repo()).thenReturn(repo);
    Mockito.when(com.issue()).thenReturn(issue);
    
    Step sr = new StarRepo(Mockito.mock(Step.class));
    assertFalse(com.issue().repo().stars().starred());
    sr.perform(com, logger);
    assertTrue(com.issue().repo().stars().starred());
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:25,代码来源:StarRepoTestCase.java


示例9: starsRepoTwice

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * StarRepo tries to star a repo twice.
 * @throws Exception If something goes wrong.
 */
@Test
public void starsRepoTwice() throws Exception {
    Logger logger = Mockito.mock(Logger.class);
    Mockito.doNothing().when(logger).info(Mockito.anyString());
    Mockito.doThrow(new IllegalStateException("Unexpected error; test failed")).when(logger).error(Mockito.anyString());

    Github gh = new MkGithub("amihaiemil");
    Repo repo =  gh.repos().create(
        new RepoCreate("amihaiemil.github.io", false)
    );
    Command com = Mockito.mock(Command.class);
    Issue issue = Mockito.mock(Issue.class);
    Mockito.when(issue.repo()).thenReturn(repo);
    Mockito.when(com.issue()).thenReturn(issue);

    Step sr = new StarRepo(Mockito.mock(Step.class));
    assertFalse(com.issue().repo().stars().starred());
    sr.perform(com, logger);
    sr.perform(com, logger);
    assertTrue(com.issue().repo().stars().starred());
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:26,代码来源:StarRepoTestCase.java


示例10: repoStarringFails

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * StarRepo did not star the repository due to an IOException. 
 * StarRepo.perform() should return true anyway because it's not a critical operation and we
 * shouldn't fail the whole process just because of this.
 * 
 * This test expects an RuntimeException (we mock the logger in such a way) because it's the easiest way
 * to find out if the flow entered the catch block.
 * @throws IOException If something goes wrong.
 */
@Test(expected = RuntimeException.class)
public void repoStarringFails() throws IOException {
    Logger logger = Mockito.mock(Logger.class);
    Mockito.doNothing().when(logger).info(Mockito.anyString());
    Mockito.doThrow(new RuntimeException("Excpected excetion; all is ok!")).when(logger).error(
        Mockito.anyString(), Mockito.any(IOException.class)
    );
    
    Repo repo = Mockito.mock(Repo.class);
    Stars stars = Mockito.mock(Stars.class);
    Mockito.when(stars.starred()).thenReturn(false);
    Mockito.doThrow(new IOException()).when(stars).star();
    Mockito.when(repo.stars()).thenReturn(stars);
    Command com = Mockito.mock(Command.class);
    Issue issue = Mockito.mock(Issue.class);
    Mockito.when(issue.repo()).thenReturn(repo);
    Mockito.when(com.issue()).thenReturn(issue);
    
    StarRepo sr = new StarRepo(Mockito.mock(Step.class));
    sr.perform(com, logger);
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:31,代码来源:StarRepoTestCase.java


示例11: agentRepliedAlreadyToTheLastComment

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * Agent already replied once to the last comment.
 * @throws Exception if something goes wrong.
 */
@Test
public void agentRepliedAlreadyToTheLastComment() throws Exception {
    final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    final Repo repoMihai = new MkGithub(storage, "amihaiemil").repos().create( new RepoCreate("amihaiemil.github.io", false));
    final Issue issue = repoMihai.issues().create("test issue", "body");
    issue.comments().post("@charlesmike hello!");
    
    final Github charlesmike = new MkGithub(storage, "charlesmike");
    Issue issueCharlesmike = charlesmike.repos().get(repoMihai.coordinates()).issues().get(issue.number());
    issueCharlesmike.comments().post("@amihaiemil hi there, I can help you index... ");

    issue.comments().post("@someoneelse, please check that...");
    
    LastComment lastComment = new LastComment(issueCharlesmike);
    JsonObject jsonComment = lastComment.json();
    JsonObject emptyMentionComment = Json.createObjectBuilder().add("id", "-1").add("body", "").build();
    assertTrue(emptyMentionComment.equals(jsonComment)); 
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:23,代码来源:LastCommentTestCase.java


示例12: agentRepliedToPreviousMention

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * There is more than 1 mention of the agent in the issue and it has already 
 * replied to others, but the last one is not replied to yet.
 * @throws Exception if something goes wrong.
 */
@Test
public void agentRepliedToPreviousMention() throws Exception {
    final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    final Repo repoMihai = new MkGithub(storage, "amihaiemil").repos().create( new RepoCreate("amihaiemil.github.io", false));
    final Issue issue = repoMihai.issues().create("test issue", "body");
    issue.comments().post("@charlesmike hello!");//first mention
    
    final Github charlesmike = new MkGithub(storage, "charlesmike");
    Issue issueCharlesmike = charlesmike.repos().get(repoMihai.coordinates()).issues().get(issue.number());
    issueCharlesmike.comments().post("@amihaiemil hi there, I can help you index... "); //first reply

    Comment lastMention = issue.comments().post("@charlesmike hello again!!");//second mention
    issue.comments().post("@someoneelse, please check that..."); //some other comment that is the last on the ticket.
    
    LastComment lastComment = new LastComment(issueCharlesmike);
    JsonObject jsonComment = lastComment.json();
    assertTrue(lastMention.json().equals(jsonComment)); 
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:24,代码来源:LastCommentTestCase.java


示例13: create

import com.jcabi.github.Repo; //导入依赖的package包/类
@Override
@NotNull(message = "repo is never NULL")
public Repo create(
    @NotNull(message = "settings can't be NULL")
    final RepoCreate settings
) throws IOException {
    final Coordinates coords = new Coordinates.Simple(
        this.self,
        settings.name()
    );
    this.storage.apply(
        new Directives().xpath(this.xpath()).add("repo")
            .attr("coords", coords.toString())
            .add("name").set(settings.name()).up()
            .add("description").set("test repository").up()
            .add("private").set("false").up()
    );
    final Repo repo = this.get(coords);
    repo.patch(settings.json());
    Logger.info(
        this, "repository %s created by %s",
        coords, this.self
    );
    return repo;
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:26,代码来源:MkRepos.java


示例14: get

import com.jcabi.github.Repo; //导入依赖的package包/类
@Override
@NotNull(message = "Repo is never NULL")
public Repo get(
    @NotNull(message = "coords can't be NULL") final Coordinates coords
) {
    try {
        final String xpath = String.format(
            "%s/repo[@coords='%s']", this.xpath(), coords
        );
        if (this.storage.xml().nodes(xpath).isEmpty()) {
            throw new IllegalArgumentException(
                String.format("repository %s doesn't exist", coords)
            );
        }
    } catch (final IOException ex) {
        throw new IllegalStateException(ex);
    }
    return new MkRepo(this.storage, this.self, coords);
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:20,代码来源:MkRepos.java


示例15: iterate

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * Iterate all public repos, starting with the one you've seen already.
 * @param identifier The integer ID of the last Repo that you’ve seen.
 * @return Iterator of repo
 */
@Override
public Iterable<Repo> iterate(
    @NotNull(message = "identifier can't be NULL")
    final String identifier) {
    return new MkIterable<Repo>(
        this.storage,
        "/github/repos/repo",
        new MkIterable.Mapping<Repo>() {
            @Override
            public Repo map(final XML xml) {
                return new MkRepo(
                    MkRepos.this.storage, MkRepos.this.self,
                    new Coordinates.Simple(xml.xpath("@coords").get(0))
                );
            }
        }
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:24,代码来源:MkRepos.java


示例16: repos

import com.jcabi.github.Repo; //导入依赖的package包/类
@Override
@NotNull(message = "Iterable of repos is never NULL")
public Iterable<Repo> repos(
    @NotNull(message = "keywords can't be NULL") final String keywords,
    @NotNull(message = "sort can't be NULL") final String sort,
    @NotNull(message = "order can't be NULL") final Order order
) throws IOException {
    return new MkIterable<Repo>(
        this.storage,
        "/github/repos/repo",
        new MkIterable.Mapping<Repo>() {
            @Override
            public Repo map(final XML xml) {
                return new MkRepo(
                    MkSearch.this.storage, MkSearch.this.self,
                    new Coordinates.Simple(xml.xpath("@coords").get(0))
                );
            }
        }
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:22,代码来源:MkSearch.java


示例17: returnsSameCoordinatesRepo

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * MkMilestone returns a repo with same coordinates.
 * @throws Exception if test fails
 */
@Test
public final void returnsSameCoordinatesRepo() throws Exception {
    final Coordinates coordinates = new Coordinates.Simple(
        "user",
        "repo"
    );
    final MkMilestone milestone = new MkMilestone(
        new MkStorage.InFile(),
        "login",
        coordinates,
        1
    );
    final Repo repo = milestone.repo();
    MatcherAssert.assertThat(
        repo.coordinates(),
        Matchers.equalTo(coordinates)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:23,代码来源:MkMilestoneTest.java


示例18: getTreeRec

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * MkTrees can get tree recursively.
 *
 * @throws Exception if some problem inside
 */
@Test
public void getTreeRec() throws Exception {
    final String sha = "0abcd89jcabitest";
    final JsonObject json = Json.createObjectBuilder().add(
        "tree",
        Json.createArrayBuilder().add(
            Json.createObjectBuilder()
                .add("path", "test.txt")
                .add("mode", "100644")
                .add("sha", sha).add("name", "tree rec")
                .add("type", "blob")
                .add("content", "hello")
                .build()
        ).build()
    ).build();
    final Repo repo = new MkGithub().randomRepo();
    repo.git().trees().create(json);
    MatcherAssert.assertThat(
        repo.git().trees().getRec(sha).json().getString("sha"),
        Matchers.containsString(sha)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:28,代码来源:MkTreesTest.java


示例19: fetchesRepo

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * MkBranch can fetch its repo.
 * @throws IOException If an I/O problem occurs
 */
@Test
public void fetchesRepo() throws IOException {
    final Repo repo = new MkGithub().randomRepo();
    final Coordinates coords = MkBranchTest.branches(repo)
        .create("test", "sha")
        .repo().coordinates();
    MatcherAssert.assertThat(
        coords.user(),
        Matchers.equalTo(repo.coordinates().user())
    );
    MatcherAssert.assertThat(
        coords.repo(),
        Matchers.equalTo(repo.coordinates().repo())
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:20,代码来源:MkBranchTest.java


示例20: canCreateAPull

import com.jcabi.github.Repo; //导入依赖的package包/类
/**
 * MkPulls can create a pull.
 * It should create an issue first, and then pull with the same number
 * @throws Exception if some problem inside
 */
@Test
public void canCreateAPull() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final Pull pull = repo.pulls().create(
        "hello",
        "head-branch",
        "base-branch"
    );
    final Issue.Smart issue = new Issue.Smart(
        repo.issues().get(pull.number())
    );
    MatcherAssert.assertThat(
        issue.title(),
        Matchers.is("hello")
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:22,代码来源:MkPullsTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KeyHelper类代码示例发布时间:2022-05-23
下一篇:
Java EntryEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap