diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ActionEvaluator.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ActionEvaluator.java
new file mode 100644
index 0000000000..29f22bcffe
--- /dev/null
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ActionEvaluator.java
@@ -0,0 +1,51 @@
+/*
+ * #%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 .
+ * #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();
+}
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ActionExecutorUtil.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ActionExecutorUtil.java
new file mode 100644
index 0000000000..a804ca28d1
--- /dev/null
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ActionExecutorUtil.java
@@ -0,0 +1,73 @@
+/*
+ * #%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 .
+ * #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());
+ }
+ }
+}
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/RejectRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/RejectRecordTests.java
index 3c003d07bf..87ff1a13a9 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/RejectRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/RejectRecordTests.java
@@ -41,6 +41,8 @@ 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;
@@ -60,11 +62,14 @@ public class RejectRecordTests extends BaseRMRestTest
private RecordCategory recordCategory;
private RecordCategoryChild recordFolder;
+ private ActionExecutorUtil actionExecuterUtil;
+
private RecordCategoryChildCollection recordFolders;
@BeforeClass (alwaysRun = true)
public void setUp() throws Exception
{
+ actionExecuterUtil = new ActionExecutorUtil();
publicSite = dataSite.usingAdmin().createPublicRandomSite();
recordCategory = createRootCategory(getRandomName("recordCategory"));
recordFolder = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
@@ -90,7 +95,7 @@ public class RejectRecordTests extends BaseRMRestTest
STEP("Link record to new folder");
getRestAPIFactory().getActionsAPI().linkRecord(testFile, recordCategory.getName() + "/" + recordFolder.getName() + "_2");
recordFolders = null;
- checkActionExecution(new LinkEvaluator());
+ actionExecuterUtil.checkActionExecution(new LinkEvaluator());
Optional linkedFolder = recordFolders.getEntries().stream().filter(child -> child.getEntry().getName().equals(recordFolder.getName() + "_2"))
.findFirst();
@@ -101,7 +106,7 @@ public class RejectRecordTests extends BaseRMRestTest
STEP("Reject record");
getRestAPIFactory().getActionsAPI().rejectRecord(testFile, "Just because");
- checkActionExecution(new RejectEvaluator());
+ actionExecuterUtil.checkActionExecution(new RejectEvaluator());
STEP("Check record has been rejected");
assertFalse("Record rejection failure", isMatchingRecordInRecordFolder(testFile, recordFolder));
@@ -122,60 +127,6 @@ 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());
- }
- }
-
- /**
- * Generic interface for checking action execution
- */
- private 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();
- }
-
/**
* Check for completion of link action
*/