use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtOrganizationsTest method retrievesOrganizations.
/**
* RtOrganizations should be able to iterate
* the logged-in user's organizations.
*
* @throws Exception If a problem occurs
* @checkstyle MagicNumberCheck (25 lines)
*/
@Test
public void retrievesOrganizations() throws Exception {
final Github github = new MkGithub();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(org(1, "org1")).add(org(2, "org2")).add(org(3, "org3")).build().toString())).start(this.resource.port());
try {
final Organizations orgs = new RtOrganizations(github, new ApacheRequest(container.home()));
MatcherAssert.assertThat(orgs.iterate(), Matchers.<Organization>iterableWithSize(Tv.THREE));
MatcherAssert.assertThat(container.take().uri().toString(), Matchers.endsWith("/user/orgs"));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtOrganizationsTest method fetchesSingleOrganization.
/**
* RtOrganizations should be able to get a single organization.
*
* @throws Exception if a problem occurs
*/
@Test
public void fetchesSingleOrganization() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")).start(this.resource.port());
try {
final Organizations orgs = new RtOrganizations(new MkGithub(), new ApacheRequest(container.home()));
MatcherAssert.assertThat(orgs.get("org"), Matchers.notNullValue());
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtPullCommentTest method canCompareInstances.
/**
* RtPullComment should be able to compare different instances.
* @throws Exception If a problem occurs.
*/
@Test
public void canCompareInstances() throws Exception {
final Pull pull = Mockito.mock(Pull.class);
Mockito.doReturn(new MkGithub().randomRepo()).when(pull).repo();
final RtPullComment less = new RtPullComment(new FakeRequest(), pull, 1);
final RtPullComment greater = new RtPullComment(new FakeRequest(), pull, 2);
MatcherAssert.assertThat(less.compareTo(greater), Matchers.lessThan(0));
MatcherAssert.assertThat(greater.compareTo(less), Matchers.greaterThan(0));
MatcherAssert.assertThat(less.compareTo(less), Matchers.equalTo(0));
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtReferenceTest method fetchesContent.
/**
* RtReference should be able to fetch its json.
* @throws Exception - if something goes wrong.
*/
@Test
public void fetchesContent() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"ref\":\"refs/heads/featureB\"}")).start();
final Reference reference = new RtReference(new ApacheRequest(container.home()), new MkGithub().randomRepo(), "refs/heads/featureB");
try {
MatcherAssert.assertThat(reference.json().getString("ref"), Matchers.is("refs/heads/featureB"));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtReferenceTest method returnsOwner.
/**
* RtReference should be able to return its owner repo.
* @throws Exception - If something goes wrong.
*/
@Test
public void returnsOwner() throws Exception {
final Repo owner = new MkGithub().randomRepo();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"ref\":\"refs/heads/featureD\"}")).start();
final Reference reference = new RtReference(new ApacheRequest(container.home()), owner, "refs/heads/featureD");
try {
MatcherAssert.assertThat(reference.repo(), Matchers.is(owner));
} finally {
container.stop();
}
}
Aggregations