use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtBranchesTest method fetchesRepo.
/**
* RtBranches can fetch its repository.
* @throws IOException If there is any I/O problem
*/
@Test
public void fetchesRepo() throws IOException {
final Repo repo = new MkGithub().randomRepo();
final RtBranches branch = new RtBranches(new FakeRequest(), repo);
final Coordinates coords = branch.repo().coordinates();
MatcherAssert.assertThat(coords.user(), Matchers.equalTo(repo.coordinates().user()));
MatcherAssert.assertThat(coords.repo(), Matchers.equalTo(repo.coordinates().repo()));
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCommentTest method returnsItsIssue.
/**
* RtComment can return its issue (owner).
* @throws Exception - if anything goes wrong.
*/
@Test
public void returnsItsIssue() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("testing1", "issue1");
final RtComment comment = new RtComment(new FakeRequest(), issue, 1);
MatcherAssert.assertThat(comment.issue(), Matchers.is(issue));
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCommentTest method returnsItsNumber.
/**
* RtComment can return its number.
* @throws Exception - in case something goes wrong.
*/
@Test
public void returnsItsNumber() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("testing2", "issue2");
final int num = 10;
final RtComment comment = new RtComment(new FakeRequest(), issue, num);
MatcherAssert.assertThat(comment.number(), Matchers.is(num));
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCommentTest method givesToString.
/**
* This tests that the toString() method is working fine.
* @throws Exception - if anything goes wrong.
*/
@Test
public void givesToString() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")).start(this.resource.port());
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("testing6", "issue6");
final RtComment comment = new RtComment(new ApacheRequest(container.home()), issue, 10);
try {
final String stringComment = comment.toString();
MatcherAssert.assertThat(stringComment, Matchers.not(Matchers.isEmptyOrNullString()));
MatcherAssert.assertThat(stringComment, Matchers.endsWith("10"));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCommitsTest method createsCommit.
/**
* Tests creating a Commit.
*
* @throws Exception when an error occurs
*/
@Test
public final void createsCommit() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, "{\"sha\":\"0abcd89jcabitest\"}")).start(this.resource.port());
final Commits commits = new RtCommits(new ApacheRequest(container.home()), new MkGithub().randomRepo());
final JsonObject author = Json.createObjectBuilder().add("name", "Scott").add("email", "scott@gmail.com").add("date", "2011-06-17T14:53:35-07:00").build();
final JsonObject input = Json.createObjectBuilder().add("message", "initial version").add("author", author).build();
try {
final Commit newCommit = commits.create(input);
MatcherAssert.assertThat(newCommit, Matchers.instanceOf(Commit.class));
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
MatcherAssert.assertThat(newCommit.sha(), Matchers.equalTo("0abcd89jcabitest"));
} finally {
container.stop();
}
}
Aggregations