@Test(description = "classid为99999999", priority = 4)
 public void testErrclassid01() {
   Response response =
       TestConfig.getOrDeleteExecu("get", "/classes/9999999999/unteam_user?access_token=" + token);
   response.then().assertThat().statusCode(404);
   // body("status",equalTo(false)).body("message", equalTo("班次信息不存在"));
 }
  @Test
  public void testIncludeJobsWithoutTenantIdPostParameter() {
    List<Job> jobs =
        Arrays.asList(
            MockProvider.mockJob().tenantId(null).build(),
            MockProvider.mockJob().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
    mockQuery = setUpMockJobQuery(jobs);

    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("tenantIdIn", new String[] {MockProvider.EXAMPLE_TENANT_ID});
    queryParameters.put("includeJobsWithoutTenantId", true);

    Response response =
        given()
            .contentType(POST_JSON_CONTENT_TYPE)
            .body(queryParameters)
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .post(JOBS_RESOURCE_URL);

    verify(mockQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
    verify(mockQuery).includeJobsWithoutTenantId();
    verify(mockQuery).list();

    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(null);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
  }
  @Test(
      groups = {SHOULD},
      description =
          "LDP clients SHOULD use the HTTP If-Match header and HTTP ETags "
              + "to ensure it isn’t modifying a resource that has changed since the "
              + "client last retrieved its representation. LDP servers SHOULD require "
              + "the HTTP If-Match header and HTTP ETags to detect collisions.")
  @SpecTest(
      specRefUri = LdpTestSuite.SPEC_URI + "#ldpr-put-precond",
      testMethod = METHOD.AUTOMATED,
      approval = STATUS.WG_APPROVED,
      comment =
          "Covers only part of the specification requirement. "
              + "testConditionFailedStatusCode, testPreconditionRequiredStatusCode "
              + "and testPutBadETag covers the rest.")
  public void testPutRequiresIfMatch() throws URISyntaxException {
    skipIfMethodNotAllowed(HttpMethod.PUT);

    String resourceUri = getResourceUri();
    Response response =
        buildBaseRequestSpecification()
            .expect()
            .statusCode(isSuccessful())
            .header(ETAG, isValidEntityTag())
            .when()
            .get(resourceUri);

    buildBaseRequestSpecification()
        .contentType(response.getContentType())
        .body(response.asByteArray())
        .expect()
        .statusCode(not(isSuccessful()))
        .when()
        .put(resourceUri);
  }
  @Test
  public void greeting_accessible_with_token() throws Exception {
    AuthenticationRequest authRequest = new AuthenticationRequest("user", "password");

    // @formatter:off
    Response tokenResponse =
        given()
            .contentType("application/json")
            .body(authRequest)
            .when()
            .post("/auth/login")
            .then()
            .statusCode(HttpStatus.SC_OK)
            .extract()
            .response();
    // @formatter:on

    String token = tokenResponse.getBody().jsonPath().getString("token");
    logger.debug("Token: {}", token);

    // @formatter:off
    given()
        .header(new Header("X-Auth-Token", token))
        .param("name", "jdoe")
        .when()
        .get("/hello")
        .then()
        .contentType("application/json")
        .statusCode(HttpStatus.SC_OK)
        .body("greeting", equalTo("Hello jdoe"));
    // @formatter:on
  }
  @Test
  public void testIncludeJobsWithoutTenantIdParameter() {
    List<Job> jobs =
        Arrays.asList(
            MockProvider.mockJob().tenantId(null).build(),
            MockProvider.mockJob().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
    mockQuery = setUpMockJobQuery(jobs);

    Response response =
        given()
            .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID)
            .queryParam("includeJobsWithoutTenantId", true)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(JOBS_RESOURCE_URL);

    verify(mockQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
    verify(mockQuery).includeJobsWithoutTenantId();
    verify(mockQuery).list();

    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(null);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
  }
  @Test
  public void testCaseDefinitionTenantIdList() {
    mockedQuery = createMockCaseDefinitionQuery(MockProvider.createMockTwoCaseDefinitions());

    Response response =
        given()
            .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(CASE_DEFINITION_QUERY_URL);

    verify(mockedQuery)
        .tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
    verify(mockedQuery).list();

    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
  }
 public String createDir(String user, String password, String dir, String permsOctal, int status) {
   getMock("WEBHDFS")
       .expect()
       .method("PUT")
       .pathInfo("/v1" + dir)
       .queryParam("op", "MKDIRS")
       .queryParam("user.name", user)
       .queryParam("permission", permsOctal)
       .respond()
       .status(HttpStatus.SC_OK)
       .contentType("application/json")
       .content("{\"boolean\": true}".getBytes());
   Response response =
       given()
           // .log().all()
           .auth()
           .preemptive()
           .basic(user, password)
           .header("X-XSRF-Header", "jksdhfkhdsf")
           .queryParam("op", "MKDIRS")
           .queryParam("permission", permsOctal)
           .expect()
           // .log().all()
           .statusCode(status)
           .contentType("application/json")
           .content("boolean", equalTo(true))
           .when()
           .put(getUrl("WEBHDFS") + "/v1" + dir + (isUseGateway() ? "" : "?user.name=" + user));
   String location = response.getHeader("Location");
   return location;
 }
  @Test
  public void sessionIMChatAccept8()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 3 has received a chat message");

    receiveMessageStatusURL = INVALID;

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text",
                    Matchers.hasItem("I am good"),
                "notificationList.messageNotification.sessionId", Matchers.hasItem(sessionID),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress",
                    Matchers.hasItem(Setup.TestUser4Contact),
                "notificationList.messageNotification.link", Matchers.notNullValue())
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());

    receiveMessageStatusURL =
        response.jsonPath().getString("notificationList.messageNotification[0].link[0].href");
    System.out.println("message status URL = " + receiveMessageStatusURL);
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
    Setup.endTest();
  }
  @Test
  public void sessionIMChatAccept13()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.majorTest("Chat/IM", "isComposing functionality between users 3 and 4");

    Setup.startTest("Send isComposing from User 3");
    IsComposing isComposing = new IsComposing("active", new java.util.Date(), "text/plain", 60);
    ObjectMapper mapper = new ObjectMapper();
    String jsonRequestData = "{\"isComposing\":" + mapper.writeValueAsString(isComposing) + "}";

    System.out.println("Sending " + jsonRequestData);
    RestAssured.authentication = RestAssured.basic(Setup.TestUser3, Setup.applicationPassword);
    Response resp =
        RestAssured.given()
            .contentType("application/json")
            .body(jsonRequestData)
            .expect()
            .log()
            .ifError()
            .statusCode(204)
            .post(Setup.sendIMURL(Setup.TestUser3, Setup.TestUser4Contact, sessionID));

    System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString());
    Setup.endTest();
  }
  @Test
  public void sessionIMChatAccept2() {
    Setup.startTest("Checking IM notifications for user 3");
    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList", Matchers.notNullValue())
            .post(url);
    System.out.println(
        "Response = " + notifications3.getStatusCode() + " / " + notifications3.asString());

    /*
    * {"notificationList":[{"messageStatusNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatMessage","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004//messages/1352666437776-470267184"}],
    * "status":"Delivered","messageId":"1352666437776-470267184"}},
    * {"messageStatusNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatMessage","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004//messages/1352666437776-470267184"}],
    * "status":"Displayed","messageId":"1352666437776-470267184"}},
    * {"chatEventNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatSessionInformation","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004/373305033"}],
    * "eventType":"Accepted","sessionId":"373305033"}}]}

    */
    JsonPath jsonData = notifications3.jsonPath();
    sentMessageID = jsonData.getString("notificationList.messageStatusNotification[0].messageId");
    System.out.println("Extracted messageId=" + sentMessageID);
    sendSessionURL = jsonData.getString("notificationList.chatEventNotification.link[0].href[0]");
    System.out.println("Extracted sendSessionURL=" + sendSessionURL);
    sessionID = jsonData.getString("notificationList.chatEventNotification.sessionId[0]");
    System.out.println("Extracted sessionId=" + sessionID);

    Setup.endTest();
  }
 @Test
 public void sessionIMChatAccept5() {
   Setup.startTest("Checking IM notifications for user 4");
   String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.messageNotification[0].senderAddress",
                   Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact)),
               "notificationList.messageNotification[0].chatMessage.text",
                   Matchers.equalTo("hello user4"))
           .post(url);
   System.out.println(
       "Response = " + notifications4.getStatusCode() + " / " + notifications4.asString());
   /*
    * {"notificationList":[{"messageNotification":
    * {"callbackData":"GSMA3","link":
    * [{"rel":"MessageStatusReport","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000004/oneToOne/tel%3A%2B15554000003/-797939895/messages/1352475373833-1790113032/status"}],
    * "dateTime":"2012-11-09T15:36:13Z","chatMessage":{"text":"hello user4"},"sessionId":"-797939895","messageId":"1352475373833-1790113032",
    * "senderAddress":"tel:+15554000003"}}]}
    */
   try {
     Thread.sleep(1000);
   } catch (InterruptedException e) {
   }
   Setup.endTest();
 }
  @Test
  public void sessionIMChatAccept1A() {
    Setup.startTest("Checking IM notifications for user 4");
    String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.chatSessionInvitationNotification", Matchers.notNullValue(),
                "notificationList.messageNotification.dateTime", Matchers.notNullValue(),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress[0]",
                    Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact)))
            .post(url);
    System.out.println(
        "Response = " + notifications4.getStatusCode() + " / " + notifications4.asString());

    JsonPath jsonData = notifications4.jsonPath();

    receiveSessionURL =
        jsonData.getString("notificationList.chatSessionInvitationNotification[0].link[0].href");
    System.out.println("Extracted receiveSessionURL=" + receiveSessionURL);

    receiveSessionID = jsonData.getString("notificationList.messageNotification.sessionId[0]");
    System.out.println("Extracted receiveSessionID=" + receiveSessionID);

    receiveMessageID = jsonData.getString("notificationList.messageNotification.messageId[0]");
    System.out.println("Extracted receiveMessageID=" + receiveMessageID);

    Setup.endTest();
  }
  @Override
  public List<EDITOR> readAll(CONTEXT context) {
    Response response =
        context
            .getSession()
            .given()
            .contentType(getContentType())
            .header(Headers.acceptJson())
            .get(
                "/rest/applications/{variantID}/installations", context.getParent().getVariantID());

    UnexpectedResponseException.verifyResponse(response, HttpStatus.SC_OK);

    List<EDITOR> editors = new ArrayList<EDITOR>();

    JsonPath jsonPath = response.jsonPath();

    List<Map<String, ?>> items = jsonPath.getList("");

    for (int i = 0; i < items.size(); i++) {
      jsonPath.setRoot("[" + i + "]");

      EDITOR editor = demarshall(context, jsonPath);
      editors.add(editor);
    }

    return editors;
  }
  @Test
  public void testSimpleJobQuery() {
    String jobId = MockProvider.EXAMPLE_JOB_ID;

    Response response =
        given()
            .queryParam("jobId", jobId)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(JOBS_RESOURCE_URL);

    InOrder inOrder = inOrder(mockQuery);
    inOrder.verify(mockQuery).jobId(jobId);
    inOrder.verify(mockQuery).list();

    String content = response.asString();
    List<String> instances = from(content).getList("");
    Assert.assertEquals("There should be one job returned.", 1, instances.size());
    Assert.assertNotNull("The returned job should not be null.", instances.get(0));

    String returnedJobId = from(content).getString("[0].id");
    String returnedProcessInstanceId = from(content).getString("[0].processInstanceId");
    String returendExecutionId = from(content).getString("[0].executionId");
    String returnedExceptionMessage = from(content).getString("[0].exceptionMessage");

    Assert.assertEquals(MockProvider.EXAMPLE_JOB_ID, returnedJobId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId);
    Assert.assertEquals(MockProvider.EXAMPLE_EXECUTION_ID, returendExecutionId);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_NO_EXCEPTION_MESSAGE, returnedExceptionMessage);
  }
  @Test
  public void test07Create_WithAmpersandInUserName() {
    TestUtils.mmxApiHeaders.put("X-mmx-app-owner", TestUtils.appOwner);
    String payload =
        "{\n"
            + "  \"username\": \"amazing&user\",\n"
            + "  \"password\": \"pass\",\n"
            + "  \"appId\": "
            + "\""
            + TestUtils.appId
            + "\",\n"
            + "  \"name\": \"test1 user\",\n"
            + "  \"email\": \"[email protected]\",\n"
            + "  \"isAdmin\" : true\n"
            + "}";
    Response responsePost =
        given()
            .log()
            .all()
            .authentication()
            .preemptive()
            .basic(TestUtils.user, TestUtils.pass)
            .contentType(TestUtils.JSON)
            .headers(TestUtils.toHeaders(TestUtils.mmxApiHeaders))
            .body(payload)
            .when()
            .post("/mmxadmin/rest/v1/user");

    responsePost
        .then()
        .statusCode(400)
        .body("code", equalTo(48))
        .body("message", containsString(INVALID_CHAR_MESSAGE));
  }
  @Test
  public void sessionIMChatAccept18()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 4 has received composing notification");

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.messageNotification[0].isComposing.refresh", Matchers.equalTo(60),
                "notificationList.messageNotification[0].isComposing.status",
                    Matchers.equalTo("idle"),
                "notificationList.messageNotification[0].sessionId",
                    Matchers.equalTo(receiveSessionID),
                "notificationList.messageNotification[0].senderAddress",
                    Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact)))
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());
    Setup.endTest();
  }
  @Test
  public void testCaseDefinitionRetrievalByList() {
    mockedQuery = createMockCaseDefinitionQuery(MockProvider.createMockTwoCaseDefinitions());

    Response response =
        given()
            .queryParam("caseDefinitionIdIn", MockProvider.EXAMPLE_CASE_DEFINITION_ID_LIST)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(CASE_DEFINITION_QUERY_URL);

    // assert query invocation
    InOrder inOrder = Mockito.inOrder(mockedQuery);
    inOrder
        .verify(mockedQuery)
        .caseDefinitionIdIn(
            MockProvider.EXAMPLE_CASE_DEFINITION_ID,
            MockProvider.ANOTHER_EXAMPLE_CASE_DEFINITION_ID);
    inOrder.verify(mockedQuery).list();

    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);

    String returnedDefinitionId1 = from(content).getString("[0].id");
    String returnedDefinitionId2 = from(content).getString("[1].id");

    assertThat(returnedDefinitionId1).isEqualTo(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
    assertThat(returnedDefinitionId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_CASE_DEFINITION_ID);
  }
  @Test
  public void sessionIMChatAccept21()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Send invalid isComposing from User 4");
    IsComposing isComposing = new IsComposing("rubbish", new java.util.Date(), "text/plain", 60);
    ObjectMapper mapper = new ObjectMapper();
    String jsonRequestData = "{\"isComposing\":" + mapper.writeValueAsString(isComposing) + "}";

    System.out.println("Sending " + jsonRequestData);
    RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword);
    Response resp =
        RestAssured.given()
            .contentType("application/json")
            .body(jsonRequestData)
            .expect()
            .log()
            .ifError()
            .statusCode(400)
            .post(Setup.sendIMURL(Setup.TestUser4, Setup.TestUser3Contact, receiveSessionID));
    /*
     * 400 / {"requestError": {"serviceException": {
     * "messageId":"SVC002","variables": ["State is not valid. Received 'rubbish'"],"text":"Invalid input value for message. Part %0"}}}
     */
    System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString());
    Setup.endTest();
  }
  @Test
  public final void whenResourcesAreRetrievedSorted_then200IsReceived() {
    final Response response =
        getAPI().findAllSortedAsResponse(SearchField.name.name(), Sort.Direction.ASC.name(), null);

    assertThat(response.getStatusCode(), is(200));
  }
  @Test
  public void sessionIMChatAccept23()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 3 has received chat closed notification");

    System.out.println("sessionID=" + sessionID);
    System.out.println("receiveSessionID=" + receiveSessionID);

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList.chatEventNotification.eventType",
                    Matchers.hasItem("SessionEnded"),
                "notificationList.chatEventNotification.sessionId", Matchers.hasItem(sessionID),
                "notificationList.chatEventNotification.link[0].rel",
                    Matchers.hasItem("ChatSessionInformation"))
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());
    Setup.endTest();
  }
