Search in sources :

Example 26 with Repo

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

Example 27 with Repo

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

the class MkEventTest method canGetCreatedAt.

/**
 * Can get created_at value from json object.
 * @throws Exception If some problem inside
 */
@Test
public void canGetCreatedAt() throws Exception {
    final MkStorage storage = new MkStorage.InFile();
    final String user = "test_user";
    final Repo repo = new MkGithub(storage, user).randomRepo();
    final MkIssueEvents events = (MkIssueEvents) (repo.issueEvents());
    final int eventnum = events.create("test_type", 1, user, Optional.of("test_label")).number();
    MatcherAssert.assertThat(new MkEvent(storage, user, repo.coordinates(), eventnum).json().getString("created_at"), Matchers.notNullValue());
}
Also used : Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 28 with Repo

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

the class MkForksTest method iteratesForks.

/**
 * MkForks can list forks.
 * @throws Exception If some problem inside
 */
@Test
public void iteratesForks() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final Fork fork = repo.forks().create("Organization");
    final Iterable<Fork> iterate = repo.forks().iterate("Order");
    MatcherAssert.assertThat(iterate, Matchers.<Fork>iterableWithSize(1));
    MatcherAssert.assertThat(iterate, Matchers.hasItem(fork));
}
Also used : Fork(com.jcabi.github.Fork) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 29 with Repo

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

the class MkGithubTest method canRelogin.

/**
 * MkGithub can relogin.
 *
 * @throws Exception if some problem inside
 */
@Test
public void canRelogin() throws Exception {
    final String login = "mark";
    final MkGithub github = new MkGithub();
    final Repo repo = github.repos().create(NEW_REPO_SETTINGS);
    final Issue issue = repo.issues().create("title", "Found a bug");
    final Comment comment = github.relogin(login).repos().get(repo.coordinates()).issues().get(issue.number()).comments().post("Nice change");
    MatcherAssert.assertThat(new User.Smart(new Comment.Smart(comment).author()).login(), Matchers.not(Matchers.equalTo(new User.Smart(repo.github().users().self()).login())));
    MatcherAssert.assertThat(new User.Smart(new Comment.Smart(comment).author()).login(), Matchers.equalTo(login));
}
Also used : Comment(com.jcabi.github.Comment) Issue(com.jcabi.github.Issue) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 30 with Repo

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

the class MkGithubTest method canCreateRandomRepo.

/**
 * MkGithub can create random repo.
 * @throws Exception if some problem inside
 */
@Test
public void canCreateRandomRepo() throws Exception {
    final MkGithub github = new MkGithub();
    final Repo repo = github.randomRepo();
    MatcherAssert.assertThat(github.repos().get(repo.coordinates()).coordinates(), Matchers.equalTo(repo.coordinates()));
}
Also used : 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