use of com.jcabi.http.mock.MkGrizzlyContainer 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();
}
}
use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtCommentTest method returnsItsJSon.
/**
* RtComment can return its JSon description.
* @throws Exception - if something goes wrong.
*/
@Test
public void returnsItsJSon() throws Exception {
final String body = "{\"body\":\"test5\"}";
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body)).start(this.resource.port());
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("testing4", "issue4");
final RtComment comment = new RtComment(new ApacheRequest(container.home()), issue, 10);
try {
final JsonObject json = comment.json();
MatcherAssert.assertThat(json.getString("body"), Matchers.is("test5"));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtDeployKeysTest method canFetchNonEmptyListOfDeployKeys.
/**
* RtDeployKeys can fetch non empty list of deploy keys.
*
* @throws IOException If some problem inside.
*/
@Test
public void canFetchNonEmptyListOfDeployKeys() throws IOException {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(key(1)).add(key(2)).build().toString()));
container.start(this.resource.port());
try {
MatcherAssert.assertThat(new RtDeployKeys(new ApacheRequest(container.home()), RtDeployKeysTest.repo()).iterate(), Matchers.<DeployKey>iterableWithSize(2));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtGistCommentTest method patchAndCheckJsonGistComment.
/**
* RtGistComment can patch comment and return new json.
* @throws IOException if has some problems with json parsing.
*/
@Test
public final void patchAndCheckJsonGistComment() throws IOException {
final int identifier = 1;
final String idString = "id";
final String bodyString = "body";
final String body = "somebody";
final String patchedBody = "some patchedbody";
final MkAnswer first = new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createObjectBuilder().add(bodyString, body).add(idString, identifier).build().toString());
final MkAnswer second = new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createObjectBuilder().add(bodyString, patchedBody).add(idString, identifier).build().toString());
final MkAnswer third = new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createObjectBuilder().add(bodyString, body).add(idString, identifier).build().toString());
final MkContainer container = new MkGrizzlyContainer().next(first).next(second).next(third).start(this.resource.port());
final MkContainer gistContainer = new MkGrizzlyContainer().start(this.resource.port());
final RtGist gist = new RtGist(new MkGithub(), new ApacheRequest(gistContainer.home()), "someName");
final RtGistComment comment = new RtGistComment(new ApacheRequest(container.home()), gist, identifier);
comment.patch(Json.createObjectBuilder().add(bodyString, patchedBody).add(idString, identifier).build());
MatcherAssert.assertThat(comment.json().getString(bodyString), Matchers.equalTo(patchedBody));
container.stop();
gistContainer.stop();
}
use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtGistCommentTest method removeGistComment.
/**
* RtGistComment can remove comment.
* @throws IOException if has some problems with json parsing.
*/
@Test
public final void removeGistComment() throws IOException {
final int identifier = 1;
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start(this.resource.port());
final RtGist gist = new RtGist(new MkGithub(), new FakeRequest().withStatus(HttpURLConnection.HTTP_NO_CONTENT), "gistName");
final RtGistComment comment = new RtGistComment(new ApacheRequest(container.home()), gist, identifier);
comment.remove();
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.DELETE));
container.stop();
}
Aggregations