@Test
  public void test01Create_Get() {
    TestUtils.mmxApiHeaders.put("X-mmx-app-owner", TestUtils.appOwner);

    // Create User
    String payload =
        "{\n"
            + "  \"username\": \"test01user\",\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");
    System.out.println(responsePost.asString());

    responsePost.then().statusCode(201);

    // Get User by userName
    RestAssured.port = 5220;
    Response responseGet =
        given()
            .log()
            .all()
            .authentication()
            .preemptive()
            .basic(TestUtils.user, TestUtils.pass)
            .contentType(TestUtils.JSON)
            .headers(TestUtils.toHeaders(TestUtils.mmxApiHeaders))
            .when()
            .queryParam("name", "test1 user")
            .get("/mmxmgmt/api/v1/users");
    System.out.println(responseGet.asString());

    responseGet
        .then()
        .statusCode(200)
        .assertThat()
        .body("results.any {it.username == 'test01user'}", is(true))
        .assertThat()
        .body("results.any {it.name == 'test1 user'}", is(true))
        .assertThat()
        .body("results.any {it.email == '*****@*****.**'}", is(true));
  }
예제 #2
0
  @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();
  }
예제 #3
0
  @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();
  }
예제 #4
0
  @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();
  }
예제 #5
0
 @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();
 }
예제 #6
0
  @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();
  }
예제 #7
0
  @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();
  }
예제 #8
0
  @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();
  }
  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 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);
  }
예제 #11
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 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);
  }
 public static void performPostRequest() {
   try {
     response =
         given()
             .urlEncodingEnabled(urlEncoding)
             .headers(requestHeaders)
             .body(requestBody)
             .filter(new RequestLoggingFilter(psRequest))
             .filter(new ResponseLoggingFilter(psResponse))
             .expect()
             .statusCode(statusCode)
             .headers(responseHeaders)
             .post(requestURL);
     responseString = response.asString();
   } catch (AssertionError e) {
     fail(
         e.getMessage()
             + "\n\n"
             + baosRequest.toString()
             + "\nResponse:\n"
             + baosResponse.toString());
   } finally {
     psRequest.close();
   }
 }
  @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);
  }
  @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 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);
  }
예제 #17
0
  @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();
  }
  @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);
  }
예제 #19
0
  @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 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);
  }
예제 #21
0
 public void readFile(
     String user, String password, String file, String contentType, String resource, int status)
     throws IOException {
   getMock("WEBHDFS")
       .expect()
       .method("GET")
       .pathInfo("/v1" + file)
       .queryParam("user.name", user)
       .queryParam("op", "OPEN")
       .respond()
       .status(HttpStatus.SC_TEMPORARY_REDIRECT)
       .header("Location", getRealUrl("DATANODE") + file + "?op=OPEN&user.name=" + user);
   if (status == HttpStatus.SC_OK) {
     getMock("DATANODE")
         .expect()
         .method("GET")
         .pathInfo(file)
         .queryParam("user.name", user)
         .queryParam("op", "OPEN")
         .respond()
         .status(status)
         .contentType(contentType)
         .content(getResourceBytes(resource));
   } else {
     getMock("DATANODE")
         .expect()
         .method("GET")
         .pathInfo(file)
         .queryParam("user.name", user)
         .queryParam("op", "OPEN")
         .respond()
         .status(status);
   }
   Response response =
       given()
           // .log().all()
           .auth()
           .preemptive()
           .basic(user, password)
           .header("X-XSRF-Header", "jksdhfkhdsf")
           .queryParam("op", "OPEN")
           .expect()
           // .log().all()
           .statusCode(status)
           .when()
           .get(getUrl("WEBHDFS") + "/v1" + file + (isUseGateway() ? "" : "?user.name=" + user));
   if (response.getStatusCode() == HttpStatus.SC_OK) {
     String actualContent = response.asString();
     String expectedContent = getResourceString(resource, Charset.forName("UTF-8"));
     assertThat(actualContent, is(expectedContent));
   }
   assertComplete();
 }
  @SuppressWarnings("unchecked")
  @Test
  public final void whenResourcesAreRetrievedNotSorted_thenResourcesAreNotOrdered() {
    getTemplate().createAsResponse(getTemplate().createNewEntity());
    getTemplate().createAsResponse(getTemplate().createNewEntity());

    // When
    final Response response = givenAuthenticated().get(getURI() + "?page=0&size=6");
    final List<T> resourcesPagedAndSorted =
        getTemplate().getMarshaller().decode(response.asString(), List.class);

    // Then
    assertFalse(getOrdering().isOrdered(resourcesPagedAndSorted));
  }
