From c83640151edfe3e442815890d78ab2385536b84f Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Tue, 19 Jul 2016 09:31:29 +0000 Subject: [PATCH] REPO-828: MNT-16401: Delete comment notification from Blog or Links is not displayed in Site Activities dashlet - Corrected the tests. (see REPO-904) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@128814 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web/scripts/blogs/BlogServiceTest.java | 28 +++++++++++++++---- .../web/scripts/links/LinksRestApiTest.java | 27 ++++++++++++++---- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/source/test-java/org/alfresco/repo/web/scripts/blogs/BlogServiceTest.java b/source/test-java/org/alfresco/repo/web/scripts/blogs/BlogServiceTest.java index 39a9a3c304..b303d76e2a 100644 --- a/source/test-java/org/alfresco/repo/web/scripts/blogs/BlogServiceTest.java +++ b/source/test-java/org/alfresco/repo/web/scripts/blogs/BlogServiceTest.java @@ -25,6 +25,7 @@ */ package org.alfresco.repo.web.scripts.blogs; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -93,6 +94,7 @@ public class BlogServiceTest extends BaseWebScriptTest private static final String URL_MY_PUBLISHED_BLOG_POSTS = "/api/blog/site/" + SITE_SHORT_NAME_BLOG + "/" + COMPONENT_BLOG + "/posts/mypublished"; + private static final String URL_DELETE_COMMENT = "api/comment/node/{0}/{1}/{2}?site={3}&itemtitle={4}&page={5}"; private List posts; private List drafts; @@ -287,7 +289,17 @@ public class BlogServiceTest extends BaseWebScriptTest { return "/api/comment/node/" + nodeRef.replace("://", "/"); } - + + private String getDeleteCommentUrl(NodeRef commentNodeRef) + { + String itemTitle = "Test Title"; + String page = "document-details"; + + String URL = MessageFormat.format(URL_DELETE_COMMENT, new Object[] { commentNodeRef.getStoreRef().getProtocol(), + commentNodeRef.getStoreRef().getIdentifier(), commentNodeRef.getId(), SITE_SHORT_NAME_BLOG, itemTitle, page}); + return URL; + } + private JSONObject createComment(String nodeRef, String title, String content, int expectedStatus) throws Exception { @@ -751,20 +763,24 @@ public class BlogServiceTest extends BaseWebScriptTest { this.authenticationComponent.setCurrentUser(USER_ONE); JSONObject item = createPost("testActivity", "test", null, false, 200); + assertNotNull(item); postLookup.execute(); feedGenerator.execute(); - int activityNumStart = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_BLOG).size(); + int activityNumStart = activityService.getSiteFeedEntries(SITE_SHORT_NAME_BLOG).size(); String nodeRef = item.getString("nodeRef"); JSONObject commentOne = createComment(nodeRef, "comment", "content", 200); + assertNotNull(item); postLookup.execute(); feedGenerator.execute(); - int activityNumNext = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_BLOG).size(); + int activityNumNext = activityService.getSiteFeedEntries(SITE_SHORT_NAME_BLOG).size(); assertEquals("The activity feeds were not generated after adding a comment", activityNumStart + 1, activityNumNext); - - sendRequest(new DeleteRequest(getCommentUrl(commentOne.getString("nodeRef"))), 200); + activityNumStart = activityNumNext; + NodeRef commentNodeRef = new NodeRef(commentOne.getString("nodeRef")); + Response resp = sendRequest(new DeleteRequest(getDeleteCommentUrl(commentNodeRef)), 200); + assertTrue(resp.getStatus() == 200); postLookup.execute(); feedGenerator.execute(); - activityNumNext = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_BLOG).size(); + activityNumNext = activityService.getSiteFeedEntries(SITE_SHORT_NAME_BLOG).size(); assertEquals("The activity feeds were not generated after deleting a comment", activityNumStart + 1, activityNumNext); } diff --git a/source/test-java/org/alfresco/repo/web/scripts/links/LinksRestApiTest.java b/source/test-java/org/alfresco/repo/web/scripts/links/LinksRestApiTest.java index 58fb734545..ffabb5a394 100644 --- a/source/test-java/org/alfresco/repo/web/scripts/links/LinksRestApiTest.java +++ b/source/test-java/org/alfresco/repo/web/scripts/links/LinksRestApiTest.java @@ -25,6 +25,7 @@ */ package org.alfresco.repo.web.scripts.links; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Date; import java.util.HashMap; @@ -108,7 +109,9 @@ public class LinksRestApiTest extends BaseWebScriptTest private static final String URL_LINKS_CREATE = URL_LINKS_BASE + "/posts"; private static final String URL_LINKS_UPDATE = URL_LINKS_BASE + "/"; // plus path private static final String URL_LINKS_DELETE = "/api/links/delete/site/" + SITE_SHORT_NAME_LINKS + "/links"; - private static final String URL_LINKS_FETCH = "/api/links/link/site/" + SITE_SHORT_NAME_LINKS + "/links/"; // plus path + private static final String URL_LINKS_FETCH = "/api/links/link/site/" + SITE_SHORT_NAME_LINKS + "/links/"; // plus path + + private static final String URL_DELETE_COMMENT = "api/comment/node/{0}/{1}/{2}?site={3}&itemtitle={4}&page={5}"; // General methods @@ -784,23 +787,25 @@ public class LinksRestApiTest extends BaseWebScriptTest public void testCommentLink() throws Exception { + AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); JSONObject link = createLink(LINK_TITLE_ONE, "commented link", LINK_URL_ONE, false, Status.STATUS_OK); postLookup.execute(); feedGenerator.execute(); - int activityNumStart = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_LINKS).size(); + int activityNumStart = activityService.getSiteFeedEntries(SITE_SHORT_NAME_LINKS).size(); String name = getNameFromLink(link); link = getLink(name, Status.STATUS_OK); String nodeRef = link.getString("nodeRef"); JSONObject commentOne = createComment(nodeRef, "comment", "content", 200); postLookup.execute(); feedGenerator.execute(); - int activityNumNext = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_LINKS).size(); + int activityNumNext = activityService.getSiteFeedEntries(SITE_SHORT_NAME_LINKS).size(); assertEquals("The activity feeds were not generated after adding a comment", activityNumStart + 1, activityNumNext); - - sendRequest(new DeleteRequest(getCommentUrl(commentOne.getString("nodeRef"))), 200); + activityNumStart = activityNumNext; + NodeRef commentNodeRef = new NodeRef(commentOne.getString("nodeRef")); + sendRequest(new DeleteRequest(getDeleteCommentUrl(commentNodeRef)), 200); postLookup.execute(); feedGenerator.execute(); - activityNumNext = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_LINKS).size(); + activityNumNext = activityService.getSiteFeedEntries(SITE_SHORT_NAME_LINKS).size(); assertEquals("The activity feeds were not generated after deleting a comment", activityNumStart + 1, activityNumNext); } @@ -832,4 +837,14 @@ public class LinksRestApiTest extends BaseWebScriptTest { return "/api/comment/node/" + nodeRef.replace("://", "/"); } + + private String getDeleteCommentUrl(NodeRef commentNodeRef) + { + String itemTitle = "Test Title"; + String page = "document-details"; + + String URL = MessageFormat.format(URL_DELETE_COMMENT, new Object[] { commentNodeRef.getStoreRef().getProtocol(), + commentNodeRef.getStoreRef().getIdentifier(), commentNodeRef.getId(), SITE_SHORT_NAME_LINKS, itemTitle, page}); + return URL; + } }