use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtContentsTest method canIterateDirectoryContents.
/**
* RtContents can iterate through a directory's contents.
* @throws Exception If something goes wrong.
*/
@Test
public void canIterateDirectoryContents() throws Exception {
final JsonArray body = Json.createArrayBuilder().add(Json.createObjectBuilder().add("path", "README.md").build()).add(Json.createObjectBuilder().add("path", ".gitignore").build()).build();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body.toString())).next(new MkAnswer.Simple("{\"path\":\"README.md\"}")).next(new MkAnswer.Simple("{\"path\":\".gitignore\"}")).start(this.resource.port());
final RtContents contents = new RtContents(new ApacheRequest(container.home()), repo());
try {
MatcherAssert.assertThat(contents.iterate("dir", "branch2"), Matchers.<Content>iterableWithSize(2));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtAssigneesTest method checkUserIsAssigneeForRepo.
/**
* RtAssignees can check if user is assignee for this repo.
* @throws Exception Exception If some problem inside
*/
@Test
public void checkUserIsAssigneeForRepo() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, Json.createArrayBuilder().add(RtAssigneesTest.json("octocat2")).add(RtAssigneesTest.json("dummy")).build().toString())).start(this.resource.port());
final Assignees users = new RtAssignees(new JdkRequest(container.home()), this.repo());
MatcherAssert.assertThat(users.check("octocat2"), Matchers.equalTo(true));
container.stop();
}
use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtAssigneesTest method checkUserIsNotAssigneeForRepo.
/**
* RtAssignees can check if user is NOT assignee for this repo.
* @throws Exception Exception If some problem inside
*/
@Test
public void checkUserIsNotAssigneeForRepo() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_FOUND, Json.createArrayBuilder().add(RtAssigneesTest.json("octocat3")).add(RtAssigneesTest.json("dummy")).build().toString())).start(this.resource.port());
final Assignees users = new RtAssignees(new JdkRequest(container.home()), this.repo());
MatcherAssert.assertThat(users.check("octocat33"), Matchers.equalTo(false));
container.stop();
}
use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtAssigneesTest method iteratesAssignees.
/**
* RtAssignees can iterate over assignees.
* @throws Exception Exception If some problem inside
*/
@Test
public void iteratesAssignees() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(RtAssigneesTest.json("octocat")).add(RtAssigneesTest.json("dummy")).build().toString())).start(this.resource.port());
final Assignees users = new RtAssignees(new JdkRequest(container.home()), this.repo());
MatcherAssert.assertThat(users.iterate(), Matchers.<User>iterableWithSize(2));
container.stop();
}
use of com.jcabi.http.mock.MkContainer 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();
}
}
Aggregations