예제 #23
0
  @Test
  public void adhocIMChat8() {
    Setup.startTest("Checking IM notifications for user 2");
    RestAssured.authentication = RestAssured.basic(Setup.TestUser2, Setup.applicationPassword);
    String url = (Setup.channelURL[2].split("username\\=")[0]) + "username="******"notificationList.chatEventNotification.eventType", Matchers.hasItem("Accepted"),
				"notificationList.chatEventNotification.sessionId", Matchers.hasItem("adhoc")
				).*/ post(url);
    System.out.println(
        "Response = " + notifications2.getStatusCode() + " / " + notifications2.asString());
    Setup.endTest();
  }
  public static void performPutRequest() {

    response =
        given()
            .urlEncodingEnabled(urlEncoding)
            .headers(requestHeaders)
            .body(requestBody)
            .expect()
            .log()
            .ifError()
            .statusCode(statusCode)
            .headers(responseHeaders)
            .put(requestURL);
    responseString = response.asString();
  }
예제 #25
0
 @Test
 public void sessionIMChatAccept10() {
   Setup.startTest("Checking the receiver status");
   RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword);
   Response status =
       RestAssured.given()
           .expect()
           .log()
           .ifError()
           .statusCode(200)
           .body("messageStatusReport.status", Matchers.equalTo("DISPLAYED"))
           .get(Setup.prepareForTest(receiveMessageStatusURL));
   System.out.println("Response = " + status.getStatusCode() + " / " + status.asString());
   Setup.endTest();
 }
예제 #26
0
 @Test
 public void adhocIMChat2() {
   Setup.startTest("Checking the sender status");
   RestAssured.authentication = RestAssured.basic(Setup.TestUser1, Setup.applicationPassword);
   Response status =
       RestAssured.given()
           .expect()
           .log()
           .ifError()
           .statusCode(200)
           .body("messageStatusReport.status", Matchers.is("DISPLAYED"))
           .get(sendMessageStatusURL);
   System.out.println("Response = " + status.getStatusCode() + " / " + status.asString());
   Setup.endTest();
 }
  @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 returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId");
    String returnedProcessDefinitionKey = from(content).getString("[0].processDefinitionKey");
    String returnedExecutionId = from(content).getString("[0].executionId");
    String returnedExceptionMessage = from(content).getString("[0].exceptionMessage");
    int returnedRetries = from(content).getInt("[0].retries");
    Date returnedDueDate = DateTimeUtil.parseDate(from(content).getString("[0].dueDate"));
    boolean returnedSuspended = from(content).getBoolean("[0].suspended");
    long returnedPriority = from(content).getLong("[0].priority");
    String returnedJobDefinitionId = from(content).getString("[0].jobDefinitionId");
    String returnedTenantId = from(content).getString("[0].tenantId");

    Assert.assertEquals(MockProvider.EXAMPLE_JOB_ID, returnedJobId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY, returnedProcessDefinitionKey);
    Assert.assertEquals(MockProvider.EXAMPLE_EXECUTION_ID, returnedExecutionId);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_NO_EXCEPTION_MESSAGE, returnedExceptionMessage);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_RETRIES, returnedRetries);
    Assert.assertEquals(DateTimeUtil.parseDate(MockProvider.EXAMPLE_DUE_DATE), returnedDueDate);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_IS_SUSPENDED, returnedSuspended);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_PRIORITY, returnedPriority);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_DEFINITION_ID, returnedJobDefinitionId);
    Assert.assertEquals(MockProvider.EXAMPLE_TENANT_ID, returnedTenantId);
  }
예제 #28
0
 @Test
 public void sessionIMChatAccept22()
     throws JsonGenerationException, JsonMappingException, IOException {
   Setup.startTest("Close chat by User 4");
   RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword);
   Response resp =
       RestAssured.given()
           .expect()
           .log()
           .ifError()
           .statusCode(204)
           .delete(
               Setup.chatSessionIMURL(Setup.TestUser4, Setup.TestUser3Contact, receiveSessionID));
   System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString());
   Setup.endTest();
 }
  @SuppressWarnings("unchecked")
  @Test
  @Ignore(
      "http://forum.springsource.org/showthread.php?124083-Sort-case-sensitivey-in-Spring-Data-%28JPA%29&p=404901#post404901")
  public final void whenResourcesAreRetrievedSorted_thenResourcesAreIndeedOrdered() {
    getTemplate().createAsResponse(getTemplate().createNewEntity());
    getTemplate().createAsResponse(getTemplate().createNewEntity());

    // When
    final Response response = givenAuthenticated().get(getURI() + "?page=0&size=4&sortBy=name");
    final List<T> resourcesPagedAndSorted =
        getTemplate().getMarshaller().decode(response.asString(), List.class);

    // Then
    assertTrue(getOrdering().isOrdered(resourcesPagedAndSorted));
  }
예제 #30
0
 @Test
 public void adhocIMChat4() {
   Setup.startTest("Checking no further IM notifications for user 2 ");
   String url = (Setup.channelURL[2].split("username\\=")[0]) + "username="******"notificationList", Matchers.nullValue())
           .post(url);
   System.out.println(
       "Response = " + notifications2.getStatusCode() + " / " + notifications2.asString());
   Setup.endTest();
 }