use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtReleaseAssetTest method removesAsset.
/**
* RtReleaseAsset can remove itself.
* @throws Exception If a problem occurs.
*/
@Test
public void removesAsset() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final RtReleaseAsset asset = new RtReleaseAsset(new ApacheRequest(container.home()), release(), 3);
try {
asset.remove();
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtReposTest method removeRepo.
/**
* RtRepos can remove a repo.
* @throws Exception if some problem inside
*/
@Test
public void removeRepo() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final Repos repos = new RtRepos(Mockito.mock(Github.class), new ApacheRequest(container.home()));
repos.remove(new Coordinates.Simple("", ""));
try {
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
MatcherAssert.assertThat(query.body(), Matchers.isEmptyString());
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtPullCommentTest method patchesComment.
/**
* RtPullComment can create a patch request.
* @throws Exception If a problem occurs.
*/
@Test
public void patchesComment() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")).start();
final Pull pull = Mockito.mock(Pull.class);
Mockito.doReturn(repo()).when(pull).repo();
final RtPullComment comment = new RtPullComment(new ApacheRequest(container.home()), pull, 2);
try {
final JsonObject json = Json.createObjectBuilder().add("body", "test comment").build();
comment.patch(json);
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PATCH));
MatcherAssert.assertThat(query.body(), Matchers.containsString("{\"body\":\"test comment\"}"));
MatcherAssert.assertThat(query.uri().toString(), Matchers.endsWith("/repos/joe/blueharvest/pulls/comments/2"));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtStarsTest method unstarRepository.
/**
* RtStars can unstar repository.
*
* @throws Exception If something goes wrong.
*/
@Test
public void unstarRepository() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT)).start();
final String user = "unstaruser";
final String repo = "unstarrepo";
final Stars stars = new RtStars(new ApacheRequest(container.home()), RtStarsTest.repo(user, repo));
try {
stars.unstar();
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
MatcherAssert.assertThat(query.uri().getPath(), Matchers.containsString(UriBuilder.fromPath(user).path(repo).build().getPath()));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtCollaboratorsTest method userCanBeAddedAsCollaborator.
/**
* User can be added to a repo as a collaborator.
* @throws Exception if any error occurs.
*/
@Test
public void userCanBeAddedAsCollaborator() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, Json.createArrayBuilder().add(RtCollaboratorsTest.json("octocat2")).add(RtCollaboratorsTest.json("dummy")).build().toString())).start(this.resource.port());
final Collaborators users = new RtCollaborators(new JdkRequest(container.home()), this.repo());
try {
users.add("dummy1");
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PUT));
} finally {
container.stop();
}
}
Aggregations