Search in sources :

Example 1 with Repo

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

the class MkIssuesTest method iteratesIssues.

/**
 * MkIssues can list issues.
 * @throws Exception If some problem inside
 */
@Test
public void iteratesIssues() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    repo.issues().create("hey, you", "body of issue");
    repo.issues().create("hey", "body of 2nd issue");
    repo.issues().create("hey again", "body of 3rd issue");
    MatcherAssert.assertThat(repo.issues().iterate(new ArrayMap<String, String>()), Matchers.<Issue>iterableWithSize(Tv.THREE));
}
Also used : Repo(com.jcabi.github.Repo) ArrayMap(com.jcabi.immutable.ArrayMap) Test(org.junit.Test)

Example 2 with Repo

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

the class MkIssuesTest method createsMultipleIssues.

/**
 * MkIssues can create a multiple issues.
 * @throws Exception If some problem inside
 */
@Test
public void createsMultipleIssues() throws Exception {
    final Github github = new MkGithub("jeff");
    final Repo repo = github.repos().create(new Repos.RepoCreate("test-3", false));
    for (int idx = 1; idx < Tv.TEN; ++idx) {
        repo.issues().create("title", "body");
    }
}
Also used : Repos(com.jcabi.github.Repos) Repo(com.jcabi.github.Repo) Github(com.jcabi.github.Github) Test(org.junit.Test)

Example 3 with Repo

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

the class MkIssuesTest method createsNewIssueWithCorrectAuthor.

/**
 * MkIssues can create a new issue with correct author.
 * @throws Exception If some problem inside
 */
@Test
public void createsNewIssueWithCorrectAuthor() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final Issue.Smart issue = new Issue.Smart(repo.issues().create("hello", "the body"));
    MatcherAssert.assertThat(issue.author().login(), Matchers.equalTo(repo.github().users().self().login()));
}
Also used : Issue(com.jcabi.github.Issue) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 4 with Repo

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

the class MkMilestoneTest method returnsSameCoordinatesRepo.

/**
 * 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));
}
Also used : Repo(com.jcabi.github.Repo) Coordinates(com.jcabi.github.Coordinates) Test(org.junit.Test)

Example 5 with Repo

use of com.jcabi.github.Repo 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)

Aggregations

Repo (com.jcabi.github.Repo)57 Test (org.junit.Test)55 Coordinates (com.jcabi.github.Coordinates)11 Issue (com.jcabi.github.Issue)10 Repos (com.jcabi.github.Repos)10 References (com.jcabi.github.References)5 Github (com.jcabi.github.Github)3 JsonObject (javax.json.JsonObject)3 Comment (com.jcabi.github.Comment)2 Content (com.jcabi.github.Content)2 Event (com.jcabi.github.Event)2 RepoCommit (com.jcabi.github.RepoCommit)2 ArrayMap (com.jcabi.immutable.ArrayMap)2 Branch (com.jcabi.github.Branch)1 Contents (com.jcabi.github.Contents)1 Fork (com.jcabi.github.Fork)1 IssueLabels (com.jcabi.github.IssueLabels)1 Label (com.jcabi.github.Label)1 Labels (com.jcabi.github.Labels)1 Language (com.jcabi.github.Language)1