ACS-5449 Code quality improvements to LockServiceImplTest & RuleServiceImplUnitTest (#2087)

This commit is contained in:
Oskar Rajzner
2023-07-28 12:20:18 +02:00
committed by GitHub
parent a39fa50bcf
commit 86189efc4a
2 changed files with 285 additions and 293 deletions

View File

@@ -34,6 +34,7 @@ import static org.alfresco.model.ContentModel.ASSOC_MEMBER;
import static org.alfresco.model.ContentModel.TYPE_CONTENT;
import static org.alfresco.model.ContentModel.TYPE_FOLDER;
import static org.alfresco.repo.rule.RuleModel.ASPECT_IGNORE_INHERITED_RULES;
import static org.alfresco.repo.rule.RuleModel.ASPECT_RULES;
import static org.alfresco.repo.rule.RuleModel.ASSOC_ACTION;
import static org.alfresco.repo.rule.RuleModel.ASSOC_RULE_FOLDER;
import static org.alfresco.repo.rule.RuleModel.TYPE_RULE;
@@ -134,12 +135,12 @@ public class RuleServiceImplUnitTest
// Call the method under test.
ruleService.saveRule(FOLDER_NODE, mockRule);
then(nodeService).should(times(2)).hasAspect(FOLDER_NODE, RuleModel.ASPECT_RULES);
then(nodeService).should(times(2)).hasAspect(FOLDER_NODE, ASPECT_RULES);
then(nodeService).should().exists(FOLDER_NODE);
then(nodeService).should().addAspect(FOLDER_NODE, RuleModel.ASPECT_RULES, null);
then(nodeService).should().addAspect(FOLDER_NODE, ASPECT_RULES, null);
then(nodeService).should().createNode(eq(RULE_SET_NODE), eq(ASSOC_CONTAINS), any(QName.class), eq(TYPE_RULE));
then(nodeService).should(atLeastOnce()).setProperty(eq(RULE_NODE), any(QName.class), nullable(Serializable.class));
then(nodeService).should().getChildAssocs(RULE_NODE, RuleModel.ASSOC_ACTION, RuleModel.ASSOC_ACTION);
then(nodeService).should().getChildAssocs(RULE_NODE, ASSOC_ACTION, ASSOC_ACTION);
verifyNoMoreInteractions(nodeService);
}
@@ -425,7 +426,7 @@ public class RuleServiceImplUnitTest
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
assertEquals("A,B,C,D,E", nodeNames);
assertEquals("Node names should match expected string", "A,B,C,D,E", nodeNames);
}
/** Check that ordered parents are returned in the correct order. */
@@ -439,7 +440,7 @@ public class RuleServiceImplUnitTest
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
assertEquals("A,B,C,D,E", nodeNames);
assertEquals("Node names should match expected string", "A,B,C,D,E", nodeNames);
}
/** Check that the ASPECT_IGNORE_INHERITED_RULES aspect breaks the chain. */
@@ -454,7 +455,7 @@ public class RuleServiceImplUnitTest
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
assertEquals("C,D,E", nodeNames);
assertEquals("Node names should match expected string", "C,D,E", nodeNames);
}
/** Check that the user group hierarchy is not traversed. */
@@ -471,7 +472,7 @@ public class RuleServiceImplUnitTest
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
assertEquals("C,D,E", nodeNames);
assertEquals("Node names should match expected string", "C,D,E", nodeNames);
}
/** Check that a cycle doesn't cause a problem. */
@@ -485,7 +486,7 @@ public class RuleServiceImplUnitTest
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
assertEquals("A,B,C", nodeNames);
assertEquals("Node names should match expected string", "A,B,C", nodeNames);
}
/** Check that a diamond of nodes is traversed correctly. */
@@ -499,7 +500,7 @@ public class RuleServiceImplUnitTest
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
assertEquals("A,B,C,D", nodeNames);
assertEquals("Node names should match expected string", "A,B,C,D", nodeNames);
}
/**
@@ -524,7 +525,7 @@ public class RuleServiceImplUnitTest
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
assertEquals("A,C,B,E,D,F,G", nodeNames);
assertEquals("Node names should match expected string", "A,C,B,E,D,F,G", nodeNames);
}
/**
@@ -549,7 +550,7 @@ public class RuleServiceImplUnitTest
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
assertEquals("A,D,C,F,B,E,G", nodeNames);
assertEquals("Node names should match expected string", "A,D,C,F,B,E,G", nodeNames);
}
/**