use of com.jcabi.github.Issue 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.Issue in project jcabi-github by jcabi.
the class MkIssueLabelsTest method createsLabelsThroughDecorator.
/**
* MkIssueLabels can create labels through Smart decorator.
* @throws Exception If some problem inside
*/
@Test
public void createsLabelsThroughDecorator() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("how are you?", "");
final String name = "task";
new IssueLabels.Smart(issue.labels()).addIfAbsent(name, "f0f0f0");
MatcherAssert.assertThat(issue.labels().iterate(), Matchers.<Label>iterableWithSize(1));
}
use of com.jcabi.github.Issue 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));
}
use of com.jcabi.github.Issue in project jcabi-github by jcabi.
the class MkPulls method create.
@Override
public Pull create(final String title, final String head, final String base) throws IOException {
if (head.isEmpty()) {
throw new IllegalArgumentException("head cannot be empty!");
}
if (base.isEmpty()) {
throw new IllegalArgumentException("base cannot be empty!");
}
final String canonical;
if (head.contains(MkPulls.USER_BRANCH_SEP)) {
canonical = head;
} else {
canonical = String.format("%s%s%s", this.coords.user(), MkPulls.USER_BRANCH_SEP, head);
}
this.storage.lock();
final int number;
try {
final Issue issue = this.repo().issues().create(title, "some body");
number = issue.number();
this.storage.apply(new Directives().xpath(this.xpath()).add("pull").add("number").set(Integer.toString(number)).up().add("head").set(canonical).up().add("base").set(base).up().add("user").add("login").set(this.self).up());
} finally {
this.storage.unlock();
}
return this.get(number);
}
use of com.jcabi.github.Issue 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()));
}
Aggregations