use of com.jcabi.github.Repo in project jcabi-github by jcabi.
the class MkContentsTest method canRemoveFileFromBranch.
/**
* MkContents should be able to remove files from from non-default branches.
*
* @throws Exception if some problem inside
*/
@Test
public void canRemoveFileFromBranch() throws Exception {
final String branch = "branch-1";
final Repo repo = new MkGithub().randomRepo();
final String path = "removeme.txt";
this.createFile(repo, path);
final JsonObject json = MkContentsTest.content(path, "theDeleteMessage").add("ref", branch).add("committer", MkContentsTest.committer()).build();
final RepoCommit commit = repo.contents().remove(json);
MatcherAssert.assertThat(commit, Matchers.notNullValue());
MatcherAssert.assertThat(commit.json().getString("message"), Matchers.equalTo("theDeleteMessage"));
}
use of com.jcabi.github.Repo 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()));
}
use of com.jcabi.github.Repo 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()));
}
use of com.jcabi.github.Repo 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));
}
use of com.jcabi.github.Repo 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));
}
Aggregations