use of com.jcabi.github.Github in project jcabi-github by jcabi.
the class MkIssueEvents method create.
/**
* Creates a new issue event.
* This has no equivalent in GitHub's public API, since GitHub generates
* events automatically in response to some other API calls.
* @param type Type of event
* @param issue ID number of issue the event is regarding
* @param login Username of actor who caused the event
* @param label Label added or removed
* @return The newly created issue event
* @throws IOException If there is any I/O problem
* @todo #1063:30min Make it possible to set the "assignee" field for
* "assigned"/"unassigned" events. Make it possible to set the
* "milestone" field for "milestoned"/"demilestoned" events. Make it
* possible to set the "rename" field for "renamed" events. Make it
* possible to set the "commit_id" field for events related to commits.
* See https://developer.github.com/v3/issues/events/ for details.
* @checkstyle ParameterNumberCheck (4 lines)
*/
public Event create(final String type, final int issue, final String login, final Optional<String> label) throws IOException {
final String created = new Github.Time().toString();
this.storage.lock();
final int number;
try {
number = 1 + this.storage.xml().xpath(String.format("%s/issue-event/number/text()", this.xpath())).size();
Directives directives = new Directives().xpath(this.xpath()).add("issue-event").add("issue").set(Integer.toString(issue)).up().add("number").set(Integer.toString(number)).up().add("event").set(type).up().add("created_at").set(created).up().add("login").set(login).up();
if (label.isPresent()) {
directives = directives.add("label").set(label.get()).up();
}
this.storage.apply(directives);
} finally {
this.storage.unlock();
}
Logger.info(MkEvent.class, "issue event #%d of type %s created in %s for issue #%d by %s", number, type, this.self, issue, login);
return this.get(number);
}
use of com.jcabi.github.Github in project jcabi-github by jcabi.
the class MkIssuesTest method createsMultipleIssues.
/**
* MkIssues can create a multiple issues.
* @throws Exception If some problem inside
*/
@Test
public void createsMultipleIssues() throws Exception {
final Github github = new MkGithub("jeff");
final Repo repo = github.repos().create(new Repos.RepoCreate("test-3", false));
for (int idx = 1; idx < Tv.TEN; ++idx) {
repo.issues().create("title", "body");
}
}
use of com.jcabi.github.Github in project jcabi-github by jcabi.
the class MkIssueTest method canRememberItsAuthor.
/**
* MkIssue can remember it's author.
* @throws Exception when a problem occurs.
*/
@Test
public void canRememberItsAuthor() throws Exception {
final MkGithub first = new MkGithub("first");
final Github second = first.relogin("second");
final Repo repo = first.randomRepo();
final int number = second.repos().get(repo.coordinates()).issues().create("", "").number();
final Issue issue = first.repos().get(repo.coordinates()).issues().get(number);
MatcherAssert.assertThat(new Issue.Smart(issue).author().login(), Matchers.is("second"));
}
use of com.jcabi.github.Github in project jcabi-github by jcabi.
the class Main method main.
/**
* Main entry point.
* @param args Command line arguments
*/
public static void main(final String[] args) throws Exception {
final Github github = new RtGithub();
final JsonResponse resp = github.entry().uri().path("/search/repositories").queryParam("q", "java").back().fetch().as(JsonResponse.class);
final List<JsonObject> items = resp.json().readObject().getJsonArray("items").getValuesAs(JsonObject.class);
for (final JsonObject item : items) {
System.out.println(String.format("repository found: %s", item.get("full_name").toString()));
}
}
use of com.jcabi.github.Github in project jcabi-github by jcabi.
the class MkGithubTest method retrievesMarkdown.
/**
* MkGithub can retrieve the markdown.
*
* @throws Exception if a problem occurs.
*/
@Test
public void retrievesMarkdown() throws Exception {
final Github github = new MkGithub();
MatcherAssert.assertThat(github.markdown(), Matchers.notNullValue());
}
Aggregations