Exemple #21
0
  @Test
  @RunAsClient
  public void testResourceOwnerPasswordFlowWithFormClientCredentials() throws Exception {
    RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();

    Response response =
        given()
            .redirects()
            .follow(false)
            .contentType("application/x-www-form-urlencoded")
            .formParam("grant_type", "password")
            .formParam("username", "jduke")
            .formParam("password", "1234")
            .formParam("client_id", "sample")
            .formParam("client_secret", "password")
            .when()
            .post(SampleRequest.TOKEN_ENDPOINT)
            .then()
            .statusCode(200)
            .body("access_token", Matchers.not(Matchers.isEmptyOrNullString()))
            .body("refresh_token", Matchers.not(Matchers.isEmptyOrNullString()))
            .body("expires_in", Matchers.not(Matchers.isEmptyOrNullString()))
            .body("token_type", Matchers.is("Bearer"))
            .header("Pragma", "no-cache")
            .header("Cache-Control", "no-store")
            .extract()
            .response();
    System.out.println(response.asString());
    String accessToken = response.jsonPath().getString("access_token");

    SampleRequest.verify(accessToken);
  }
  @Test
  public void adhocIMChat6() throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 1 has received a chat message");

    receiveMessageStatusURL = INVALID;
    String url = (Setup.channelURL[1].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text",
                    Matchers.hasItem("how are you"),
                "notificationList.messageNotification.sessionId", Matchers.hasItem("adhoc"),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress",
                    Matchers.hasItem(Setup.TestUser2Contact),
                "notificationList.messageNotification.link", Matchers.notNullValue())
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());

    receiveMessageStatusURL =
        response.jsonPath().getString("notificationList.messageNotification[0].link[0].href");
    System.out.println("message status URL = " + receiveMessageStatusURL);
    Setup.endTest();
  }
  @Test
  public void testTenantIdListParameter() {
    mockQuery = setUpMockJobQuery(createMockJobsTwoTenants());

    Response response =
        given()
            .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(JOBS_RESOURCE_URL);

    verify(mockQuery)
        .tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
    verify(mockQuery).list();

    String content = response.asString();
    List<String> jobs = from(content).getList("");
    assertThat(jobs).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
  }
  private void subscribeToAddressBookNotifications(String userID, int i) {
    String test = "Subscribing User 1 to Address Book Notifications";
    startTest(test);

    String clientCorrelator = Long.toString(System.currentTimeMillis());
    String callback = callbackURL[i];
    String requestData = requestDataClean(addressBookRequestData, clientCorrelator, callback);
    String url = replace(addressBookSubscriptionURL, apiVersion, userID);

    RestAssured.authentication = RestAssured.basic(userID, applicationPassword);

    Response response =
        RestAssured.given()
            .contentType("application/json")
            .body(requestData)
            .expect()
            .log()
            .ifError()
            .statusCode(201)
            .post(url);

    JsonPath jsonData = response.jsonPath();
    subscriptionURL[i] = jsonData.getString("abChangesSubscription.resourceURL");
    LOGGER.info("Response received = " + response.getStatusCode());
    LOGGER.info("Body = " + response.asString());

    endTest(test);
  }
  @Test
  public void testTenantIdListPostParameter() {
    mockQuery = setUpMockJobQuery(createMockJobsTwoTenants());

    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST.split(","));

    Response response =
        given()
            .contentType(POST_JSON_CONTENT_TYPE)
            .body(queryParameters)
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .post(JOBS_RESOURCE_URL);

    verify(mockQuery)
        .tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
    verify(mockQuery).list();

    String content = response.asString();
    List<String> jobs = from(content).getList("");
    assertThat(jobs).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
  }
  @Test
  public void testDeleteStudentPhoneNumber() throws NoSuchFieldException {
    PhoneNumber phoneNumber = new PhoneNumber(null, 1l, Boolean.FALSE, "(123) 12 234 5678");

    Response response =
        given()
            .headers(getAdminAuthHeaders())
            .contentType("application/json")
            .body(phoneNumber)
            .post("/students/students/{STUDENTID}/phoneNumbers", TEST_STUDENT_ID);

    Long id = new Long(response.body().jsonPath().getInt("id"));

    response =
        given()
            .headers(getAuthHeaders())
            .delete("/students/students/{STUDENTID}/phoneNumbers/{ID}", TEST_STUDENT_ID, id);

    assertOk(response, studentPermissions, StudentPermissions.DELETE_STUDENTPHONENUMBER, 204);

    if (response.getStatusCode() != 204) {
      given()
          .headers(getAdminAuthHeaders())
          .delete("/students/students/{STUDENTID}/phoneNumbers/{ID}", TEST_STUDENT_ID, id);
    }
  }
  @Test
  public void byeResource_ok() {

    Response response =
        given().expect().response().statusCode(200).when().get("http://localhost:5050/bye?to=foo");
    assertThat(response.getBody().asString()).isEqualToIgnoringCase("bye foo from test");
  }
 @Test(description = "正常", priority = 1)
 public void test() {
   Response response =
       TestConfig.getOrDeleteExecu(
           "get", "/classes/" + classid + "/unteam_user?access_token=" + token);
   response
       .then()
       .
       // log().all().
       assertThat()
       .statusCode(200)
       .body("status", equalTo(true))
       .
       // body("message",equalTo("success")).
       body("data.curPage", equalTo(1))
   /*
    * body("data.name", equalTo("响应式Web设计-单元得分")).
    * body("data.course.id",equalTo(1)).
    * body("data.course.name",equalTo("响应式Web设计")).
    * body("data.course.instructorList.id",Matchers.hasItem(1)).
    * body("data.course.instructorList.name",Matchers.hasItem("马鉴")
    * )
    */
   ;
 }
 @Test(description = "quizzesID非法无效")
 public void testErrQuizzId02() {
   quizzesID = "-1";
   Response response =
       TestConfig.postOrPutExecu(
           "put", "/quizzes/" + quizzesID + "/?access_token=" + accesstoken, jsonObject);
   response.then().assertThat().statusCode(404);
 }
 @Test(description = "全部为空")
 public void testBody01() {
   quizzesID = "1682";
   Response response =
       TestConfig.postOrPutExecu(
           "put", "/quizzes/" + quizzesID + "/?access_token=" + accesstoken, jsonObject);
   response.then().assertThat().statusCode(200).body("id", equalTo(quizzesID));
 }