This is an automated email from the ASF dual-hosted git repository.

jkevan pushed a commit to branch reduceIndicesItems3
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/reduceIndicesItems3 by this 
push:
     new 6d0e1afef UNOMI-736: Fix IT
6d0e1afef is described below

commit 6d0e1afef1cbe1b7de409ed7c5814ab7e92d4ab1
Author: Kevan <ke...@jahia.com>
AuthorDate: Tue Feb 28 14:43:24 2023 +0100

    UNOMI-736: Fix IT
---
 .../actions/services/impl/GroovyActionsServiceImpl.java   | 15 ++++++++-------
 .../org/apache/unomi/itests/GroovyActionsServiceIT.java   | 11 +++++++----
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git 
a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
 
b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
index cc120e869..0a38e9010 100644
--- 
a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
+++ 
b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
@@ -214,14 +214,15 @@ public class GroovyActionsServiceImpl implements 
GroovyActionsService {
     @Override
     public void remove(String id) {
         String groovySourceCodeId = getGroovyCodeSourceIdForActionId(id);
-        try {
-            definitionsService.removeActionType(
-                    
groovyShell.parse(groovyCodeSourceMap.get(groovySourceCodeId)).getClass().getMethod("execute").getAnnotation(Action.class).id());
-        } catch (NoSuchMethodException e) {
-            logger.error("Failed to delete the action type for the id {}", id, 
e);
+        if (groovyCodeSourceMap.containsKey(groovySourceCodeId)) {
+            try {
+                definitionsService.removeActionType(
+                        
groovyShell.parse(groovyCodeSourceMap.get(groovySourceCodeId)).getClass().getMethod("execute").getAnnotation(Action.class).id());
+            } catch (NoSuchMethodException e) {
+                logger.error("Failed to delete the action type for the id {}", 
id, e);
+            }
+            persistenceService.remove(groovySourceCodeId, GroovyAction.class);
         }
-        persistenceService.remove(groovySourceCodeId, GroovyAction.class);
-        groovyCodeSourceMap.remove(groovySourceCodeId);
     }
 
     @Override
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/GroovyActionsServiceIT.java 
b/itests/src/test/java/org/apache/unomi/itests/GroovyActionsServiceIT.java
index 18cd2c80f..7fecea183 100644
--- a/itests/src/test/java/org/apache/unomi/itests/GroovyActionsServiceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/GroovyActionsServiceIT.java
@@ -101,10 +101,10 @@ public class GroovyActionsServiceIT extends BaseIT {
         groovyActionsService.save(UPDATE_ADDRESS_ACTION, 
loadGroovyAction(UPDATE_ADDRESS_ACTION_GROOVY_FILE));
 
         keepTrying("Failed waiting for the creation of the GroovyAction for 
the trigger action test",
-                () -> 
groovyActionsService.getGroovyCodeSource(UPDATE_ADDRESS_ACTION), 
Objects::nonNull, 1000, 100);
+                () -> 
groovyActionsService.getGroovyCodeSource(UPDATE_ADDRESS_ACTION), 
Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         ActionType actionType = keepTrying("Failed waiting for the creation of 
the GroovyAction for trigger action test",
-                () -> 
definitionsService.getActionType(UPDATE_ADDRESS_GROOVY_ACTION), 
Objects::nonNull, 1000, 100);
+                () -> 
definitionsService.getActionType(UPDATE_ADDRESS_GROOVY_ACTION), 
Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         Assert.assertNotNull(actionType);
 
@@ -118,7 +118,10 @@ public class GroovyActionsServiceIT extends BaseIT {
         groovyActionsService.save(UPDATE_ADDRESS_ACTION, 
loadGroovyAction(UPDATE_ADDRESS_ACTION_GROOVY_FILE));
 
         ActionType actionType = keepTrying("Failed waiting for the creation of 
the GroovyAction for the save test",
-                () -> 
definitionsService.getActionType(UPDATE_ADDRESS_GROOVY_ACTION), 
Objects::nonNull, 1000, 100);
+                () -> 
definitionsService.getActionType(UPDATE_ADDRESS_GROOVY_ACTION), 
Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+
+        GroovyCodeSource groovyCodeSource = keepTrying("Failed waiting for the 
creation of the GroovyAction for the save test",
+                () -> 
groovyActionsService.getGroovyCodeSource(UPDATE_ADDRESS_ACTION), 
Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         Assert.assertEquals(UPDATE_ADDRESS_ACTION + "-groovySourceCode", 
groovyActionsService.getGroovyCodeSource(UPDATE_ADDRESS_ACTION).getName());
 
@@ -137,7 +140,7 @@ public class GroovyActionsServiceIT extends BaseIT {
         groovyActionsService.save(UPDATE_ADDRESS_ACTION, 
loadGroovyAction(UPDATE_ADDRESS_ACTION_GROOVY_FILE));
 
         GroovyCodeSource groovyCodeSource = keepTrying("Failed waiting for the 
creation of the GroovyAction for the remove test",
-                () -> 
groovyActionsService.getGroovyCodeSource(UPDATE_ADDRESS_ACTION), 
Objects::nonNull, 1000, 100);
+                () -> 
groovyActionsService.getGroovyCodeSource(UPDATE_ADDRESS_ACTION), 
Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         Assert.assertNotNull(groovyCodeSource);
 

Reply via email to