本文整理汇总了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;
}
示例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;
}
示例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
);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
);
}
示例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;
}
示例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");
}
);
}
示例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);
}
);
}
示例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);
}
示例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;
}
示例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");
}
);
}
示例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;
}