Skip to content

Commit

Permalink
Refactored CommunityService
Browse files Browse the repository at this point in the history
- Added factory methods that return a instance of entity and entitylist
- Added factory methods that return entityfeedhandlers
- Removed feedhandlers and list classes
- Removed forum and bookmark community tests and methods
- Fixed methods affected by the changes in other files
  • Loading branch information
davetobin committed Apr 28, 2014
1 parent d429e4d commit 735f813
Show file tree
Hide file tree
Showing 62 changed files with 1,212 additions and 1,478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import org.openqa.selenium.WebElement;

import com.ibm.sbt.automation.core.test.pageobjects.WrapperResultPage;
import com.ibm.sbt.services.client.ClientServicesException;
import com.ibm.sbt.services.client.connections.communities.Community;
import com.ibm.sbt.services.client.connections.communities.CommunityService;
import com.ibm.sbt.services.client.connections.communities.CommunityServiceException;
/*
* © Copyright IBM Corp. 2012
*
Expand All @@ -20,8 +23,6 @@
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
import com.ibm.sbt.services.client.connections.communities.CommunityService;
import com.ibm.sbt.services.client.connections.communities.CommunityServiceException;

/**
* @author Francis
Expand All @@ -48,7 +49,7 @@ public String createCommunity(){
try {
communityUuid = communityService.createCommunity("TestTitle" + System.currentTimeMillis(), "Test content.", "public");
community = communityService.getCommunity(communityUuid);
} catch (CommunityServiceException e) {
} catch (ClientServicesException e) {
e.printStackTrace();
Assert.fail("Problem creating test community.");
}
Expand All @@ -62,7 +63,7 @@ public String createCommunity(){
public void destroyCommunity() {
try {
communityService.deleteCommunity(community.getCommunityUuid());
} catch (CommunityServiceException e) {
} catch (ClientServicesException e) {
e.printStackTrace();
}
destroyContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import com.ibm.sbt.automation.core.utils.Trace;
import com.ibm.sbt.security.authentication.AuthenticationException;
import com.ibm.sbt.services.client.ClientServicesException;
import com.ibm.sbt.services.client.base.transformers.TransformerException;
import com.ibm.sbt.services.client.connections.activity.Activity;
import com.ibm.sbt.services.client.connections.activity.ActivityService;
Expand Down Expand Up @@ -166,7 +167,7 @@ public Community createCommunity(String title, String type, String content, Arra
community = community.save();
long duration = System.currentTimeMillis() - start;
Trace.log("Created test community: "+community.getCommunityUuid() + " took "+duration+"(ms)");
} catch (CommunityServiceException e) {
} catch (ClientServicesException e) {
System.out.println("Grid Setup Error: cannot create community");

fail("Error creating test community", e);
Expand All @@ -189,7 +190,7 @@ public void deleteCommunity() {
pe.getCause().printStackTrace();
}
Assert.fail("Error authenicating: " + pe.getMessage());
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
fail("Error deleting community "+testCommunityID, cse);
}
}
Expand Down Expand Up @@ -319,7 +320,7 @@ public void emptyTrash(){
}
}

protected void fail(String message, CommunityServiceException cse) {
protected void fail(String message, ClientServicesException cse) {
String failure = message;

Throwable cause = cse.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
import com.ibm.sbt.automation.core.test.BaseTest.AuthType;
import com.ibm.sbt.automation.core.test.FlexibleTest;
import com.ibm.sbt.automation.core.utils.Trace;
import com.ibm.sbt.services.client.ClientServicesException;
import com.ibm.sbt.services.client.SBTServiceException;
import com.ibm.sbt.services.client.connections.activitystreams.ActivityStreamEntity;
import com.ibm.sbt.services.client.connections.activitystreams.ActivityStreamEntityList;
import com.ibm.sbt.services.client.connections.activitystreams.ActivityStreamService;
import com.ibm.sbt.services.client.connections.activitystreams.ActivityStreamServiceException;
import com.ibm.sbt.services.client.connections.communities.Community;
import com.ibm.sbt.services.client.connections.communities.CommunityService;
import com.ibm.sbt.services.client.connections.communities.CommunityServiceException;
import com.ibm.sbt.services.endpoints.BasicEndpoint;
import com.ibm.sbt.services.endpoints.Endpoint;
import com.ibm.sbt.services.endpoints.EndpointFactory;
Expand Down Expand Up @@ -162,7 +162,7 @@ protected void createCommunityWithTags(String tags) {
community.setContent("Test Community created to test Activity Streams");
community.setTags(tags);
String communityId = communityService.createCommunity(community);
}catch(CommunityServiceException cse){
}catch(ClientServicesException cse){
assertNull("CommunityServiceException in testing SearchByFilters");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@
import com.ibm.sbt.services.client.base.datahandlers.EntityList;
import com.ibm.sbt.services.client.connections.communities.Community;
import com.ibm.sbt.services.client.connections.communities.CommunityService;
import com.ibm.sbt.services.client.connections.communities.CommunityServiceException;
import com.ibm.sbt.services.client.connections.communities.Invite;
import com.ibm.sbt.services.client.connections.communities.Member;
import com.ibm.sbt.services.client.connections.forums.ForumServiceException;
import com.ibm.sbt.services.client.connections.forums.ForumTopic;
import com.ibm.sbt.services.client.connections.forums.model.BaseForumEntity;
import com.ibm.sbt.services.client.connections.forums.transformers.BaseForumTransformer;



Expand All @@ -59,7 +54,7 @@ public class BaseCommunitiesTest extends FlexibleTest {
protected boolean createCommunity = true;
protected CommunityService communityService;
protected Community community;
protected BaseForumEntity forum;
protected Member member;

protected String CommunityEventEntry =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
Expand All @@ -83,8 +78,8 @@ public void createCommunity() {
//System.out.println(name);
community = createCommunity(name, type, name, "tag1,tag2,tag3");
try {
forum = community.getForums().get(0);
} catch (CommunityServiceException e) {
member = community.getMembers().get(0);
} catch (ClientServicesException e) {
e.printStackTrace();
}
}
Expand Down Expand Up @@ -138,7 +133,7 @@ protected Invite createInvite(Community community, String userid) {
invite.setCommunityUuid(community.getCommunityUuid());
invite.setUserid(userid);
return communityService.createInvite(invite);
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
fail("Error creating invite",cse);
}
return null;
Expand Down Expand Up @@ -207,7 +202,7 @@ protected Community getLastCreatedCommunity() {
Trace.log("Last created community: "+c.getTitle());
Trace.log("Last created community: "+c.getPublished());
}
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
fail("Error getting last created community", cse);
}

Expand All @@ -226,7 +221,7 @@ protected Community getCommunity(String communityUuid, boolean failOnCse) {
CommunityService communityService = getCommunityService();
community = communityService.getCommunity(communityUuid);
Trace.log("Got community: "+community.getCommunityUuid());
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
if (failOnCse) {
fail("Error retrieving community", cse);
}
Expand Down Expand Up @@ -255,7 +250,7 @@ protected Community createCommunity(String title, String type, String content, S
long duration = System.currentTimeMillis() - start;
Trace.log("Created test community: "+communityUuid + " took "+duration+"(ms)");
}
catch (CommunityServiceException cse) {
catch (ClientServicesException cse) {
// TODO remove this when we upgrade the QSI
Throwable t = cse.getCause();
if (t instanceof ClientServicesException) {
Expand All @@ -277,7 +272,7 @@ protected void deleteCommunity(Community community) {

CommunityService communityService = getCommunityService();
communityService.deleteCommunity(community.getCommunityUuid());
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
community = null;
// check if community delete failed because
// community was already deleted
Expand All @@ -301,7 +296,7 @@ protected void deleteCommunity(String communityId) {

CommunityService communityService = getCommunityService();
communityService.deleteCommunity(communityId);
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
fail("Error deleting community "+communityId, cse);
}
}
Expand All @@ -316,7 +311,7 @@ protected boolean addMember(Community community, String id, String role) {
Assert.assertTrue("Unable to add member: "+id, added);
Trace.log("Added member: "+id);
return added;
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
fail("Error adding member", cse);
}
return false;
Expand All @@ -332,45 +327,13 @@ protected boolean hasMember(Community community, String id) {
return true;
}
}
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
fail("Error getting members", cse);
}
return false;
}

protected ForumTopic createForumTopic(Community community, ForumTopic topic) throws ForumServiceException {
if (null == topic){
throw new ForumServiceException(null,"Topic object passed was null");
}
Response result = null;
try {
CommunityService communityService = getCommunityService();
EntityList<ForumTopic> topicList = communityService.getForumTopics(community.getCommunityUuid());

String forumUuid = "";

BaseForumTransformer transformer = new BaseForumTransformer(topic);
Object payload = transformer.transform(topic.getFieldsMap());

Map<String, String> params = new HashMap<String, String>();
params.put("communityUuid", community.getCommunityUuid());

Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/atom+xml");

//String url = resolveUrl(ForumType.TOPICS,null,params);
//result = createData(url, null, headers,payload);
//topic = (ForumTopic) new TopicsFeedHandler(this).createEntity(result);

} catch (Exception e) {
throw new ForumServiceException(e, "error creating forum");
}

return topic;
}

}

protected void fail(String message, CommunityServiceException cse) {
protected void fail(String message, ClientServicesException cse) {
String failure = message;

Throwable cause = cse.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected Community createCommunity(String title, String type,
pe.getCause().printStackTrace();
}
fail("Error authenicating: ", pe);
} catch (CommunityServiceException cse) {
} catch (ClientServicesException cse) {
// TODO remove this when we upgrade the QSI
Throwable t = cse.getCause();
if (t instanceof ClientServicesException) {
Expand Down Expand Up @@ -264,7 +264,7 @@ public void deleteFileAndQuit() {
communityService = getCommunityService();
try {
communityService.deleteCommunity(community.getCommunityUuid());
} catch (CommunityServiceException e) {
} catch (ClientServicesException e) {
fail("Error deleting test community: ", e);
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,25 @@
import com.ibm.sbt.automation.core.environment.TestEnvironment;
import com.ibm.sbt.test.java.connections.communities.AcceptInvite;
import com.ibm.sbt.test.java.connections.communities.AddMember;
import com.ibm.sbt.test.java.connections.communities.RemoveMember;
import com.ibm.sbt.test.java.connections.communities.CreateCommunity;
import com.ibm.sbt.test.java.connections.communities.CreateForumTopic;
import com.ibm.sbt.test.java.connections.communities.CreateInvite;
import com.ibm.sbt.test.java.connections.communities.DeclineInvite;
import com.ibm.sbt.test.java.connections.communities.GetBookmarks;
import com.ibm.sbt.test.java.connections.communities.GetCommunity;
import com.ibm.sbt.test.java.connections.communities.GetCommunityDataByEntity;
import com.ibm.sbt.test.java.connections.communities.GetForums;
import com.ibm.sbt.test.java.connections.communities.GetForumTopics;
import com.ibm.sbt.test.java.connections.communities.GetForums;
import com.ibm.sbt.test.java.connections.communities.GetMembers;
import com.ibm.sbt.test.java.connections.communities.GetMyCommunities;
import com.ibm.sbt.test.java.connections.communities.GetMyInvites;
import com.ibm.sbt.test.java.connections.communities.GetPublicCommunities;
import com.ibm.sbt.test.java.connections.communities.GetSubCommunities;
import com.ibm.sbt.test.java.connections.communities.RemoveCommunity;
import com.ibm.sbt.test.java.connections.communities.RemoveMember;
import com.ibm.sbt.test.java.connections.communities.UpdateCommunity;
import com.ibm.sbt.test.java.connections.communities.UpdateCommunityLogo;
import com.ibm.sbt.test.java.connections.communities.UpdateMember;
import com.ibm.sbt.test.js.connections.communities.api.CreateBookmark;

/**
* @author mwallace
Expand All @@ -52,7 +51,7 @@
@RunWith(Suite.class)
@SuiteClasses({ AcceptInvite.class, AddMember.class, RemoveMember.class, CreateCommunity.class, CreateForumTopic.class, CreateInvite.class, DeclineInvite.class, GetBookmarks.class,
GetCommunity.class, GetForumTopics.class, GetCommunityDataByEntity.class, GetForums.class, GetMembers.class, GetMyCommunities.class, GetMyInvites.class, GetPublicCommunities.class,
GetSubCommunities.class, RemoveCommunity.class, UpdateCommunity.class , UpdateCommunityLogo.class, UpdateMember.class, CreateBookmark.class })
GetSubCommunities.class, RemoveCommunity.class, UpdateCommunity.class , UpdateCommunityLogo.class, UpdateMember.class })
public class CommunitiesTestSuite {
@AfterClass
public static void cleanup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,28 @@
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

import com.ibm.sbt.test.js.base.CommunityEntryDataHandler;
import com.ibm.sbt.test.js.base.CommunityFeedDataHandler;
import com.ibm.sbt.test.js.base.CommunityInvitesFeedDataHandler;
import com.ibm.sbt.test.js.base.CommunityMembersFeedDataHandler;
import com.ibm.sbt.test.js.connections.communities.GetCommunityEvents;
import com.ibm.sbt.test.js.connections.communities.GetCommunityForumTopics;
import com.ibm.sbt.test.js.connections.communities.api.AddMember;
import com.ibm.sbt.test.js.connections.communities.api.Community;
import com.ibm.sbt.test.js.connections.communities.api.CreateCommunity;
import com.ibm.sbt.test.js.connections.communities.api.CreateCommunityInvalidTitle;
import com.ibm.sbt.test.js.connections.communities.api.CreateCommunityJson;
import com.ibm.sbt.test.js.connections.communities.api.CreateCommunityLoadIt;
import com.ibm.sbt.test.js.connections.communities.api.CreateCommunityNew;
import com.ibm.sbt.test.js.connections.communities.api.CreateForumTopic;
import com.ibm.sbt.test.js.connections.communities.api.CreateInvite;
import com.ibm.sbt.test.js.connections.communities.api.CrudCommunity;
import com.ibm.sbt.test.js.connections.communities.api.DeleteCommunity;
import com.ibm.sbt.test.js.connections.communities.api.GetAllInvites;
import com.ibm.sbt.test.js.connections.communities.api.GetCommunity;
import com.ibm.sbt.test.js.connections.communities.api.GetCommunityEvent;
import com.ibm.sbt.test.js.connections.communities.api.GetForums;
import com.ibm.sbt.test.js.connections.communities.api.GetMembers;
import com.ibm.sbt.test.js.connections.communities.api.GetForumTopics;
import com.ibm.sbt.test.js.connections.communities.api.GetMyCommunities;
import com.ibm.sbt.test.js.connections.communities.api.GetMyInvites;
import com.ibm.sbt.test.js.connections.communities.api.GetPublicCommunities;
import com.ibm.sbt.test.js.connections.communities.api.GetSaveCommunity;
import com.ibm.sbt.test.js.connections.communities.api.GetSubCommunities;
import com.ibm.sbt.test.js.connections.communities.api.NewSaveCommunity;
import com.ibm.sbt.test.js.connections.communities.api.RemoveMember;
import com.ibm.sbt.test.js.connections.communities.api.RemoveInvite;
import com.ibm.sbt.test.js.connections.communities.api.RemoveMember;
import com.ibm.sbt.test.js.connections.communities.api.UpdateCommunity;
import com.ibm.sbt.test.js.connections.communities.api.UpdateCommunityJson;
import com.ibm.sbt.test.js.connections.communities.api.UpdateCommunityTags;
Expand Down Expand Up @@ -93,11 +84,6 @@
CreateInvite.class,
RemoveInvite.class,

GetCommunityForumTopics.class,
GetForums.class,
GetForumTopics.class,
CreateForumTopic.class,

AddMember.class,
RemoveMember.class
})
Expand Down

This file was deleted.

Loading

0 comments on commit 735f813

Please sign in to comment.