Example #1
0
 @Test
 public void testResponseHeaders() {
   addSnippetParam("CommunityService.communityUuid", community.getCommunityUuid());
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   List jsonList = previewPage.getJsonList();
   Assert.assertTrue("Promise chaining failed", !jsonList.isEmpty());
 }
Example #2
0
 /**
  * @param snippetId
  * @return
  */
 public JavaScriptPreviewPage executeSnippet(String snippetId, long delay) {
   this.snippetId = snippetId;
   ResultPage resultPage = launchSnippet(snippetId, authType, delay);
   JavaScriptPreviewPage previewPage = new JavaScriptPreviewPage(resultPage);
   Trace.log(previewPage.getText());
   return previewPage;
 }
 @Test
 public void testGetActivity() {
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   JsonJavaObject json = previewPage.getJson();
   String activityNodeId = json.getAsString("getActivityNodeUuid");
   Assert.assertNotNull(activityNodeId);
 }
 @Test
 public void testProfileCreatePostData() {
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   String newPost = previewPage.getWebElement().findElement(By.id("newPost")).getText();
   String newPut = previewPage.getWebElement().findElement(By.id("newPut")).getText();
   Assert.assertNotNull(newPost);
   Assert.assertNotNull(newPut);
 }
  @Test
  public void DeleteProfileWithMissingArguments() {
    addSnippetParam("sample.createProfileId", "");

    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
    JsonJavaObject json = previewPage.getJson();
    Assert.assertEquals(400, json.getInt("code"));
  }
Example #6
0
  @Test
  public void testGetForumTopicInvalidArg() {
    addSnippetParam("ForumService.topicUuid", "");

    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
    JsonJavaObject json = previewPage.getJson();
    Assert.assertEquals(400, json.getInt("code"));
    Assert.assertEquals("Invalid argument, expected topicUuid.", json.getString("message"));
  }
  @Test
  public void testCreateForumTopic() {
    addSnippetParam("ForumService.forumUuid", forum.getForumUuid());

    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
    JsonJavaObject json = previewPage.getJson();
    Assert.assertNull("Unexpected error detected on page", json.getString("code"));
    assertForumTopicProperties(json);
  }
  @Test
  public void testCommunityNewSave() {
    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
    JsonJavaObject json = previewPage.getJson();
    Assert.assertNull("Unexpected error detected on page", json.getString("code"));

    community = getCommunity(json.getString("getCommunityUuid"));
    assertCommunityValid(json);
  }
Example #9
0
  @Test
  public void testGetForumTopic() {
    String title = createForumTopicName();
    ForumTopic forumTopic = createForumTopic(forum, title, title);
    addSnippetParam("ForumService.topicUuid", forumTopic.getTopicUuid());

    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
    JsonJavaObject json = previewPage.getJson();
    assertForumTopicValid(forumTopic, (JsonJavaObject) json);
  }
  @Test
  public void testGetUpdatesFromACommunity() {
    String commId = communitiesTest.getCommunity().getCommunityUuid();
    createEntry("urn:lsid:lconn.ibm.com:communities.community:" + commId, "@all", "@all");

    addSnippetParam("CommunityService.communityUuid", commId);
    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
    List jsonList = previewPage.getJsonList();
    Assert.assertFalse("GetUpdatesFromACommunity returned no results", jsonList.isEmpty());
  }
 @Test
 public void testBaseServiceEndpoint() {
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   List jsonList = previewPage.getJsonList();
   Assert.assertEquals(2, jsonList.size());
   JsonJavaObject json = (JsonJavaObject) jsonList.get(0);
   Assert.assertEquals("connections", json.getJsonObject("endpoint").getString("name"));
   json = (JsonJavaObject) jsonList.get(1);
   Assert.assertEquals("connections", json.getJsonObject("endpoint").getString("name"));
 }
Example #12
0
  @Test
  public void testGetForumTopicError() {
    addSnippetParam("ForumService.topicUuid", "Foo");

    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
    JsonJavaObject json = previewPage.getJson();
    Assert.assertEquals(404, json.getInt("code"));
    Assert.assertEquals(
        "No existing forum found. Please contact your system administrator.",
        json.getString("message"));
  }
Example #13
0
  @Test
  public void testCommunity() {
    AuthType authType = getEnvironment().isSmartCloud() ? AuthType.AUTO_DETECT : AuthType.NONE;
    setAuthType(authType);
    addSnippetParam("CommunityService.communityUuid", community.getCommunityUuid());

    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);

    List jsonList = previewPage.getJsonList();
    for (int i = 0; i < jsonList.size(); i++) {
      assertCommunityValid((JsonJavaObject) jsonList.get(i));
    }
  }
  @Test
  public void testRemoveMember() throws Exception {
    String id = getProperty("sample.email2");
    if (getEnvironment().isSmartCloud()) {
      id = getProperty("smartcloud.id2");
    }
    addMember(community, id, "member");

    addSnippetParam("CommunityService.communityUuid", community.getCommunityUuid());
    addSnippetParam("sample.id2", id);

    JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
    JsonJavaObject json = previewPage.getJson();
    Assert.assertFalse("Remove member failed", hasMember(community, getProperty("sample.email2")));
  }
Example #15
0
 @Test
 @Ignore
 public void testBaseEntity() {
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   List jsonList = previewPage.getJsonList();
   for (int i = 0; i < jsonList.size(); i++) {
     JsonJavaObject json = (JsonJavaObject) jsonList.get(i);
     Iterator<String> properties = json.getProperties();
     if (properties.hasNext() && Results[i][1] != null) {
       String property = properties.next();
       Object value = json.get(property);
       Assert.assertEquals(Results[i][0], property);
       Assert.assertEquals(
           "Match failed [" + i + "] name:" + property + " type:" + value.getClass(),
           Results[i][1],
           value);
     }
   }
 }
Example #16
0
 @Test
 public void testAddMemberToActivity() {
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   JsonJavaObject json = previewPage.getJson();
   Assert.assertEquals(json.getAsInt("status"), 201); // created
 }
Example #17
0
 @Test
 public void testUpdateActivityMember() {
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   JsonJavaObject json = previewPage.getJson();
   Assert.assertEquals(json.getAsInt("status"), 200); // OK	
 }
Example #18
0
 @Test
 public void testGetBookmarksTags() {
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   JsonJavaObject json = previewPage.getJson();
   Assert.assertNotNull(json.getString("tagTerm"));
 }
Example #19
0
 @Test
 public void testGetActivityMember() {
   JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID);
   JsonJavaObject json = previewPage.getJson();
   Assert.assertEquals(json.getAsString("getUserId"), id);
 }