Search in sources :

Example 26 with JdkRequest

use of com.jcabi.http.request.JdkRequest 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();
}
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 27 with JdkRequest

use of com.jcabi.http.request.JdkRequest 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();
}
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 28 with JdkRequest

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

the class RtForksTest method createsFork.

/**
 * RtForks should be able to create a new fork.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void createsFork() throws Exception {
    final String organization = RandomStringUtils.randomAlphanumeric(10);
    final MkAnswer answer = new MkAnswer.Simple(HttpURLConnection.HTTP_OK, fork(organization).toString());
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_ACCEPTED, fork(organization).toString())).next(answer).start(this.resource.port());
    final Repo owner = Mockito.mock(Repo.class);
    final Coordinates coordinates = new Coordinates.Simple("test_user", "test_repo");
    Mockito.doReturn(coordinates).when(owner).coordinates();
    final RtForks forks = new RtForks(new JdkRequest(container.home()), owner);
    final Fork fork = forks.create(organization);
    MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
    MatcherAssert.assertThat(fork.json().getString(ORGANIZATION), Matchers.equalTo(organization));
    container.stop();
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) MkAnswer(com.jcabi.http.mock.MkAnswer) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 29 with JdkRequest

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

the class RtLabelsTest method deleteLabel.

/**
 * RtLabels can delete a label.
 * @throws Exception if some problem inside
 */
@Test
public void deleteLabel() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
    final RtLabels issues = new RtLabels(new JdkRequest(container.home()), repo());
    issues.delete("issue");
    final MkQuery query = container.take();
    MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
    MatcherAssert.assertThat(query.body(), Matchers.isEmptyOrNullString());
    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 30 with JdkRequest

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

the class RtLabelsTest method getSingleLabel.

/**
 * RtLabels can get a single label.
 *
 * @throws Exception if some problem inside
 */
@Test
public void getSingleLabel() throws Exception {
    final String name = "bug";
    final String color = "f29513";
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, label(name, color).toString())).start();
    final RtLabels issues = new RtLabels(new JdkRequest(container.home()), repo());
    final Label label = issues.get(name);
    MatcherAssert.assertThat(new Label.Smart(label).color(), Matchers.equalTo(color));
    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