Search in sources :

Example 21 with JdkRequest

use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.

the class RtIssuesTest method getSingleIssue.

/**
 * RtIssues can get a single issue.
 * @throws Exception if some problem inside
 */
@Test
public void getSingleIssue() throws Exception {
    final String title = "Unit test";
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, issue(title).toString())).start(this.resource.port());
    final RtIssues issues = new RtIssues(new JdkRequest(container.home()), repo());
    final Issue issue = issues.get(1);
    MatcherAssert.assertThat(new Issue.Smart(issue).title(), Matchers.equalTo(title));
    container.stop();
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 22 with JdkRequest

use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.

the class RtCollaboratorsTest method canIterate.

/**
 * RtCollaborators can iterate over a list of collaborators.
 * @throws Exception if any error occurs.
 */
@Test
public void canIterate() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(RtCollaboratorsTest.json("octocat")).add(RtCollaboratorsTest.json("dummy")).build().toString())).start(this.resource.port());
    final Collaborators users = new RtCollaborators(new JdkRequest(container.home()), this.repo());
    MatcherAssert.assertThat(users.iterate(), Matchers.<User>iterableWithSize(2));
    container.stop();
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 23 with JdkRequest

use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.

the class RtCollaboratorsTest method userCanBeRemoved.

/**
 * User can be removed from a list of collaborators.
 * @throws Exception if any error occurs.
 */
@Test
public void userCanBeRemoved() 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.remove("dummy");
        final MkQuery query = container.take();
        MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
    } finally {
        container.stop();
    }
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) MkQuery(com.jcabi.http.mock.MkQuery) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 24 with JdkRequest

use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.

the class RtCollaboratorsTest method userCanBeTestForBeingCollaborator.

/**
 * User can be checked for being a collaborator.
 * @throws Exception if any error occurs.
 */
@Test
public void userCanBeTestForBeingCollaborator() 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 {
        MatcherAssert.assertThat(users.isCollaborator("octocat2"), Matchers.equalTo(true));
    } finally {
        container.stop();
    }
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 25 with JdkRequest

use of com.jcabi.http.request.JdkRequest 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();
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Aggregations

JdkRequest (com.jcabi.http.request.JdkRequest)32 Test (org.junit.Test)32 MkContainer (com.jcabi.http.mock.MkContainer)31 MkGrizzlyContainer (com.jcabi.http.mock.MkGrizzlyContainer)31 MkAnswer (com.jcabi.http.mock.MkAnswer)8 MkQuery (com.jcabi.http.mock.MkQuery)4 MkGithub (com.jcabi.github.mock.MkGithub)2 RestResponse (com.jcabi.http.response.RestResponse)2 XmlResponse (com.jcabi.http.response.XmlResponse)1 ArrayMap (com.jcabi.immutable.ArrayMap)1 FkBase (io.wring.fake.FkBase)1 EnumMap (java.util.EnumMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Take (org.takes.Take)1 FtRemote (org.takes.http.FtRemote)1