• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FakeRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: tolerateMissingRateLimitResetHeader

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * CarefulWire can tolerate the lack the X-RateLimit-Reset header.
 * @throws IOException If some problem inside
 */
@Test
public void tolerateMissingRateLimitResetHeader() throws IOException {
    final int threshold = 8;
    // @checkstyle MagicNumber (1 lines)
    new FakeRequest()
        .withStatus(HttpURLConnection.HTTP_OK)
        .withReason(OK)
        .withHeader(REMAINING_HEADER, "7")
        .through(CarefulWire.class, threshold)
        .fetch();
    MatcherAssert.assertThat(
        "Did not crash when X-RateLimit-Reset header was absent",
        true
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:20,代码来源:CarefulWireTest.java


示例17: tolerateMissingRateLimitResetHeader

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * RetryCarefulWire can tolerate the lack the X-RateLimit-Reset header.
 * @throws IOException If some problem inside
 */
@Test
public void tolerateMissingRateLimitResetHeader() throws IOException {
    final int threshold = 8;
    // @checkstyle MagicNumber (1 lines)
    new FakeRequest()
        .withStatus(HttpURLConnection.HTTP_OK)
        .withReason(OK)
        .withHeader(REMAINING_HEADER, "7")
        .through(RetryCarefulWire.class, threshold)
        .fetch();
    MatcherAssert.assertThat(
        "Did not crash when X-RateLimit-Reset header was absent",
        true
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:20,代码来源:RetryCarefulWireTest.java


示例18: fetchesCommits

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * CommitsComparison.Smart can fetch commits.
 * @throws Exception If some problem inside
 */
@Test
public void fetchesCommits() throws Exception {
    final String sha = "6dcb09b5b57875f334f61aebed695e2e4193db50";
    final CommitsComparison.Smart comparison = new CommitsComparison.Smart(
        new RtCommitsComparison(
            new FakeRequest().withBody(
                Json.createObjectBuilder()
                    .add("base_commit", Json.createObjectBuilder())
                    .add(
                        "commits",
                        Json.createArrayBuilder()
                            .add(Json.createObjectBuilder().add("sha", sha))
                    )
                    .add("files", Json.createArrayBuilder())
                    .build().toString()
            ),
            CommitsComparisonTest.repo(),
            "6dcb09b5b57875f334f61aebed695e2e4193db51",
            "6dcb09b5b57875f334f61aebed695e2e4193db52"
        )
    );
    MatcherAssert.assertThat(
        comparison.commits().iterator().next().sha(), Matchers.equalTo(sha)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:30,代码来源:CommitsComparisonTest.java


示例19: canCompareInstances

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * 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)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:28,代码来源:RtOrganizationTest.java


示例20: cachesJsonData

import com.jcabi.http.request.FakeRequest; //导入依赖的package包/类
/**
 * Bulk can cache JSON data.
 * @throws Exception If some problem inside
 */
@Test
public void cachesJsonData() throws Exception {
    final Comment origin = Mockito.mock(Comment.class);
    final Request request = new FakeRequest()
        .withBody("[{\"body\": \"hey you\"}]");
    final Comment comment = new Bulk<Comment>(
        new RtPagination<Comment>(
            request,
            new RtValuePagination.Mapping<Comment, JsonObject>() {
                @Override
                public Comment map(final JsonObject object) {
                    return origin;
                }
            }
        )
    ).iterator().next();
    MatcherAssert.assertThat(
        new Comment.Smart(comment).body(),
        Matchers.equalTo("hey you")
    );
    comment.number();
    Mockito.verify(origin).number();
    Mockito.verify(origin, Mockito.never()).json();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:29,代码来源:BulkTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityEnderman类代码示例发布时间:2022-05-23
下一篇:
Java BoundaryScanner类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap