io.restassured.response.Response.asString()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中io.restassured.response.Response.asString方法的一些代码示例,展示了Response.asString的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.asString方法的具体详情如下:
包路径:io.restassured.response.Response
类名称:Response
方法名:asString

Response.asString介绍

暂无

代码示例

代码示例来源:origin: rest-assured/rest-assured

public T specification(ResponseSpecification responseSpecification) {
  notNull(responseSpecification, ResponseSpecification.class);
  // We parse the response as a string here because we need to enforce it otherwise specs won't work
  response.asString();
  // The following is a work-around to enable logging of request and response if validation fails
  if (responseSpecification instanceof ResponseSpecificationImpl) {
    ResponseSpecificationImpl impl = (ResponseSpecificationImpl) responseSpecification;
    LogConfig globalLogConfig = responseSpec.getConfig().getLogConfig();
    if (globalLogConfig.isLoggingOfRequestAndResponseIfValidationFailsEnabled()) {
      impl.setConfig(impl.getConfig().logConfig(globalLogConfig));
      impl.setLogRepository(responseSpec.getLogRepository());
    }
    if (impl.getLogDetail() != null) {
      logResponse(impl.getLogDetail(), globalLogConfig.isPrettyPrintingEnabled(),
      globalLogConfig.defaultStream());
    }
  }
  // Finally validate the response
  responseSpecification.validate(response);
  return (T) this;
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyCreatedDrdDeployment(Deployment mockDeployment, Response response) {
 String content = response.asString();
 verifyDrdDeploymentValues(mockDeployment, content);
 verifyDeploymentLink(mockDeployment, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyCreatedEmptyDeployment(Deployment mockDeployment, Response response) {
 String content = response.asString();
 verifyDeploymentValuesEmptyDefinitions(mockDeployment, content);
 verifyDeploymentLink(mockDeployment, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyCreatedTaskAttachment(Attachment mockTaskAttachment, Response response, boolean urlExist) {
 String content = response.asString();
 verifyTaskAttachmentValues(mockTaskAttachment, content, urlExist);
 verifyTaskAttachmentLink(mockTaskAttachment, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyCreatedBpmnDeployment(Deployment mockDeployment, Response response) {
 String content = response.asString();
 verifyBpmnDeploymentValues(mockDeployment, content);
 verifyDeploymentLink(mockDeployment, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyCreatedTaskComment(Comment mockTaskComment, Response response) {
 String content = response.asString();
 verifyTaskCommentValues(mockTaskComment, content);
 verifyTaskCommentLink(mockTaskComment, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyCreatedDeployment(Deployment mockDeployment, Response response) {
 String content = response.asString();
 verifyDeploymentWithDefinitionsValues(mockDeployment, content);
 verifyDeploymentLink(mockDeployment, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyCreatedCmmnDeployment(Deployment mockDeployment, Response response) {
 String content = response.asString();
 verifyCmmnDeploymentValues(mockDeployment, content);
 verifyDeploymentLink(mockDeployment, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyCreatedDmnDeployment(Deployment mockDeployment, Response response) {
 String content = response.asString();
 verifyDmnDeploymentValues(mockDeployment, content);
 verifyDeploymentLink(mockDeployment, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testUnknownQueryParameter() {
 Response response = given()
  .queryParam("unknown", "unknown")
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(HISTORIC_BATCH_RESOURCE_URL);
 verify(queryMock, never()).batchId(anyString());
 verify(queryMock).list();
 verifyHistoricBatchListJson(response.asString());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testUnknownQueryParameter() {
 Response response = given()
  .queryParam("unknown", "unknown")
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(BATCH_RESOURCE_URL);
 verify(queryMock, never()).batchId(anyString());
 verify(queryMock).list();
 verifyBatchListJson(response.asString());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testQuery() {
 Response response = given()
  .then().expect()
   .statusCode(Status.OK.getStatusCode())
  .when()
   .get(BATCH_STATISTICS_URL);
 verify(queryMock).list();
 verifyNoMoreInteractions(queryMock);
 verifyBatchStatisticsListJson(response.asString());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testNoParametersQuery() {
 Response response = given()
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(BATCH_RESOURCE_URL);
 verify(queryMock).list();
 verifyNoMoreInteractions(queryMock);
 verifyBatchListJson(response.asString());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testNoParametersQuery() {
 Response response = given()
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(HISTORIC_BATCH_RESOURCE_URL);
 verify(queryMock).list();
 verifyNoMoreInteractions(queryMock);
 verifyHistoricBatchListJson(response.asString());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testGetStacktrace() {
 String stacktrace = "aStacktrace";
 when(mockManagementService.getJobExceptionStacktrace(MockProvider.EXAMPLE_JOB_ID)).thenReturn(stacktrace);
 Response response = given().pathParam("id", MockProvider.EXAMPLE_JOB_ID)
 .then().expect().statusCode(Status.OK.getStatusCode()).contentType(ContentType.TEXT)
 .when().get(JOB_RESOURCE_GET_STACKTRACE_URL);
 String content = response.asString();
 Assert.assertEquals(stacktrace, content);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testIncompleteExecution() {
 setUpMockExecutionQuery(createIncompleteMockExecutions());
 Response response = expect().statusCode(Status.OK.getStatusCode())
   .when().get(EXECUTION_QUERY_URL);
 String content = response.asString();
 String returnedProcessInstanceId = from(content).getString("[0].processInstanceId");
 Assert.assertNull("Should be null, as it is also null in the original execution on the server.",
   returnedProcessInstanceId);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testIncompleteProcessDefinition() {
 setUpMockDefinitionQuery(createIncompleteMockDefinitions());
 Response response = expect().statusCode(Status.OK.getStatusCode())
   .when().get(PROCESS_DEFINITION_QUERY_URL);
 String content = response.asString();
 String returnedResourceName = from(content).getString("[0].resource");
 Assert.assertNull("Should be null, as it is also null in the original process definition on the server.",
   returnedResourceName);
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void verifyExampleUserResponse(Response response) {
 String content = response.asString();
 List<String> instances = from(content).getList("");
 Assert.assertEquals("There should be one user returned.", 1, instances.size());
 Assert.assertNotNull("The returned user should not be null.", instances.get(0));
 String returendLastName = from(content).getString("[0].lastName");
 String returnedFirstName = from(content).getString("[0].firstName");
 String returnedEmail = from(content).getString("[0].email");
 Assert.assertEquals(MockProvider.EXAMPLE_USER_FIRST_NAME, returnedFirstName);
 Assert.assertEquals(MockProvider.EXAMPLE_USER_LAST_NAME, returendLastName);
 Assert.assertEquals(MockProvider.EXAMPLE_USER_EMAIL, returnedEmail);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testIncompleteProcessInstance() {
 setUpMockInstanceQuery(createIncompleteMockInstances());
 Response response = expect().statusCode(Status.OK.getStatusCode())
   .when().get(PROCESS_INSTANCE_QUERY_URL);
 String content = response.asString();
 String returnedBusinessKey = from(content).getString("[0].businessKey");
 Assert.assertNull("Should be null, as it is also null in the original process instance on the server.",
   returnedBusinessKey);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void verifyDeploymentResource(Resource mockDeploymentResource, Response response) {
 String content = response.asString();
 JsonPath path = from(content);
 String returnedId = path.get("id");
 String returnedName = path.get("name");
 String returnedDeploymentId = path.get("deploymentId");
 assertEquals(mockDeploymentResource.getId(), returnedId);
 assertEquals(mockDeploymentResource.getName(), returnedName);
 assertEquals(mockDeploymentResource.getDeploymentId(), returnedDeploymentId);
}

相关文章