use of com.jcabi.github.Label in project jcabi-github by jcabi.
the class MkIssue method json.
@Override
public JsonObject json() throws IOException {
final XML xml = this.storage.xml();
final JsonObject obj = new JsonNode(xml.nodes(this.xpath()).get(0)).json();
final JsonObjectBuilder json = Json.createObjectBuilder();
for (final Map.Entry<String, JsonValue> val : obj.entrySet()) {
json.add(val.getKey(), val.getValue());
}
final JsonArrayBuilder array = Json.createArrayBuilder();
for (final Label label : this.labels().iterate()) {
array.add(Json.createObjectBuilder().add("name", label.name()).build());
}
final JsonObjectBuilder res = json.add("labels", array).add(// @checkstyle MultipleStringLiteralsCheck (1 line)
"assignee", Json.createObjectBuilder().add("login", obj.getString("assignee", "")).build());
final JsonObjectBuilder pull = Json.createObjectBuilder();
final String html = "html_url";
if (xml.nodes(String.format(// @checkstyle LineLengthCheck (1 line)
"/github/repos/repo[@coords='%s']/pulls/pull/number[text() = '%d']", this.coords, this.num)).isEmpty()) {
pull.addNull(html);
} else {
pull.add(html, String.format("https://%s/pulls/%d", this.coords, this.num));
}
return res.add("pull_request", pull.build()).build();
}
use of com.jcabi.github.Label 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()));
}
Aggregations