use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtForkTest method patchAndCheckJsonFork.
/**
* RtFork can patch comment and return new json.
* @throws IOException if has some problems with json parsing.
*/
@Test
public void patchAndCheckJsonFork() throws IOException {
final String original = "some organization";
final String patched = "some patched organization";
final MkContainer container = new MkGrizzlyContainer().next(this.answer(original)).next(this.answer(patched)).next(this.answer(original)).start(this.resource.port());
final MkContainer forksContainer = new MkGrizzlyContainer().start(this.resource.port());
final RtRepo repo = new RtRepo(new MkGithub(), new ApacheRequest(forksContainer.home()), new Coordinates.Simple("test_user", "test_repo"));
final RtFork fork = new RtFork(new ApacheRequest(container.home()), repo, 1);
fork.patch(RtForkTest.fork(patched));
MatcherAssert.assertThat(new Fork.Smart(fork).organization(), Matchers.equalTo(patched));
MatcherAssert.assertThat(new Fork.Smart(fork).name(), Matchers.notNullValue());
container.stop();
forksContainer.stop();
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class PullRefTest method fetchesRepo.
/**
* PullRef.Smart can fetch its repo.
* @throws IOException If there is an I/O problem.
*/
@Test
public void fetchesRepo() throws IOException {
final Repo repo = new MkGithub().randomRepo();
MatcherAssert.assertThat(PullRefTest.pullRef(repo).repo().coordinates(), Matchers.equalTo(repo.coordinates()));
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class PullRefTest method fetchesUser.
/**
* PullRef.Smart can fetch its user.
* @throws IOException If there is an I/O problem.
*/
@Test
public void fetchesUser() throws IOException {
final Repo repo = new MkGithub().randomRepo();
MatcherAssert.assertThat(PullRefTest.pullRef(repo).user().login(), Matchers.equalTo(repo.coordinates().user()));
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtOrganizationTest method patchWithJson.
/**
* RtOrganization should be able to perform a patch request.
*
* @throws Exception if a problem occurs.
*/
@Test
public void patchWithJson() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "response")).start();
final RtOrganization org = new RtOrganization(new MkGithub(), new ApacheRequest(container.home()), "testPatch");
org.patch(Json.createObjectBuilder().add("patch", "test").build());
final MkQuery query = container.take();
try {
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PATCH));
MatcherAssert.assertThat(query.body(), Matchers.equalTo("{\"patch\":\"test\"}"));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtOrganizationTest method canCompareInstances.
/**
* RtOrganization should be able to compare instances of each other.
*
* @throws Exception if a problem occurs.
*/
@Test
public void canCompareInstances() throws Exception {
final RtOrganization less = new RtOrganization(new MkGithub(), new FakeRequest(), "abc");
final RtOrganization greater = new RtOrganization(new MkGithub(), new FakeRequest(), "def");
MatcherAssert.assertThat(less.compareTo(greater), Matchers.lessThan(0));
MatcherAssert.assertThat(greater.compareTo(less), Matchers.greaterThan(0));
MatcherAssert.assertThat(less.compareTo(less), Matchers.equalTo(0));
}
Aggregations