RM-6869 removing updates

This commit is contained in:
Ross Gale
2019-06-05 10:45:13 +01:00
parent e8d1c82a21
commit afc24fa4a9
3 changed files with 48 additions and 146 deletions

View File

@@ -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();
}

View File

@@ -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());
}
}
}

View File

@@ -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.RecordCategoryChildEntry;
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.utility.Utility;
import org.alfresco.utility.model.FileModel;
@@ -62,14 +60,11 @@ public class RejectRecordTests extends BaseRMRestTest
private RecordCategory recordCategory;
private RecordCategoryChild recordFolder;
private ActionExecutorUtil actionExecutorUtil;
private RecordCategoryChildCollection recordFolders;
RecordCategoryChildCollection recordFolders;
@BeforeClass (alwaysRun = true)
public void setUp() throws Exception
{
actionExecutorUtil = new ActionExecutorUtil();
publicSite = dataSite.usingAdmin().createPublicRandomSite();
recordCategory = createRootCategory(getRandomName("recordCategory"));
recordFolder = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
@@ -80,7 +75,7 @@ public class RejectRecordTests extends BaseRMRestTest
*/
@Test
@AlfrescoTest(jira = "RM-6869")
public void testRejectingALinkedRecordRemovesLink() throws Exception
public void declareAndFileToValidLocationUsingActionsAPI() throws Exception
{
STEP("Create a document in the collaboration site");
FileModel testFile = dataContent.usingSite(publicSite)
@@ -95,7 +90,7 @@ public class RejectRecordTests extends BaseRMRestTest
STEP("Link record to new folder");
getRestAPIFactory().getActionsAPI().linkRecord(testFile, recordCategory.getName() + "/" + recordFolder.getName() + "_2");
recordFolders = null;
actionExecutorUtil.checkActionExecution(new LinkEvaluator());
checkActionExecution(new LinkEvaluator());
Optional<RecordCategoryChildEntry> linkedFolder = recordFolders.getEntries().stream().filter(child -> child.getEntry().getName().equals(recordFolder.getName() + "_2"))
.findFirst();
@@ -106,7 +101,7 @@ public class RejectRecordTests extends BaseRMRestTest
STEP("Reject record");
getRestAPIFactory().getActionsAPI().rejectRecord(testFile, "Just because");
actionExecutorUtil.checkActionExecution(new RejectEvaluator());
checkActionExecution(new RejectEvaluator());
STEP("Check record has been rejected");
assertFalse("Record rejection failure", isMatchingRecordInRecordFolder(testFile, recordFolder));
@@ -127,14 +122,54 @@ public class RejectRecordTests extends BaseRMRestTest
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
*/
private class LinkEvaluator implements ActionEvaluator
{
/**
* {@inheritDoc}
*/
@Override
public boolean evaluate()
{
@@ -142,9 +177,6 @@ public class RejectRecordTests extends BaseRMRestTest
return recordFolders != null && recordFolders.getEntries().size() == 2;
}
/**
* {@inheritDoc}
*/
@Override
public String getErrorMessage()
{
@@ -157,19 +189,13 @@ public class RejectRecordTests extends BaseRMRestTest
*/
private class RejectEvaluator implements ActionEvaluator
{
/**
* {@inheritDoc}
*/
@Override
public boolean evaluate()
{
RecordFolderCollection records = getRestAPIFactory().getRecordFolderAPI().getRecordFolderChildren(recordFolder.getId());
return records != null && records.getEntries().size() == 0;
return records != null && records.getEntries().size() == 7;
}
/**
* {@inheritDoc}
*/
@Override
public String getErrorMessage()
{