Search in sources :

Example 11 with Issue

use of com.jcabi.github.Issue 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 12 with Issue

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

Example 13 with Issue

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

the class MkIssueTest method showsIssueAuthor.

/**
 * MkIssue can show an issue author.
 * @throws Exception If some problem inside
 */
@Test
public void showsIssueAuthor() throws Exception {
    final Issue issue = this.issue();
    MatcherAssert.assertThat(new Issue.Smart(issue).author().login(), Matchers.notNullValue());
}
Also used : Issue(com.jcabi.github.Issue) Test(org.junit.Test)

Example 14 with Issue

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

the class MkIssueTest method opensAndCloses.

/**
 * MkIssue can open and close.
 * @throws Exception If some problem inside
 */
@Test
public void opensAndCloses() throws Exception {
    final Issue issue = this.issue();
    MatcherAssert.assertThat(new Issue.Smart(issue).isOpen(), Matchers.is(true));
    new Issue.Smart(issue).close();
    MatcherAssert.assertThat(new Issue.Smart(issue).isOpen(), Matchers.is(false));
}
Also used : Issue(com.jcabi.github.Issue) Test(org.junit.Test)

Example 15 with Issue

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

the class MkIssueTest method listsReadOnlyLabels.

/**
 * MkIssue can list its labels.
 * @throws Exception If some problem inside
 */
@Test
public void listsReadOnlyLabels() throws Exception {
    final Issue issue = this.issue();
    final String tag = "test-tag";
    issue.repo().labels().create(tag, "c0c0c0");
    issue.labels().add(Collections.singletonList(tag));
    MatcherAssert.assertThat(new Issue.Smart(issue).roLabels().iterate(), Matchers.<Label>hasItem(new CustomMatcher<Label>("label just created") {

        @Override
        public boolean matches(final Object item) {
            return Label.class.cast(item).name().equals(tag);
        }
    }));
}
Also used : Issue(com.jcabi.github.Issue) CustomMatcher(org.hamcrest.CustomMatcher) Test(org.junit.Test)

Aggregations

Issue (com.jcabi.github.Issue)17 Test (org.junit.Test)16 Repo (com.jcabi.github.Repo)10 Comment (com.jcabi.github.Comment)2 Event (com.jcabi.github.Event)2 Github (com.jcabi.github.Github)1 IssueLabels (com.jcabi.github.IssueLabels)1 Labels (com.jcabi.github.Labels)1 Pull (com.jcabi.github.Pull)1 User (com.jcabi.github.User)1 Date (java.util.Date)1 ToString (lombok.ToString)1 CustomMatcher (org.hamcrest.CustomMatcher)1 Directives (org.xembly.Directives)1