mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-6869 removing updates
This commit is contained in:
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.rest.rm.community.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic interface for checking action execution
|
|
||||||
*
|
|
||||||
* @author Ross Gale
|
|
||||||
* @since 3.1
|
|
||||||
*/
|
|
||||||
public interface ActionEvaluator
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The check for completion
|
|
||||||
*
|
|
||||||
* @return boolean for if the action has been successfully executed
|
|
||||||
*/
|
|
||||||
boolean evaluate();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Error message for an action not completed
|
|
||||||
*
|
|
||||||
* @return String action specific error message
|
|
||||||
*/
|
|
||||||
String getErrorMessage();
|
|
||||||
}
|
|
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
package org.alfresco.rest.rm.community.util;
|
|
||||||
|
|
||||||
import static org.testng.AssertJUnit.fail;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Ross Gale
|
|
||||||
* @since 3.1
|
|
||||||
*/
|
|
||||||
public class ActionExecutorUtil
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Method to wait and retry when using the actions api
|
|
||||||
*
|
|
||||||
* @param evaluator the action specific check for completion
|
|
||||||
*/
|
|
||||||
public void checkActionExecution(ActionEvaluator evaluator)
|
|
||||||
{
|
|
||||||
int counter = 0;
|
|
||||||
int waitInMilliSeconds = 7000;
|
|
||||||
while (counter < 4)
|
|
||||||
{
|
|
||||||
synchronized (this)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.wait(waitInMilliSeconds);
|
|
||||||
} catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
// Restore interrupted state...
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (evaluator.evaluate())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (counter == 4)
|
|
||||||
{
|
|
||||||
fail(evaluator.getErrorMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -41,8 +41,6 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildCollection;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildCollection;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildEntry;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildEntry;
|
||||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection;
|
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection;
|
||||||
import org.alfresco.rest.rm.community.util.ActionEvaluator;
|
|
||||||
import org.alfresco.rest.rm.community.util.ActionExecutorUtil;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
import org.alfresco.utility.Utility;
|
import org.alfresco.utility.Utility;
|
||||||
import org.alfresco.utility.model.FileModel;
|
import org.alfresco.utility.model.FileModel;
|
||||||
@@ -62,14 +60,11 @@ public class RejectRecordTests extends BaseRMRestTest
|
|||||||
private RecordCategory recordCategory;
|
private RecordCategory recordCategory;
|
||||||
private RecordCategoryChild recordFolder;
|
private RecordCategoryChild recordFolder;
|
||||||
|
|
||||||
private ActionExecutorUtil actionExecutorUtil;
|
RecordCategoryChildCollection recordFolders;
|
||||||
|
|
||||||
private RecordCategoryChildCollection recordFolders;
|
|
||||||
|
|
||||||
@BeforeClass (alwaysRun = true)
|
@BeforeClass (alwaysRun = true)
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
actionExecutorUtil = new ActionExecutorUtil();
|
|
||||||
publicSite = dataSite.usingAdmin().createPublicRandomSite();
|
publicSite = dataSite.usingAdmin().createPublicRandomSite();
|
||||||
recordCategory = createRootCategory(getRandomName("recordCategory"));
|
recordCategory = createRootCategory(getRandomName("recordCategory"));
|
||||||
recordFolder = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
recordFolder = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
||||||
@@ -80,7 +75,7 @@ public class RejectRecordTests extends BaseRMRestTest
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@AlfrescoTest(jira = "RM-6869")
|
@AlfrescoTest(jira = "RM-6869")
|
||||||
public void testRejectingALinkedRecordRemovesLink() throws Exception
|
public void declareAndFileToValidLocationUsingActionsAPI() throws Exception
|
||||||
{
|
{
|
||||||
STEP("Create a document in the collaboration site");
|
STEP("Create a document in the collaboration site");
|
||||||
FileModel testFile = dataContent.usingSite(publicSite)
|
FileModel testFile = dataContent.usingSite(publicSite)
|
||||||
@@ -95,7 +90,7 @@ public class RejectRecordTests extends BaseRMRestTest
|
|||||||
STEP("Link record to new folder");
|
STEP("Link record to new folder");
|
||||||
getRestAPIFactory().getActionsAPI().linkRecord(testFile, recordCategory.getName() + "/" + recordFolder.getName() + "_2");
|
getRestAPIFactory().getActionsAPI().linkRecord(testFile, recordCategory.getName() + "/" + recordFolder.getName() + "_2");
|
||||||
recordFolders = null;
|
recordFolders = null;
|
||||||
actionExecutorUtil.checkActionExecution(new LinkEvaluator());
|
checkActionExecution(new LinkEvaluator());
|
||||||
|
|
||||||
Optional<RecordCategoryChildEntry> linkedFolder = recordFolders.getEntries().stream().filter(child -> child.getEntry().getName().equals(recordFolder.getName() + "_2"))
|
Optional<RecordCategoryChildEntry> linkedFolder = recordFolders.getEntries().stream().filter(child -> child.getEntry().getName().equals(recordFolder.getName() + "_2"))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
@@ -106,7 +101,7 @@ public class RejectRecordTests extends BaseRMRestTest
|
|||||||
|
|
||||||
STEP("Reject record");
|
STEP("Reject record");
|
||||||
getRestAPIFactory().getActionsAPI().rejectRecord(testFile, "Just because");
|
getRestAPIFactory().getActionsAPI().rejectRecord(testFile, "Just because");
|
||||||
actionExecutorUtil.checkActionExecution(new RejectEvaluator());
|
checkActionExecution(new RejectEvaluator());
|
||||||
|
|
||||||
STEP("Check record has been rejected");
|
STEP("Check record has been rejected");
|
||||||
assertFalse("Record rejection failure", isMatchingRecordInRecordFolder(testFile, recordFolder));
|
assertFalse("Record rejection failure", isMatchingRecordInRecordFolder(testFile, recordFolder));
|
||||||
@@ -127,14 +122,54 @@ public class RejectRecordTests extends BaseRMRestTest
|
|||||||
dataSite.deleteSite(publicSite);
|
dataSite.deleteSite(publicSite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to wait and retry when using the actions api
|
||||||
|
* @param evaluator the action specific check for completion
|
||||||
|
*/
|
||||||
|
private void checkActionExecution(ActionEvaluator evaluator)
|
||||||
|
{
|
||||||
|
int counter = 0;
|
||||||
|
int waitInMilliSeconds = 7000;
|
||||||
|
while (counter < 4)
|
||||||
|
{
|
||||||
|
synchronized (this)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.wait(waitInMilliSeconds);
|
||||||
|
} catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
// Restore interrupted state...
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (evaluator.evaluate())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(counter == 4)
|
||||||
|
{
|
||||||
|
fail(evaluator.getErrorMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface ActionEvaluator
|
||||||
|
{
|
||||||
|
boolean evaluate();
|
||||||
|
|
||||||
|
String getErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for completion of link action
|
* Check for completion of link action
|
||||||
*/
|
*/
|
||||||
private class LinkEvaluator implements ActionEvaluator
|
private class LinkEvaluator implements ActionEvaluator
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean evaluate()
|
public boolean evaluate()
|
||||||
{
|
{
|
||||||
@@ -142,9 +177,6 @@ public class RejectRecordTests extends BaseRMRestTest
|
|||||||
return recordFolders != null && recordFolders.getEntries().size() == 2;
|
return recordFolders != null && recordFolders.getEntries().size() == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getErrorMessage()
|
public String getErrorMessage()
|
||||||
{
|
{
|
||||||
@@ -157,19 +189,13 @@ public class RejectRecordTests extends BaseRMRestTest
|
|||||||
*/
|
*/
|
||||||
private class RejectEvaluator implements ActionEvaluator
|
private class RejectEvaluator implements ActionEvaluator
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean evaluate()
|
public boolean evaluate()
|
||||||
{
|
{
|
||||||
RecordFolderCollection records = getRestAPIFactory().getRecordFolderAPI().getRecordFolderChildren(recordFolder.getId());
|
RecordFolderCollection records = getRestAPIFactory().getRecordFolderAPI().getRecordFolderChildren(recordFolder.getId());
|
||||||
return records != null && records.getEntries().size() == 0;
|
return records != null && records.getEntries().size() == 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getErrorMessage()
|
public String getErrorMessage()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user