当前位置: 首页>>代码示例>>Java>>正文


Java FakeRequest类代码示例

本文整理汇总了Java中com.jcabi.http.request.FakeRequest的典型用法代码示例。如果您正苦于以下问题:Java FakeRequest类的具体用法?Java FakeRequest怎么用?Java FakeRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FakeRequest类属于com.jcabi.http.request包,在下文中一共展示了FakeRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: returnsJson

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtProject can return itself as Json.
 */
@Test
public void returnsJson() {
    final JsonObject json = Json.createObjectBuilder()
        .add("name", "charles")
        .add("type", "maven")
        .add("language", "java")
        .build();
    final Project project = new RtProject(
        new FakeRequest(), Mockito.mock(Team.class), json
    );
    MatcherAssert.assertThat(
        project.json(),
        Matchers.equalTo(json)
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:RtProjectTestCase.java

示例2: hooksOnGithub

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtProject can hook itself to Github.
 * @throws IOException If something goes wrong.
 */
@Test
public void hooksOnGithub() throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED)
    ).start();
    Team team = Mockito.mock(Team.class);
    Mockito.when(team.versionEye())
        .thenReturn(
            new RtVersionEye(
                new JdkRequest(container.home())
            )
        );
    final Project project = new RtProject(
        new FakeRequest(), team,
        Json.createObjectBuilder().add("ids", "id123").build()
    );
    MatcherAssert.assertThat(project.hook(), Matchers.is(project));
    final MkQuery request = container.take();
    MatcherAssert.assertThat(
        request.method(), Matchers.equalTo("POST")
    );
    MatcherAssert.assertThat(
        request.uri().toString(), Matchers.equalTo("/github/hook/id123")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:30,代码来源:RtProjectTestCase.java

示例3: checksWhoAmI

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtUser can understand who am I.
 * @throws Exception If some problem inside
 */
@Test
public void checksWhoAmI() throws Exception {
    final String login = "monalia";
    final RtUser user = new RtUser(
        Mockito.mock(Github.class),
        new FakeRequest().withBody(
            Json.createObjectBuilder()
                .add("login", login)
                .build().toString()
        )
    );
    MatcherAssert.assertThat(
        user.login(),
        Matchers.equalTo(login)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:21,代码来源:RtUserTest.java

示例4: checksIfHeHasAName

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtUser can check if he has a name.
 * @throws Exception If some problem inside
 */
@Test
public void checksIfHeHasAName() throws Exception {
    final User.Smart smart = new User.Smart(
        new RtUser(
            Mockito.mock(Github.class),
            new FakeRequest().withBody(
                Json.createObjectBuilder()
                    .add("name", "octoc")
                    .build()
                    .toString()
            ),
            "octoc"
        )
    );
    MatcherAssert.assertThat(
        smart.hasName(),
        Matchers.equalTo(true)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:24,代码来源:RtUserTest.java

示例5: checksIfHeHasNoName

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtUser can check if he has NO name.
 * @throws Exception If some problem inside
 */
@Test
public void checksIfHeHasNoName() throws Exception {
    final User.Smart smart = new User.Smart(
        new RtUser(
            Mockito.mock(Github.class),
            new FakeRequest().withBody(
                Json.createObjectBuilder()
                    .build()
                    .toString()
            ),
            "octoc"
        )
    );
    MatcherAssert.assertThat(
        smart.hasName(),
        Matchers.equalTo(false)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:23,代码来源:RtUserTest.java

示例6: describeAsJson

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtUser can describe as a JSON object.
 *
 * @throws Exception if there is any problem
 */
@Test
public void describeAsJson() throws Exception {
    final RtUser user = new RtUser(
        Mockito.mock(Github.class),
        new FakeRequest().withBody(
            Json.createObjectBuilder()
                .add("name", "monalisa")
                .add("email", "[email protected]")
                .build()
                .toString()
        ),
        "octoc"
    );
    MatcherAssert.assertThat(
        user.json().toString(),
        Matchers.equalTo(
            "{\"name\":\"monalisa\",\"email\":\"[email protected]\"}"
        )
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:26,代码来源:RtUserTest.java

示例7: getTree

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtTrees can get tree.
 *
 * @throws Exception if some problem inside
 */
@Test
public void getTree() throws Exception {
    final String sha = "0abcd89jcabitest";
    final Trees trees = new RtTrees(
        new FakeRequest().withBody(
            Json.createObjectBuilder()
                .add("sha", sha)
                .build()
                .toString()
        ),
        repo()
    );
    MatcherAssert.assertThat(
        trees.get(sha).sha(), Matchers.equalTo(sha)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:22,代码来源:RtTreesTest.java

示例8: getTreeRec

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtTrees can get tree recursively.
 *
 * @throws Exception if some problem inside
 */
@Test
public void getTreeRec() throws Exception {
    final String sha = "0abcd89jcabitest";
    final Trees trees = new RtTrees(
        new FakeRequest().withBody(
            Json.createObjectBuilder()
                .add("sha", sha)
                .build()
                .toString()
        ),
        repo()
    );
    MatcherAssert.assertThat(
        trees.getRec(sha).sha(), Matchers.equalTo(sha)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:22,代码来源:RtTreesTest.java

示例9: canCompareInstances

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtContent should be able to compare different instances.
 *
 * @throws Exception when a problem occurs.
 */
@Test
public void canCompareInstances() throws Exception {
    final RtContent less = new RtContent(
        new FakeRequest(),
        this.repo(),
        "aaa"
    );
    final RtContent greater = new RtContent(
        new FakeRequest(),
        this.repo(),
        "zzz"
    );
    MatcherAssert.assertThat(
        less.compareTo(greater), Matchers.lessThan(0)
    );
    MatcherAssert.assertThat(
        greater.compareTo(less), Matchers.greaterThan(0)
    );
    MatcherAssert.assertThat(
        greater.compareTo(greater), Matchers.is(0)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:28,代码来源:RtContentTest.java

示例10: canFetchNonEmptyListOfReleases

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtReleases can fetch non empty list of releases.
 */
@Test
public void canFetchNonEmptyListOfReleases() {
    final int number = 1;
    final Releases releases = new RtReleases(
        new FakeRequest().withBody(
            Json.createArrayBuilder().add(
                Json.createObjectBuilder()
                    .add("id", number)
                    .add("tag_name", "v1.0.0")
                    .add("name", "v1.0.0")
                    .add("body", "Release")
            ).build().toString()
        ),
        RtReleasesTest.repo()
    );
    MatcherAssert.assertThat(
        releases.iterate().iterator().next().number(),
        Matchers.equalTo(number)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:24,代码来源:RtReleasesTest.java

示例11: removeGistComment

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtGistComment can remove comment.
 * @throws IOException if has some problems with json parsing.
 */
@Test
public final void removeGistComment() throws IOException {
    final int identifier = 1;
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
    ).start();
    final RtGist gist = new RtGist(
        new MkGithub(),
        new FakeRequest().withStatus(HttpURLConnection.HTTP_NO_CONTENT),
        "gistName"
    );
    final RtGistComment comment = new RtGistComment(
        new ApacheRequest(container.home()), gist, identifier
    );
    comment.remove();
    MatcherAssert.assertThat(
        container.take().method(),
        Matchers.equalTo(Request.DELETE)
    );
    container.stop();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:26,代码来源:RtGistCommentTest.java

示例12: returnIterator

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtRepoCommits can return commits' iterator.
 */
@Test
public void returnIterator() {
    final String sha = "6dcb09b5b57875f334f61aebed695e2e4193db51";
    final RepoCommits commits = new RtRepoCommits(
        new FakeRequest().withBody(
            Json.createArrayBuilder().add(
                // @checkstyle MultipleStringLiterals (1 line)
                Json.createObjectBuilder().add("sha", sha)
            ).build().toString()
        ),
        RtRepoCommitsTest.repo()
    );
    MatcherAssert.assertThat(
        commits.iterate(
            Collections.<String, String>emptyMap()
        ).iterator().next().sha(),
        Matchers.equalTo(sha)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:23,代码来源:RtRepoCommitsTest.java

示例13: comparesCommits

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtRepoCommits can compare two commits.
 */
@Test
public void comparesCommits() {
    final RepoCommits commits = new RtRepoCommits(
        new FakeRequest().withBody(
            Json.createObjectBuilder()
                .add("base_commit", Json.createObjectBuilder())
                .add("commits", Json.createArrayBuilder())
                .add("files", Json.createArrayBuilder())
                .build().toString()
        ),
        RtRepoCommitsTest.repo()
    );
    MatcherAssert.assertThat(
        commits.compare(
            "6dcb09b5b57875f334f61aebed695e2e4193db53",
            "6dcb09b5b57875f334f61aebed695e2e4193db54"
        ),
        Matchers.notNullValue(CommitsComparison.class)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:24,代码来源:RtRepoCommitsTest.java

示例14: comparesCommitsPatchFormat

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RtRepoCommits can compare two commits and present result in patch format.
 * @throws Exception If some problem inside
 */
@Test
public void comparesCommitsPatchFormat() throws Exception {
    final RepoCommits commits = new RtRepoCommits(
        new FakeRequest().withBody(
            "From 6dcb09b5b57875f33"
        ),
        RtRepoCommitsTest.repo()
    );
    MatcherAssert.assertThat(
        commits.patch(
            "6dcb09b5b57875f334f61aebed695e2e4193db57",
            "6dcb09b5b57875f334f61aebed695e2e4193db58"
        ),
        Matchers.startsWith("From")
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:21,代码来源:RtRepoCommitsTest.java

示例15: waitUntilReset

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * CarefulWire can wait until the limit reset.
 * @throws IOException If some problem inside
 */
@Test
public void waitUntilReset() throws IOException {
    final int threshold = 10;
    // @checkstyle MagicNumber (2 lines)
    final long reset = TimeUnit.MILLISECONDS
        .toSeconds(System.currentTimeMillis()) + 5L;
    new FakeRequest()
        .withStatus(HttpURLConnection.HTTP_OK)
        .withReason(OK)
        .withHeader(REMAINING_HEADER, "9")
        .withHeader("X-RateLimit-Reset", String.valueOf(reset))
        .through(CarefulWire.class, threshold)
        .fetch();
    final long now = TimeUnit.MILLISECONDS
        .toSeconds(System.currentTimeMillis());
    MatcherAssert.assertThat(now, Matchers.greaterThanOrEqualTo(reset));
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:22,代码来源:CarefulWireTest.java


注:本文中的com.jcabi.http.request.FakeRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。