Search in sources :

Example 1 with Repos

use of com.jcabi.github.Repos in project jcabi-github by jcabi.

the class MkPullCommentsTest method postsPullComment.

/**
 * MkPullComments can create a pull comment.
 *
 * @throws Exception If something goes wrong.
 */
@Test
public void postsPullComment() throws Exception {
    final MkStorage storage = new MkStorage.InFile();
    final String commit = "commit_id";
    final String path = "path";
    final String bodytext = "some text as a body";
    final String login = "jamie";
    final String reponame = "incredible";
    final Repo repo = new MkGithub(storage, login).repos().create(new Repos.RepoCreate(reponame, false));
    repo.pulls().create("pullrequest1", "head", "base").comments().post(bodytext, commit, path, 1);
    final String[] fields = { commit, path };
    for (final String element : fields) {
        MkPullCommentsTest.assertFieldContains(storage, repo, element);
    }
    final List<String> position = storage.xml().xpath(String.format(// @checkstyle LineLength (1 line)
    "/github/repos/repo[@coords='%s/%s']/pulls/pull/comments/comment/position/text()", repo.coordinates().user(), repo.coordinates().repo()));
    MatcherAssert.assertThat(position.get(0), Matchers.notNullValue());
    final List<String> body = storage.xml().xpath(String.format(// @checkstyle LineLength (1 line)
    "/github/repos/repo[@coords='%s/%s']/pulls/pull/comments/comment/body/text()", repo.coordinates().user(), repo.coordinates().repo()));
    MatcherAssert.assertThat(body.get(0), Matchers.equalTo(bodytext));
}
Also used : Repos(com.jcabi.github.Repos) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 2 with Repos

use of com.jcabi.github.Repos in project jcabi-github by jcabi.

the class MkRepoTest method works.

/**
 * Repo can work.
 * @throws Exception If some problem inside
 */
@Test
public void works() throws Exception {
    final Repos repos = new MkRepos(new MkStorage.InFile(), "jeff");
    final Repo repo = repos.create(new Repos.RepoCreate("test5", false));
    MatcherAssert.assertThat(repo.coordinates(), Matchers.hasToString("jeff/test5"));
}
Also used : Repos(com.jcabi.github.Repos) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 3 with Repos

use of com.jcabi.github.Repos in project jcabi-github by jcabi.

the class MkReposTest method createsRepositoryWithDetails.

/**
 * MkRepos can create a repo with details.
 * @throws Exception If some problem inside
 */
@Test
public void createsRepositoryWithDetails() throws Exception {
    final Repos repos = new MkRepos(new MkStorage.InFile(), "jeff");
    final Repo repo = MkReposTest.repo(repos, "hello", "my test repo");
    MatcherAssert.assertThat(new Repo.Smart(repo).description(), Matchers.startsWith("my test"));
}
Also used : Repos(com.jcabi.github.Repos) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 4 with Repos

use of com.jcabi.github.Repos in project jcabi-github by jcabi.

the class MkReposTest method removesRepo.

/**
 * MkRepos can remove an existing repo.
 * @throws Exception If some problem inside
 */
@Test
public void removesRepo() throws Exception {
    final Repos repos = new MkRepos(new MkStorage.InFile(), "jeff");
    final Repo repo = MkReposTest.repo(repos, "remove-me", "remove repo");
    MatcherAssert.assertThat(repos.get(repo.coordinates()), Matchers.notNullValue());
    repos.remove(repo.coordinates());
    this.thrown.expect(IllegalArgumentException.class);
    this.thrown.expectMessage("repository jeff/remove-me doesn't exist");
    repos.get(repo.coordinates());
}
Also used : Repos(com.jcabi.github.Repos) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 5 with Repos

use of com.jcabi.github.Repos in project jcabi-github by jcabi.

the class MkEventTest method canGetPresentLabel.

/**
 * MkEvent can get present label value from json object.
 * @throws Exception If some problem inside
 */
@Test
public void canGetPresentLabel() throws Exception {
    final MkStorage storage = new MkStorage.InFile();
    final String user = "ken";
    final Repo repo = new MkGithub(storage, user).repos().create(new Repos.RepoCreate("foo", false));
    final MkIssueEvents events = (MkIssueEvents) (repo.issueEvents());
    final String label = "problem";
    final int num = events.create(Event.LABELED, 1, user, Optional.of(label)).number();
    MatcherAssert.assertThat(new Event.Smart(new MkEvent(storage, user, repo.coordinates(), num)).label().get().name(), Matchers.equalTo(label));
}
Also used : Repos(com.jcabi.github.Repos) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Aggregations

Repos (com.jcabi.github.Repos)9 Test (org.junit.Test)9 Repo (com.jcabi.github.Repo)8 Label (com.jcabi.github.Label)1 Milestones (com.jcabi.github.Milestones)1