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


Java Repo类代码示例

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


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


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