use of com.jcabi.github.Event in project jcabi-github by jcabi.
the class MkIssueEventsTest method iteratesIssueEvents.
/**
* MkIssueEvents can iterate over issue events in correct order.
* @throws Exception If some problem inside
*/
@Test
public void iteratesIssueEvents() throws Exception {
final MkIssueEvents events = this.issueEvents();
final Event first = events.create("closed", 3, "john", MkIssueEventsTest.ABSENT_STR);
final Event second = events.create("reopened", 3, "jane", MkIssueEventsTest.ABSENT_STR);
MatcherAssert.assertThat(events.iterate(), Matchers.<Event>iterableWithSize(2));
final Iterator<Event> iter = events.iterate().iterator();
MatcherAssert.assertThat(iter.next(), Matchers.equalTo(first));
MatcherAssert.assertThat(iter.next(), Matchers.equalTo(second));
}
use of com.jcabi.github.Event in project jcabi-github by jcabi.
the class MkIssueLabelsTest method addingLabelGeneratesEvent.
/**
* MkIssueLabels creates a "labeled" event when a label is added.
* @throws Exception If some problem inside
*/
@Test
public void addingLabelGeneratesEvent() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final String name = "confirmed";
repo.labels().create(name, "663399");
final Issue issue = repo.issues().create("Titular", "Corpus");
issue.labels().add(Collections.singletonList(name));
MatcherAssert.assertThat(issue.events(), Matchers.<Event>iterableWithSize(1));
final Event.Smart labeled = new Event.Smart(issue.events().iterator().next());
MatcherAssert.assertThat(labeled.type(), Matchers.equalTo(Event.LABELED));
MatcherAssert.assertThat(labeled.author().login(), Matchers.equalTo(USER));
MatcherAssert.assertThat(labeled.repo(), Matchers.equalTo(repo));
MatcherAssert.assertThat(labeled.label().get().name(), Matchers.equalTo(name));
}
use of com.jcabi.github.Event 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));
}