Search in sources :

Example 36 with Repo

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

the class MkContentsTest method canRemoveFileFromBranch.

/**
 * MkContents should be able to remove files from from non-default branches.
 *
 * @throws Exception if some problem inside
 */
@Test
public void canRemoveFileFromBranch() throws Exception {
    final String branch = "branch-1";
    final Repo repo = new MkGithub().randomRepo();
    final String path = "removeme.txt";
    this.createFile(repo, path);
    final JsonObject json = MkContentsTest.content(path, "theDeleteMessage").add("ref", branch).add("committer", MkContentsTest.committer()).build();
    final RepoCommit commit = repo.contents().remove(json);
    MatcherAssert.assertThat(commit, Matchers.notNullValue());
    MatcherAssert.assertThat(commit.json().getString("message"), Matchers.equalTo("theDeleteMessage"));
}
Also used : Repo(com.jcabi.github.Repo) RepoCommit(com.jcabi.github.RepoCommit) JsonObject(javax.json.JsonObject) Test(org.junit.Test)

Example 37 with Repo

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

the class MkEventTest method canGetAbsentLabel.

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

Example 38 with Repo

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

the class MkGithubTest method worksWithMockedData.

/**
 * MkGithub can work.
 * @throws Exception If some problem inside
 */
@Test
public void worksWithMockedData() throws Exception {
    final Repo repo = new MkGithub().repos().create(NEW_REPO_SETTINGS);
    final Issue issue = repo.issues().create("hey", "how are you?");
    final Comment comment = issue.comments().post("hey, works?");
    MatcherAssert.assertThat(new Comment.Smart(comment).body(), Matchers.startsWith("hey, "));
    MatcherAssert.assertThat(repo.issues().get(issue.number()).comments().iterate(new Date(0L)), Matchers.<Comment>iterableWithSize(1));
    MatcherAssert.assertThat(new User.Smart(new Comment.Smart(comment).author()).login(), Matchers.equalTo(new User.Smart(repo.github().users().self()).login()));
}
Also used : Comment(com.jcabi.github.Comment) Issue(com.jcabi.github.Issue) User(com.jcabi.github.User) Repo(com.jcabi.github.Repo) Date(java.util.Date) Test(org.junit.Test)

Example 39 with Repo

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

the class MkIssueLabelsTest method iteratesIssues.

/**
 * MkIssueLabels can list labels.
 * @throws Exception If some problem inside
 */
@Test
public void iteratesIssues() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final String name = "bug";
    repo.labels().create(name, "c0c0c0");
    final Issue issue = repo.issues().create("title", "body");
    issue.labels().add(Collections.singletonList(name));
    MatcherAssert.assertThat(issue.labels().iterate(), Matchers.<Label>iterableWithSize(1));
}
Also used : Issue(com.jcabi.github.Issue) Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 40 with Repo

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

the class MkIssueLabelsTest method removingLabelGeneratesEvent.

/**
 * MkIssueLabels creates an "unlabeled" event when a label is removed.
 * @throws Exception If some problem inside
 */
@Test
public void removingLabelGeneratesEvent() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final String name = "invalid";
    repo.labels().create(name, "ee82ee");
    final Issue issue = repo.issues().create("Rewrite", "Sound good?");
    issue.labels().add(Collections.singletonList(name));
    issue.labels().remove(name);
    MatcherAssert.assertThat(issue.events(), Matchers.<Event>iterableWithSize(2));
    final Iterator<Event> events = issue.events().iterator();
    events.next();
    final Event.Smart unlabeled = new Event.Smart(events.next());
    MatcherAssert.assertThat(unlabeled.type(), Matchers.equalTo(Event.UNLABELED));
    MatcherAssert.assertThat(unlabeled.author().login(), Matchers.equalTo(USER));
    MatcherAssert.assertThat(unlabeled.repo(), Matchers.equalTo(repo));
    MatcherAssert.assertThat(unlabeled.label().get().name(), Matchers.equalTo(name));
}
Also used : Issue(com.jcabi.github.Issue) Repo(com.jcabi.github.Repo) Event(com.jcabi.github.Event) 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