use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtGistsTest method removesGistByName.
/**
* RtGists can remove a gist by name.
* @throws Exception - if something goes wrong.
*/
@Test
public void removesGistByName() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start(this.resource.port());
final Gists gists = new RtGists(new MkGithub(), new ApacheRequest(container.home()));
try {
gists.remove("12234");
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtBranchesTest method iteratesOverBranches.
/**
* RtBranches can iterate over all branches.
* @throws Exception if there is any error
*/
@Test
public void iteratesOverBranches() throws Exception {
final String firstname = "first";
final String firstsha = "a971b1aca044105897297b87b0b0983a54dd5817";
final String secondname = "second";
final String secondsha = "5d8dc2acf9c95d0d4e8881eebe04c2f0cbb249ff";
final MkAnswer answer = new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(branch(firstname, firstsha)).add(branch(secondname, secondsha)).build().toString());
final MkContainer container = new MkGrizzlyContainer().next(answer).next(answer).start(this.resource.port());
final RtBranches branches = new RtBranches(new JdkRequest(container.home()), new MkGithub().randomRepo());
MatcherAssert.assertThat(branches.iterate(), Matchers.<Branch>iterableWithSize(2));
final Iterator<Branch> iter = branches.iterate().iterator();
final Branch first = iter.next();
MatcherAssert.assertThat(first.name(), Matchers.equalTo(firstname));
MatcherAssert.assertThat(first.commit().sha(), Matchers.equalTo(firstsha));
final Branch second = iter.next();
MatcherAssert.assertThat(second.name(), Matchers.equalTo(secondname));
MatcherAssert.assertThat(second.commit().sha(), Matchers.equalTo(secondsha));
container.stop();
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCommentTest method canCompareInstances.
/**
* RtComment should be able to compare different instances.
* @throws Exception when a problem occurs.
*/
@Test
public void canCompareInstances() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("title", "body");
final RtComment less = new RtComment(new FakeRequest(), issue, 1);
final RtComment greater = new RtComment(new FakeRequest(), issue, 2);
MatcherAssert.assertThat(less.compareTo(greater), Matchers.lessThan(0));
MatcherAssert.assertThat(greater.compareTo(less), Matchers.greaterThan(0));
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCommentTest method patchesComment.
/**
* RtComment can patch a comment.
* @throws Exception - if anything goes wrong.
*/
@Test
public void patchesComment() 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("testing5", "issue5");
final RtComment comment = new RtComment(new ApacheRequest(container.home()), issue, 10);
final JsonObject jsonPatch = Json.createObjectBuilder().add("title", "test comment").build();
try {
comment.patch(jsonPatch);
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PATCH));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCommentTest method removesComment.
/**
* This tests that the remove() method is working fine.
* @throws Exception - in case something goes wrong.
*/
@Test
public void removesComment() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start(this.resource.port());
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("testing3", "issue3");
final RtComment comment = new RtComment(new ApacheRequest(container.home()), issue, 10);
try {
comment.remove();
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
Aggregations