/src/agh/io/vanillaforums/transition/testing/TestTransition.java

https://bitbucket.org/kzm123/io2013 · Java · 622 lines · 427 code · 128 blank · 67 comment · 12 complexity · babd53a439dab1d313ea0aa546e4bbdd MD5 · raw file

  1. package agh.io.vanillaforums.transition.testing;
  2. import java.io.UnsupportedEncodingException;
  3. import java.lang.reflect.InvocationTargetException;
  4. import java.lang.reflect.Method;
  5. import java.util.List;
  6. import java.util.TreeMap;
  7. import agh.io.vanillaforums.R;
  8. import agh.io.vanillaforums.transition.ContentRemoteManager;
  9. import agh.io.vanillaforums.transition.IContentRemoteManager;
  10. import agh.io.vanillaforums.transition.interfaces.items.IFlatCategory;
  11. import agh.io.vanillaforums.transition.interfaces.items.IFlatComment;
  12. import agh.io.vanillaforums.transition.interfaces.items.IFlatForum;
  13. import agh.io.vanillaforums.transition.interfaces.items.IFlatForumSubscription;
  14. import agh.io.vanillaforums.transition.interfaces.items.IFlatTopic;
  15. import agh.io.vanillaforums.transition.interfaces.items.IFlatTopicSubscription;
  16. import agh.io.vanillaforums.transition.interfaces.items.IFlatUser;
  17. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.AlreadyExistsException;
  18. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.BadRequestException;
  19. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.InternalServerErrorException;
  20. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.InvalidRecordException;
  21. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.NotAuthorizedException;
  22. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.NotFoundException;
  23. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.NotImplementedException;
  24. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.NotSetedMandatoryFieldsException;
  25. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.RemoteObjectDoesNotExistException;
  26. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.ServiceUnavaliableException;
  27. import agh.io.vanillaforums.transition.interfaces.managing.exceptions.UnprocessableEntityException;
  28. import agh.io.vanillaforums.transition.iteminfo.CategoryInfo;
  29. import agh.io.vanillaforums.transition.iteminfo.CommentInfo;
  30. import agh.io.vanillaforums.transition.iteminfo.ForumInfo;
  31. import agh.io.vanillaforums.transition.iteminfo.TopicInfo;
  32. import agh.io.vanillaforums.transition.iteminfo.UserInfo;
  33. import agh.io.vanillaforums.transition.iteminfo.utils.UserRole;
  34. import agh.io.vanillaforums.transition.utils.Constants;
  35. import android.app.Activity;
  36. import android.os.Bundle;
  37. import android.view.Menu;
  38. import android.view.View;
  39. import android.view.View.OnClickListener;
  40. import android.widget.Button;
  41. import android.widget.TextView;
  42. public class TestTransition extends Activity {
  43. private Button executeB;
  44. private Button clearB;
  45. private TextView tv;
  46. private IContentRemoteManager _remoteManager;
  47. private Method toExecute;
  48. private Object[] params;
  49. /*
  50. * Test methods
  51. */
  52. public void getAllCategoriesTest() throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  53. List<IFlatCategory> categories;
  54. categories = _remoteManager.getAllCategories();
  55. StringBuffer buf = new StringBuffer("Categories on service : \n");
  56. for(IFlatCategory cat : categories)
  57. buf.append(cat.toString());
  58. tv.setText(buf.toString());
  59. }
  60. public void getCategoryTest(int categoryId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  61. IFlatCategory result = _remoteManager.getCategory(categoryId);
  62. tv.setText("Requested category " + result.toString());
  63. }
  64. public void createCategoryTest(CategoryInfo info) throws NotSetedMandatoryFieldsException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, AlreadyExistsException{
  65. IFlatCategory result = _remoteManager.createCategory(info);
  66. tv.setText(result.toString());
  67. }
  68. public void updateCategoryTest(int categoryId, CategoryInfo info) throws NotAuthorizedException, NotSetedMandatoryFieldsException, RemoteObjectDoesNotExistException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  69. IFlatCategory updated = _remoteManager.updateCategory(categoryId, info);
  70. tv.setText(updated.toString());
  71. }
  72. public void deleteCategoryTest(int categoryId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  73. boolean result = _remoteManager.deleteCategory(categoryId);
  74. tv.setText(String.valueOf(result));
  75. }
  76. public void getAllForumsTest() throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  77. List<IFlatForum> result = _remoteManager.getAllForums();
  78. StringBuffer sb = new StringBuffer("Avaliable forums : \n\n");
  79. for(IFlatForum f : result){
  80. sb.append(f.toString());
  81. }
  82. tv.setText(sb.toString());
  83. }
  84. public void getCategoryForumsTest(int categoryId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  85. List<IFlatForum> result = _remoteManager.getCategoryForums(categoryId);
  86. StringBuffer sb = new StringBuffer("Avaliable forums : \n\n");
  87. for(IFlatForum f : result){
  88. sb.append(f.toString());
  89. }
  90. tv.setText(sb.toString());
  91. }
  92. public void getForumTest(int forumId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  93. IFlatForum result = _remoteManager.getForum(forumId);
  94. tv.setText(result.toString());
  95. }
  96. public void createForumTest(ForumInfo info) throws NotSetedMandatoryFieldsException, RemoteObjectDoesNotExistException, AlreadyExistsException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  97. IFlatForum result = _remoteManager.createForum(info);
  98. tv.setText(result.toString());
  99. }
  100. public void updateForumTest(int forumId, ForumInfo info) throws NotSetedMandatoryFieldsException, RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  101. IFlatForum result = _remoteManager.updateForum(forumId, info);
  102. tv.setText(result.toString());
  103. }
  104. public void deleteForumTest(int forumId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  105. boolean result = _remoteManager.deleteForum(forumId);
  106. tv.setText(String.valueOf(result));
  107. }
  108. public void getAllTopicsTest() throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException{
  109. List<IFlatTopic> result = _remoteManager.getAllTopics();
  110. StringBuffer sb = new StringBuffer("Avaliable topics :: \n\n");
  111. for(IFlatTopic ft : result)
  112. sb.append(ft.toString());
  113. tv.setText(sb.toString());
  114. }
  115. public void getForumTopicsTest(int forumId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  116. List<IFlatTopic> result = _remoteManager.getForumTopics(forumId);
  117. StringBuffer sb = new StringBuffer("Avaliable topics :: \n\n");
  118. for(IFlatTopic ft : result)
  119. sb.append(ft.toString());
  120. tv.setText(sb.toString());
  121. }
  122. public void getUsersTopicsTest(int userId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  123. List<IFlatTopic> result = _remoteManager.getUserTopics(userId);
  124. StringBuffer sb = new StringBuffer("Avaliable topics :: \n\n");
  125. for(IFlatTopic ft : result)
  126. sb.append(ft.toString());
  127. tv.setText(sb.toString());
  128. }
  129. public void getTopicTest(int topicId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  130. IFlatTopic result = _remoteManager.getTopic(topicId);
  131. tv.setText(result.toString());
  132. }
  133. public void createTopicTest(TopicInfo info) throws NotSetedMandatoryFieldsException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, AlreadyExistsException, InvalidRecordException{
  134. IFlatTopic result = _remoteManager.createTopic(info);
  135. tv.setText(result.toString());
  136. }
  137. public void updateTopicTest(int topicId, TopicInfo info) throws RemoteObjectDoesNotExistException, NotSetedMandatoryFieldsException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  138. IFlatTopic result = _remoteManager.updateTopic(topicId, info);
  139. tv.setText(result.toString());
  140. }
  141. public void deleteTopicTest(int topicId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  142. boolean result = _remoteManager.deleteTopic(topicId);
  143. tv.setText(String.valueOf(result));
  144. }
  145. public void getTopicCommentsTest(int topicId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  146. List<IFlatComment> result = _remoteManager.getTopicComments(topicId);
  147. StringBuffer sb = new StringBuffer("avaliable comments ::\n\n");
  148. for(IFlatComment c : result)
  149. sb.append(c.toString());
  150. tv.setText(sb.toString());
  151. }
  152. public void getUsersCommentsTest(int userId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  153. List<IFlatComment> result = _remoteManager.getUserComments(userId);
  154. StringBuffer sb = new StringBuffer("avaliable comments ::\n\n");
  155. for(IFlatComment c : result)
  156. sb.append(c.toString());
  157. tv.setText(sb.toString());
  158. }
  159. public void getTopicCommentTest(int topicId, int commentId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  160. IFlatComment result = _remoteManager.getTopicComment(topicId, commentId);
  161. tv.setText(result.toString());
  162. }
  163. public void getUserCommentTest(int userId, int commentId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  164. IFlatComment result = _remoteManager.getUserComment(userId, commentId);
  165. tv.setText(result.toString());
  166. }
  167. public void createUserCommentTest(int topicId, CommentInfo info) throws NotSetedMandatoryFieldsException, RemoteObjectDoesNotExistException, AlreadyExistsException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  168. IFlatComment result = _remoteManager.createComment(topicId, info);
  169. tv.setText(result.toString());
  170. }
  171. public void updateCommentTest(int topicId, int commentId, CommentInfo info) throws NotSetedMandatoryFieldsException, RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  172. IFlatComment result = _remoteManager.updateComment(topicId, commentId, info);
  173. tv.setText(result.toString());
  174. }
  175. public void deleteCommentTest(int topicId, int commentId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  176. boolean result = _remoteManager.deleteComment(topicId, commentId);
  177. tv.setText(String.valueOf(result));
  178. }
  179. public void getAllTopicSubscriptionsTest() throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  180. List<IFlatTopicSubscription> result = _remoteManager.getAllTopicSubscriptions();
  181. StringBuffer sb = new StringBuffer();
  182. sb.append("Topic Subscriptions ::\n");
  183. for(IFlatTopicSubscription s : result)
  184. sb.append(s.toString());
  185. tv.setText(sb.toString());
  186. }
  187. public void getTopicSubscriptionsTest(int topicId) throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  188. List<IFlatTopicSubscription> result = _remoteManager.getTopicSubscriptions(topicId);
  189. StringBuffer sb = new StringBuffer();
  190. sb.append("Topic Subscriptions ::\n");
  191. for(IFlatTopicSubscription s : result)
  192. sb.append(s.toString());
  193. tv.setText(sb.toString());
  194. }
  195. public void getTopicSubscriptionTest(int subscriptionId) throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  196. IFlatTopicSubscription result = _remoteManager.getTopicSubscription(subscriptionId);
  197. tv.setText(result.toString());
  198. }
  199. public void createTopicSubscriptionTest(int topicId, int userId) throws UnsupportedEncodingException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  200. IFlatTopicSubscription result = _remoteManager.createTopicSubscription(topicId, userId);
  201. tv.setText(result.toString());
  202. }
  203. public void deleteTopicSubscriptionTest(int subscriptionId) throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, RemoteObjectDoesNotExistException{
  204. tv.setText(String.valueOf(_remoteManager.deleteTopicSubscription(subscriptionId)));
  205. }
  206. public void getAllForumSubscriptionsTest() throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  207. List<IFlatForumSubscription> result = _remoteManager.getAllForumSubscriptions();
  208. StringBuffer sb = new StringBuffer();
  209. sb.append("Forum Subscriptions ::\n");
  210. for(IFlatForumSubscription s : result)
  211. sb.append(s.toString());
  212. tv.setText(sb.toString());
  213. }
  214. public void showForumSubscriptionTest(int subscriptionId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  215. IFlatForumSubscription result = _remoteManager.getForumSubscription(subscriptionId);
  216. tv.setText(result.toString());
  217. }
  218. public void deleteForumSubscriptionTest(int subscriptionId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  219. tv.setText(String.valueOf(_remoteManager.deleteForumSubscription(subscriptionId)));
  220. }
  221. public void createForumSubscriptionTest(int forumId,int userId) throws UnsupportedEncodingException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  222. IFlatForumSubscription result = _remoteManager.createForumSubscription(forumId, userId);
  223. tv.setText(result.toString());
  224. }
  225. public void getUserRelatedInfoTest(int userId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  226. tv.setText(_remoteManager.getUserRelatedInfo(userId).toString());
  227. }
  228. public void getAllUsersTest() throws NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  229. StringBuffer sb = new StringBuffer("All users ::\n\n");
  230. for(IFlatUser u: _remoteManager.getAllUsers())
  231. sb.append(u.toString());
  232. tv.setText(sb.toString());
  233. }
  234. public void getUserTest(int userId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  235. tv.setText(_remoteManager.getUser(userId).toString());
  236. }
  237. public void createUserTest(UserInfo info) throws NotSetedMandatoryFieldsException, AlreadyExistsException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, NotFoundException, InvalidRecordException{
  238. tv.setText(_remoteManager.createUser(info).toString());
  239. }
  240. public void deleteuserTest(int userId) throws RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  241. tv.setText(String.valueOf(_remoteManager.deleteUser(userId)));
  242. }
  243. public void updateUserTest(int userId, UserInfo info) throws UnsupportedEncodingException, NotSetedMandatoryFieldsException, RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException{
  244. tv.setText(_remoteManager.updateUser(userId, info).toString());
  245. }
  246. public void setUserPasswordTest(int userId,String password) throws UnsupportedEncodingException, RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  247. tv.setText(String.valueOf(_remoteManager.setUserPassword(userId, password)));
  248. }
  249. public void changeUserPasswordTest(int userId, String oldPassword, String newPassword) throws UnsupportedEncodingException, RemoteObjectDoesNotExistException, NotAuthorizedException, BadRequestException, UnprocessableEntityException, ServiceUnavaliableException, NotImplementedException, InternalServerErrorException, InvalidRecordException{
  250. tv.setText(String.valueOf(_remoteManager.changeUserPassword(userId, oldPassword, newPassword)));
  251. }
  252. public void requestSandBox(Method m, Object ... params){
  253. try {
  254. m.invoke(this, params);
  255. }catch(InvocationTargetException e){
  256. e.printStackTrace();
  257. tv.setText(e.getTargetException().toString());
  258. }catch (IllegalArgumentException e) {
  259. e.printStackTrace();
  260. } catch (IllegalAccessException e) {
  261. e.printStackTrace();
  262. }
  263. }
  264. //===============================================
  265. // METHODS names
  266. private static final String getAllCategories = "getAllCategoriesTest"; // 0 params
  267. private static final String getCategory = "getCategoryTest"; // 1 param - int (categoryId)
  268. private static final String createCategory = "createCategoryTest"; // 1 param - CategoryInfo
  269. private static final String updateCategory = "updateCategoryTest"; // 2 params - int (categoryId) , CategoryInfo
  270. private static final String deleteCategory = "deleteCategoryTest"; // 1 param - int (categoryId)
  271. private static final String getAllForums = "getAllForumsTest"; // 0 params
  272. private static final String getCategoryForums = "getCategoryForumsTest"; // 1 param - int (categoryId)
  273. private static final String getForum = "getForumTest"; // 1 param - int (forumId)
  274. private static final String createForum = "createForumTest"; // 1 param - ForumInfo
  275. private static final String updateForum = "updateForumTest"; // 2 param - int (forumId), ForumInfo
  276. private static final String deleteForum = "deleteForumTest"; // 1 param - int (forumId)
  277. private static final String getAllTopics = "getAllTopicsTest"; // 0 params
  278. private static final String getForumTopics = "getForumTopicsTest"; // 1 param - int (forumId)
  279. private static final String getUsersTopics = "getUsersTopicsTest"; // 1 param - int (userId)
  280. private static final String getTopic = "getTopicTest"; // 1 param - int (topicId)
  281. private static final String createTopic = "createTopicTest"; // 1 param - TopicInfo
  282. private static final String updateTopic = "updateTopicTest"; // 2 params - int (topicId), TopicInfo
  283. private static final String deleteTopic = "deleteTopicTest"; // 1 param - int (topicId)
  284. private static final String getTopicComments = "getTopicCommentsTest"; // 1 param - int (topicId)
  285. private static final String getUserComments = "getUsersCommentsTest"; // 1 param - int (userId)
  286. private static final String getTopicComment = "getTopicCommentTest"; // 2 params - int (topicId), int (commentId)
  287. private static final String getUserComment = "getUserCommentTest"; // 2 params - int (userId), int (commentId)
  288. private static final String createComment = "createUserCommentTest"; // 2 params - int (topicId), CommentInfo
  289. private static final String updateComment = "updateCommentTest"; // 3 params - int (topicId), int (commentId), CommentInfo
  290. private static final String deleteComment = "deleteCommentTest"; // 2 params - int (topicId), int (commentId)
  291. private static final String getAllTopicSubscriptions = "getAllTopicSubscriptionsTest"; // 0 params
  292. private static final String getTopicSubscriptions = "getTopicSubscriptionsTest"; //1 param - int (topicId)
  293. private static final String getTopicSubscription = "getTopicSubscriptionTest"; // 1 param - int (subscriptionId)
  294. private static final String createTopicSubscription = "createTopicSubscriptionTest"; // 2 params - int(topicId), int (userId)
  295. private static final String deleteTopicSubscription = "deleteTopicSubscriptionTest"; // 1 param - int(subscriptionId)
  296. private static final String getAllForumSubscriptions = "getAllForumSubscriptionsTest"; // 0 params
  297. private static final String getForumSubscriptions = "getForumSubscriptionsTest"; // 1 param - int (forumId)
  298. private static final String showForumSubscription = "showForumSubscriptionTest"; // 1 param - int (subscriptionId)
  299. private static final String deleteForumSubscription = "deleteForumSubscriptionTest"; // 1 param - int (subscriptionId)
  300. private static final String createForumSubscription = "createForumSubscriptionTest"; // 2 params - int (forumId), int (userId)
  301. private static final String getUserRealatedInfo = "getUserRelatedInfoTest"; // 1 param - int (userId)
  302. private static final String getAllUsers = "getAllUsersTest"; // 0 params
  303. private static final String getUser = "getUserTest"; // 1 param - int (userId)
  304. private static final String createUser = "createUserTest"; // 1 param - UserInfo
  305. private static final String deleteUser = "deleteuserTest"; // 1 param - int (userId)
  306. private static final String updateUser = "updateUserTest"; // 2 params - int (userId), UserInfo
  307. private static final String setUserPassword = "setUserPasswordTest"; // 2 params - int userId, String password
  308. private static final String changeUserPassword = "changeUserPasswordTest"; // 3 params - int (userId), String - oldPass, String new pass
  309. private static TreeMap<String, MethodInfo> __methodsInfo = new TreeMap<String, MethodInfo>();
  310. static{
  311. MethodInfo m;
  312. m = new MethodInfo();
  313. __methodsInfo.put(getAllCategories, m);
  314. //=====================================
  315. m = new MethodInfo(int.class);
  316. __methodsInfo.put(getCategory,m);
  317. //=====================================
  318. m = new MethodInfo(CategoryInfo.class);
  319. __methodsInfo.put(createCategory,m);
  320. //=====================================
  321. m = new MethodInfo(int.class,CategoryInfo.class);
  322. __methodsInfo.put(updateCategory, m);
  323. //=====================================
  324. m = new MethodInfo(int.class);
  325. __methodsInfo.put(deleteCategory,m);
  326. //=====================================
  327. m = new MethodInfo();
  328. __methodsInfo.put(getAllForums, m);
  329. //=====================================
  330. m = new MethodInfo(int.class);
  331. __methodsInfo.put(getCategoryForums, m);
  332. //=====================================
  333. m = new MethodInfo(int.class);
  334. __methodsInfo.put(getForum, m);
  335. //=====================================
  336. m = new MethodInfo(ForumInfo.class);
  337. __methodsInfo.put(createForum,m);
  338. //=====================================
  339. m = new MethodInfo(int.class,ForumInfo.class);
  340. __methodsInfo.put(updateForum,m);
  341. //=====================================
  342. m = new MethodInfo(int.class);
  343. __methodsInfo.put(deleteForum, m);
  344. //=====================================
  345. m = new MethodInfo();
  346. __methodsInfo.put(getAllTopics, m);
  347. //=====================================
  348. m = new MethodInfo(int.class);
  349. __methodsInfo.put(getForumTopics, m);
  350. //=====================================
  351. m = new MethodInfo(int.class);
  352. __methodsInfo.put(getUsersTopics, m);
  353. //=====================================
  354. m = new MethodInfo(int.class);
  355. __methodsInfo.put(getTopic, m);
  356. //=====================================
  357. m = new MethodInfo(TopicInfo.class);
  358. __methodsInfo.put(createTopic, m);
  359. //=====================================
  360. m = new MethodInfo(int.class,TopicInfo.class);
  361. __methodsInfo.put(updateTopic,m);
  362. //=====================================
  363. m = new MethodInfo(int.class);
  364. __methodsInfo.put(deleteTopic,m);
  365. //=====================================
  366. //=====================================
  367. m = new MethodInfo(int.class);
  368. __methodsInfo.put(getTopicComments, m);
  369. //=====================================
  370. m = new MethodInfo(int.class);
  371. __methodsInfo.put(getUserComments, m);
  372. //=====================================
  373. m = new MethodInfo(int.class,int.class);
  374. __methodsInfo.put(getTopicComment, m);
  375. //=====================================
  376. m = new MethodInfo(int.class,int.class);
  377. __methodsInfo.put(getUserComment, m);
  378. //=====================================
  379. m = new MethodInfo(int.class,CommentInfo.class);
  380. __methodsInfo.put(createComment,m);
  381. //=====================================
  382. m = new MethodInfo(int.class,int.class,CommentInfo.class);
  383. __methodsInfo.put(updateComment,m);
  384. //=====================================
  385. m = new MethodInfo(int.class,int.class);
  386. __methodsInfo.put(deleteComment, m);
  387. //=====================================
  388. m = new MethodInfo();
  389. __methodsInfo.put(getAllTopicSubscriptions, m);
  390. //======================================
  391. m = new MethodInfo(int.class);
  392. __methodsInfo.put(getTopicSubscriptions, m);
  393. //======================================
  394. __methodsInfo.put(getTopicSubscription, new MethodInfo(int.class));
  395. //======================================
  396. __methodsInfo.put(createTopicSubscription, new MethodInfo(int.class,int.class));
  397. //======================================
  398. __methodsInfo.put(deleteTopicSubscription, new MethodInfo(int.class));
  399. //======================================
  400. __methodsInfo.put(getAllForumSubscriptions,new MethodInfo());
  401. __methodsInfo.put(getForumSubscriptions, new MethodInfo(int.class));
  402. __methodsInfo.put(showForumSubscription, new MethodInfo(int.class));
  403. __methodsInfo.put(deleteForumSubscription, new MethodInfo(int.class));
  404. __methodsInfo.put(createForumSubscription, new MethodInfo(int.class,int.class));
  405. __methodsInfo.put(getUserRealatedInfo, new MethodInfo(int.class));
  406. __methodsInfo.put(getAllUsers,new MethodInfo());
  407. __methodsInfo.put(getUser,new MethodInfo(int.class));
  408. __methodsInfo.put(createUser,new MethodInfo(UserInfo.class));
  409. __methodsInfo.put(deleteUser,new MethodInfo(int.class));
  410. __methodsInfo.put(updateUser,new MethodInfo(int.class,UserInfo.class));
  411. __methodsInfo.put(setUserPassword,new MethodInfo(int.class,String.class));
  412. __methodsInfo.put(changeUserPassword, new MethodInfo(int.class,String.class,String.class));
  413. }
  414. @Override
  415. protected void onCreate(Bundle savedInstanceState) {
  416. super.onCreate(savedInstanceState);
  417. setContentView(R.layout.activity_test_transition);
  418. tv = (TextView) findViewById(R.id.getReqText);
  419. executeB = (Button) findViewById(R.id.buttExecute);
  420. clearB = (Button) findViewById(R.id.buttClear);
  421. _remoteManager = ContentRemoteManager.getDefaultInstance();
  422. _remoteManager.logIn(Constants.API_USERNAME, Constants.API_PASSWORD);
  423. //===============================================
  424. // Control
  425. String currentTest = setUserPassword;
  426. MethodInfo mi = __methodsInfo.get(currentTest);
  427. int paramsCount = mi.params_count;
  428. @SuppressWarnings("rawtypes")
  429. Class [] paramsTypes = mi.params_types;
  430. params = new Object[paramsCount];
  431. // setting up params of invocation
  432. // CategoryInfo catinfo = new CategoryInfo();
  433. UserInfo userInfo = new UserInfo();
  434. userInfo.setUserName("StudyAgent")
  435. .setUserAlias("pizdaliz")
  436. .setUserEmail("agent@study.zendesk")
  437. .setUserRole(UserRole.AGENT)
  438. .setUserPhone("134-234-221")
  439. .setUserDetails("Moze zmieniac hasla")
  440. .setIsModerator(true)
  441. .setId(404416313);
  442. params[0] = 404439873;
  443. params[1] = "dupos";
  444. // params[1] = "dupa";
  445. // params[] = userInfo; //userId
  446. // catinfo .setCategoryName("Kategoria ostatnia")
  447. // .setCategoryDescription("Zmienilem to za pomoca API-")
  448. // .setPosition(2);
  449. //
  450. // ForumInfo fInfo = new ForumInfo();
  451. // fInfo .setForumName("Dupoforum (ZMIENIONA)")
  452. // .setForumDescription("Dodany opis forum")
  453. // .setForumAccessType(ForumAccessType.ACC_EVERYBODY)
  454. // .setForumPosition(1)
  455. // .setParentCategoryId(20107657);
  456. // params[1] = fInfo;
  457. // TopicInfo ti = new TopicInfo();
  458. // params[0] = 25972213;
  459. // subscription id= 26285167
  460. // ti .setParentForumId(22109581)
  461. // .setTopicTitle("Nazwa topiku zmieniona")
  462. // .setTopicBody("Topic body TO (ZMIENIONY)")
  463. // .setPosition(1);
  464. // topic id to test = 24078227
  465. // CommentInfo info = new CommentInfo();
  466. //
  467. // info .setCommentBody("<qoute> DUPSKO </quote> edit : nowa zawartosc");
  468. //params[2] = info;
  469. //===============================================
  470. try {
  471. toExecute = TestTransition.class.getMethod(currentTest, paramsTypes);
  472. } catch (NoSuchMethodException e) {
  473. e.printStackTrace();
  474. }
  475. clearB.setOnClickListener(new OnClickListener() {
  476. @Override
  477. public void onClick(View v) {
  478. tv.setText("");
  479. }
  480. });
  481. executeB.setOnClickListener(new OnClickListener() {
  482. @Override
  483. public void onClick(View v) {
  484. requestSandBox(toExecute, params);
  485. }
  486. });
  487. }
  488. @Override
  489. public boolean onCreateOptionsMenu(Menu menu) {
  490. // Inflate the menu; this adds items to the action bar if it is present.
  491. getMenuInflater().inflate(R.menu.test_transition, menu);
  492. return true;
  493. }
  494. }