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


Java RestResponse类代码示例

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


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

示例1: fetch

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Override
public List<Team> fetch() throws IOException {
    final JsonArray array = this.req.fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readArray();
    final List<Team> teams = new ArrayList<>();
    for(int idx=0; idx<array.size(); idx++) {
        teams.add(
            new RtTeam(
                array.getJsonObject(idx),
                this.orga,
                this.versionEye
            )
        );
    }
    return teams;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:21,代码来源:RtTeams.java

示例2: fetch

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Override
public List<Repository> fetch(final int page) throws IOException {
    final JsonArray results = this.req.uri()
        .queryParam("page", String.valueOf(page)).back().fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readObject()
        .getJsonArray("repos");
    final List<Repository> repositories = new ArrayList<>();
    for(int idx=0; idx<results.size(); idx++) {
        repositories.add(
            new RtRepository(results.getJsonObject(idx), this.req)
        );
    }
    return repositories;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:RtRepositories.java

示例3: repository

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Override
public Repository repository(final String repositoryKey)
    throws IOException {
    return new RtRepository(
        this.req.uri()
            .path(repositoryKey.replace('.', '~').replace('/', ':'))
            .back()
            .fetch()
            .as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_OK)
            .as(JsonResponse.class)
            .json()
            .readObject(),
        this.req
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:17,代码来源:RtRepositories.java

示例4: fetch

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Override
public List<Comment> fetch(final int page) throws IOException {
    final JsonArray array = this.req.uri()
        .queryParam("page", String.valueOf(page)).back().fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readObject()
        .getJsonArray("comments");
    final List<Comment> comments = new ArrayList<>();
    for(int idx=0; idx<array.size(); idx++) {
        comments.add(
            new RtComment(array.getJsonObject(idx))
        );
    }
    return comments;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:RtComments.java

示例5: fetch

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Override
public List<Project> fetch() throws IOException {
    final List<Project> projects = new ArrayList<>();
    final JsonArray fetched = this.req.uri()
        .queryParam("orga_name", this.team.organization().name())
        .queryParam("team_name", this.team.name()).back()
        .fetch().as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readArray();
    for(int idx = 0; idx<fetched.size(); idx++) {
        projects.add(
            new RtProject(this.req, this.team, fetched.getJsonObject(idx))
        );
    }
    return projects;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:RtProjects.java

示例6: fetch

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Override
public List<Favorite> fetch(final int page) throws IOException {
    final JsonArray array = this.req.uri()
        .queryParam("page", String.valueOf(page)).back().fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readObject()
        .getJsonArray("favorites");
    final List<Favorite> favorites = new ArrayList<>();
    for(int idx=0; idx<array.size(); idx++) {
        favorites.add(
            new RtFavorite(array.getJsonObject(idx))
        );
    }
    return favorites;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:RtFavorites.java

示例7: fetchOrgs

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
/**
 * Fetches the organizations that the authenticated user
 * has access to.
 * @return List of organizations.
 * @throws IOException If something goes wrong when
 *  making the HTTP call.
 */
private List<Organization> fetchOrgs() throws IOException {
    final JsonArray orgs = this.req.fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readArray();
    final List<Organization> organizations = new ArrayList<>();
    for(int idx=0; idx<orgs.size(); idx++) {
        organizations.add(
            new RtOrganization(
                orgs.getJsonObject(idx), this.req, this.versionEye
            )
        );
    }
    return organizations;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:25,代码来源:RtOrganizations.java

示例8: rendersHomePageViaHttp

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
/**
 * App can render front page.
 * @throws Exception If some problem inside
 */
@Test
public void rendersHomePageViaHttp() throws Exception {
    final Take app = new TkApp(new FakeBase());
    new FtRemote(app).exec(
        home -> {
            new JdkRequest(home)
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .as(XmlResponse.class)
                .assertXPath("/xhtml:html");
            new JdkRequest(home)
                .through(VerboseWire.class)
                .header("Accept", "application/xml")
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .as(XmlResponse.class)
                .assertXPath("/page/version");
        }
    );
}
 
开发者ID:yegor256,项目名称:rehttp,代码行数:27,代码来源:TkAppTest.java

示例9: export

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Override
public File export() throws IOException, URISyntaxException {
    final File file = File.createTempFile("report", ".zip");
    new LengthOf(
        new TeeInput(
            new InputOf(
                new URI(
                    this.req
                        .fetch()
                        .as(RestResponse.class)
                        .assertStatus(HttpURLConnection.HTTP_MOVED_TEMP)
                        .headers()
                        .get(HttpHeaders.LOCATION)
                        .get(0)
                )
            ),
            new OutputTo(
                file
            )
        )
    ).value();
    return file;
}
 
开发者ID:smallcreep,项目名称:streamrail-api-client,代码行数:24,代码来源:ExportReport.java

示例10: rendersHomePageViaHttp

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Test
public void rendersHomePageViaHttp() throws Exception {
    final Take app = new TkApp(new FkBase());
    new FtRemote(app).exec(
        home -> {
            new JdkRequest(home)
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .as(XmlResponse.class)
                .assertXPath("/xhtml:html");
            new JdkRequest(home)
                .through(VerboseWire.class)
                .header("accept", "application/xml")
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .as(XmlResponse.class)
                .assertXPath("/page/version");
        }
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:23,代码来源:TkAppTest.java

示例11: rendersOneReport

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Test
public void rendersOneReport() throws IOException {
    final Take app = new TkApp(Files.createTempDirectory("x"));
    new FtRemote(app).exec(
        home -> {
            new JdkRequest(home)
                .uri().path("org.jpeek")
                .path("jpeek")
                .path("index.html").back()
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK);
            new JdkRequest(String.format("%s/org.jpeek/jpeek/", home))
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_SEE_OTHER);
            new JdkRequest(String.format("%s/org.jpeek/jpeek", home))
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_SEE_OTHER);
        }
    );
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:24,代码来源:TkAppTest.java

示例12: fetch

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
/**
 * Get json Array projects.
 * @return Array projects
 * @throws Exception If fails
 */
private JsonArray fetch() throws Exception {
    if (this.response.get() != null) {
        final Optional<Request> next = this.response
            .get()
            .as(PaginationResponse.class)
            .next();
        if (next.has()) {
            this.response.set(
                next.value().fetch()
            );
        } else {
            throw new NoSuchElementException();
        }
    } else {
        this.response.set(this.req.fetch());
    }
    return this.response.get()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readObject()
        .getJsonArray(name);
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:30,代码来源:RtPaginationIterator.java

示例13: follow

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
/**
 * Follow link.
 * @param pointer Page's pointer
 * @return The same object
 * @throws IOException If fails
 */
private Optional<Request> follow(final String pointer) throws IOException {
    final String link = this.response
        .as(JsonResponse.class)
        .json()
        .readObject()
        .getString(pointer, "");
    final Optional<Request> request;
    if (link.isEmpty()) {
        request = new Optional.Empty<>();
    } else {
        request = new Optional.Single<>(
            new RestResponse(this).jump(URI.create(link))
        );
    }
    return request;
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:23,代码来源:PaginationResponse.java

示例14: rendersHomePageViaHttp

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
/**
 * App can render front page.
 * @throws Exception If some problem inside
 */
@Test
public void rendersHomePageViaHttp() throws Exception {
    final Take app = new TkApp(new FkBase());
    new FtRemote(app).exec(
        home -> {
            new JdkRequest(home)
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .as(XmlResponse.class)
                .assertXPath("/xhtml:html");
            new JdkRequest(home)
                .through(VerboseWire.class)
                .header("Accept", "application/xml")
                .fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .as(XmlResponse.class)
                .assertXPath("/page/version");
        }
    );
}
 
开发者ID:yegor256,项目名称:jare,代码行数:27,代码来源:TkAppTest.java

示例15: fetch

import com.jcabi.http.response.RestResponse; //导入依赖的package包/类
@Override
public List<JsonObject> fetch() throws IOException {
    List<JsonObject> filtered = new ArrayList<JsonObject>();
    JsonArray notifications = this.request().fetch()
        .as(RestResponse.class).assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class).json().readArray();
    this.lastReadAt = DateFormatUtils.formatUTC(
        new Date(System.currentTimeMillis()),
        "yyyy-MM-dd'T'HH:mm:ss'Z'"
    );
    log.info("Found " + notifications.size() + " new notifications!");
    if(notifications.size() > 0) {
        List<JsonObject> unfiltered = new ArrayList<JsonObject>();
        for(int i=0; i<notifications.size(); i++) {
            unfiltered.add(notifications.getJsonObject(i));
        }
        filtered = this.reason.filter(unfiltered);
    }
    return filtered;
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:21,代码来源:RtNotifications.java


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