本文整理了Java中com.jayway.restassured.response.Response.as
方法的一些代码示例,展示了Response.as
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.as
方法的具体详情如下:
包路径:com.jayway.restassured.response.Response
类名称:Response
方法名:as
暂无
代码示例来源:origin: stackoverflow.com
Response response = given().body(requestBody).when().post("/admin");
Result result = response.as(Result.class);
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@Nonnull
public Iterable<RestMinimalApplicationLink> getAllApplinks() {
return ImmutableList.copyOf(applinksTester.get(SimpleRestRequest.DEFAULT_INSTANCE)
.as(RestMinimalApplicationLink[].class));
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
/**
* @param credentials credentials to log in with
* @return authentication cookie value to use for subsequent interactions with the product
*/
@Nonnull
@SuppressWarnings("ConstantConditions")
public String getAuthentication(@Nonnull TestAuthentication credentials) {
Response response = authTester.get(AuthRequest.forCredentials(credentials));
String authCookie = response.as(BaseRestEntity.class).getString(SESSION_ID);
checkState(authCookie != null, "Auth cookie was not set for base URL: " + baseUrl);
return authCookie;
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@Nonnull
public RestMinimalApplicationLink getApplink(String id) {
return applinksTester.get(new CustomizableRestRequest.Builder().addPath(id).build())
.as(RestMinimalApplicationLink.class);
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@SuppressWarnings("unchecked")
public List<ApplinkTypeMetadata> getApplicationTypeMetadata() {
List<ApplinkTypeMetadata> applicationList = new ArrayList<ApplinkTypeMetadata>();
List<Map<String, String>> applicationTypes = tester.get(new CustomizableRestRequest.Builder()
.addPath(APPLICATION_TYPE_RESOURCE_PATH)
.build()).as(List.class);
for (Map<String, String> application : applicationTypes) {
applicationList.add(new ApplinkTypeMetadata(application));
}
return applicationList;
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@SuppressWarnings("unchecked")
public List<ApplinkTypeMetadata> getEntityTypeMetadata() {
List<ApplinkTypeMetadata> entityList = new ArrayList<ApplinkTypeMetadata>();
List<Map<String, String>> entityTypes = tester.get(new CustomizableRestRequest.Builder()
.addPath(ENTITY_TYPE_RESOURCE_PATH)
.build()).as(List.class);
for (Map<String, String> entity : entityTypes) {
entityList.add(new ApplinkTypeMetadata(entity));
}
return entityList;
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@Nonnull
public ApplinkOAuthStatus getOAuthStatus(@Nonnull TestedInstance instance, @Nonnull String applinkId) {
checkNotNull(applinkId, "applinkId");
Response response = new ApplinkStatusRestTester(instance).getOAuth(new ApplinkOAuthStatusRequest.Builder(applinkId)
.authentication(TestAuthentication.admin())
.expectStatus(OK)
.build());
return response.as(RestApplinkOAuthStatus.class).asDomain();
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@Nullable
public String getProperty(@Nonnull String key) {
Response response = systemPropertiesTester.get(new PropertyRequest.Builder(key)
.expectStatus(okOrNotFound())
.build());
return response.getStatusCode() == Status.OK.getStatusCode() ?
response.as(BaseRestEntity.class).getString(VALUE_PROPERTY) :
null;
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@Nonnull
public RestAccessToken addConsumerToken(@Nonnull TestApplink.Side side, @Nonnull String username,
@Nonnull RestAccessToken token) {
Response response = createConsumerTester(side.product()).put(new CustomizableRestRequest.Builder()
.addPath(side.id())
.addPath(username)
.body(token)
.expectStatus(Status.CREATED)
.build());
return response.as(RestAccessToken.class);
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@Nonnull
public RestAccessToken getServiceProviderAccessToken(@Nonnull TestApplink.Side side, @Nonnull String username) {
Response response = createServiceProviderTester(side.product()).get(new CustomizableRestRequest.Builder()
.addPath(side.id())
.addPath(username)
.expectStatus(Status.OK)
.build());
return response.as(RestAccessToken.class);
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
@Nonnull
public RestAccessToken createServiceProviderToken(@Nonnull TestApplink.Side side, @Nonnull String username) {
Response response = createServiceProviderTester(side.product()).put(new CustomizableRestRequest.Builder()
.addPath(side.id())
.addPath(username)
.expectStatus(Status.CREATED)
.build());
return response.as(RestAccessToken.class);
}
代码示例来源:origin: com.atlassian.applinks/applinks-func-test-rest-common
public RestAccessToken getConsumerToken(@Nonnull TestApplink.Side side, @Nonnull String username) {
Response response = createConsumerTester(side.product()).get(new CustomizableRestRequest.Builder()
.addPath(side.id())
.addPath(username)
.expectStatus(Status.OK)
.build());
return response.as(RestAccessToken.class);
}
代码示例来源:origin: com.ixortalk/ixortalk-test
public static OAuth2AccessToken getClientCredentialsAccessToken(String clientId, String clientSecret) {
return given()
.parameters("grant_type", "client_credentials")
.auth()
.preemptive()
.basic(clientId, clientSecret)
.when()
.post("/oauth/token")
.as(OAuth2AccessToken.class);
}
代码示例来源:origin: org.w3/ldp-testsuite
public Model getResourceAsModel(String uri, String mediaType) {
return buildBaseRequestSpecification()
.header(ACCEPT, mediaType)
.expect()
.statusCode(isSuccessful())
.when()
.get(uri).as(Model.class, new RdfObjectMapper(uri));
}
代码示例来源:origin: org.w3/ldp-testsuite
@Test(
groups = {SHOULD},
description = "LDP servers should respond with a text/turtle representation of the "
+ "requested LDP-RS whenever the Accept request header is absent [turtle].")
@SpecTest(
specRefUri = LdpTestSuite.SPEC_URI + "#ldprs-get-conneg",
testMethod = METHOD.AUTOMATED,
approval = STATUS.WG_APPROVED)
public void testGetResourceAsTurtleNoAccept() {
// No Accept header
buildBaseRequestSpecification()
.expect().statusCode(isSuccessful()).contentType(TEXT_TURTLE)
.when().get(getResourceUri()).as(Model.class, new RdfObjectMapper(getResourceUri()));
}
代码示例来源:origin: com.ixortalk/ixortalk-test
public static OAuth2AccessToken getPasswordGrantAccessToken(String username, String password) {
return given()
.when()
.contentType(APPLICATION_FORM_URLENCODED_VALUE)
.formParam("grant_type", "password")
.formParam("username", username)
.formParam("password", password)
.formParam("client_id", CLIENT_ID_ADMIN)
.formParam("client_secret", CLIENT_SECRET_ADMIN)
.post("/oauth/token")
.as(OAuth2AccessToken.class);
}
代码示例来源:origin: Talend/components
@Test
public void testValidatePropertiesJsonio() throws Exception {
ObjectNode validationResult = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) //
.expect() //
.statusCode(200).log().ifError() //
.with() //
.content(buildTestDataStoreSerProps()) //
.contentType(ServiceConstants.JSONIO_CONTENT_TYPE) //
.post(getVersionPrefix() + "/properties/validate").as(ObjectNode.class);
assertNotNull(validationResult);
assertEquals("OK", validationResult.get("status").textValue());
}
代码示例来源:origin: Talend/components
@Test
public void testValidateProperties() throws Exception {
ObjectNode validationResult = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) //
.expect() //
.statusCode(200).log().ifError() //
.with() //
.content(buildTestDataStoreFormData()) //
.contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) //
.post(getVersionPrefix() + "/properties/validate").as(ObjectNode.class);
assertNotNull(validationResult);
assertEquals("OK", validationResult.get("status").textValue());
}
代码示例来源:origin: Talend/components
@Test
public void testGetSchema_wrongSql() throws java.io.IOException {
// given
UiSpecsPropertiesDto datasetConnectionInfo = new UiSpecsPropertiesDto();
datasetConnectionInfo.setProperties(mapper.readValue(
getClass().getResourceAsStream("jdbc_data_set_properties_no_schema_wrong_table_name.json"), ObjectNode.class));
datasetConnectionInfo.setDependencies(singletonList(getJdbcDataStoreProperties()));
String dataSetDefinitionName = "JDBCDataset";
// when
ApiError response = given().content(datasetConnectionInfo).contentType(APPLICATION_JSON_UTF8_VALUE) //
.accept(APPLICATION_JSON_UTF8_VALUE) //
.expect().statusCode(400).log().ifValidationFails() //
.post(getVersionPrefix() + "/runtimes/schema").as(ApiError.class);
// then
assertEquals("TCOMP_JDBC_SQL_SYNTAX_ERROR", response.getCode());
assertEquals("Table/View 'TOTO' does not exist.", response.getMessage());
}
代码示例来源:origin: Talend/components
@Test
public void testTriggerOnProperty_nonExistentTrigger() throws Exception {
String callback = "toto";
String propName = "tagId";
ApiError errorContainer = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) //
.expect() //
.statusCode(400).log().ifValidationFails() //
.with() //
.content(buildTestDataStoreFormData()) //
.contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) //
.post(getVersionPrefix() + "/properties/trigger/{callback}/{propName}", callback, propName).as(ApiError.class);
assertEquals("Talend_ALL_UNEXPECTED_ARGUMENT", errorContainer.getCode());
assertNotNull(errorContainer.getMessageTitle());
assertNotNull(errorContainer.getMessage());
}
内容来源于网络,如有侵权,请联系作者删除!