ACS-3489 Use specified rule set. (#1373)

* ACS-3280 Get inherited rule sets. [tas]

This needs to work the exact same way as get inherited rules.

* ACS-3280 Replace LinkedList with ArrayList.

* ACS-3280 Don't return duplicated rule sets when there are links.

* ACS-3489 E2E test for getting rules with inheritance.

* ACS-3489 Inherited rule sets are also associated with folders.

* ACS-3489 Fix test to contain expected values.

* ACS-3489 Ensure only rules from specified rule set are returned.

Add E2E test case for inherited links and fix unit tests.

* ACS-3489 Fix audit reference in RuleService.
This commit is contained in:
Tom Page
2022-09-13 10:23:16 +01:00
committed by GitHub
parent bc9c23503b
commit 400b33c7eb
6 changed files with 221 additions and 13 deletions

View File

@@ -254,6 +254,8 @@ public class RuleServiceImplUnitTest
boolean associated = ruleService.isRuleSetAssociatedWithFolder(RULE_SET_NODE, FOLDER_NODE);
then(runtimeNodeService).should().getParentAssocs(RULE_SET_NODE, ASSOC_RULE_FOLDER, ASSOC_RULE_FOLDER);
then(runtimeNodeService).should().hasAspect(FOLDER_NODE, ASPECT_IGNORE_INHERITED_RULES);
then(runtimeNodeService).should().getParentAssocs(FOLDER_NODE);
then(runtimeNodeService).shouldHaveNoMoreInteractions();
then(nodeService).shouldHaveNoInteractions();
assertThat(associated).isTrue();
@@ -268,6 +270,8 @@ public class RuleServiceImplUnitTest
boolean associated = ruleService.isRuleSetAssociatedWithFolder(RULE_SET_NODE, FOLDER_NODE);
then(runtimeNodeService).should().getParentAssocs(RULE_SET_NODE, ASSOC_RULE_FOLDER, ASSOC_RULE_FOLDER);
then(runtimeNodeService).should().hasAspect(FOLDER_NODE, ASPECT_IGNORE_INHERITED_RULES);
then(runtimeNodeService).should().getParentAssocs(FOLDER_NODE);
then(runtimeNodeService).shouldHaveNoMoreInteractions();
then(nodeService).shouldHaveNoInteractions();
assertThat(associated).isFalse();
@@ -283,11 +287,45 @@ public class RuleServiceImplUnitTest
boolean associated = ruleService.isRuleSetAssociatedWithFolder(RULE_SET_NODE, FOLDER_NODE);
then(runtimeNodeService).should().getParentAssocs(RULE_SET_NODE, ASSOC_RULE_FOLDER, ASSOC_RULE_FOLDER);
then(runtimeNodeService).should().hasAspect(FOLDER_NODE, ASPECT_IGNORE_INHERITED_RULES);
then(runtimeNodeService).should().getParentAssocs(FOLDER_NODE);
then(runtimeNodeService).shouldHaveNoMoreInteractions();
then(nodeService).shouldHaveNoInteractions();
assertThat(associated).isFalse();
}
/**
* Check that a rule set is associated with the folder in the following case:
* <pre>
* parent --[link]-> rule set <-[owned]-- owningFolder
* +- child
* </pre>
*/
@Test
public void testIsRuleSetAssociatedWithFolder_inheritedLinkedAssociation()
{
// The rule is owned by one node.
NodeRef owningFolder = new NodeRef("owning://node/");
// The rule is linked to by the parent node.
NodeRef parent = new NodeRef("parent://node/");
List<ChildAssociationRef> ruleAssociations = List.of(createAssociation(owningFolder, RULE_SET_NODE), createAssociation(parent, RULE_SET_NODE));
given(runtimeNodeService.getParentAssocs(RULE_SET_NODE, ASSOC_RULE_FOLDER, ASSOC_RULE_FOLDER)).willReturn(ruleAssociations);
// The parent and the child both supply rule sets.
given(runtimeNodeService.getParentAssocs(FOLDER_NODE)).willReturn(List.of(createAssociation(parent, FOLDER_NODE)));
// when
boolean associated = ruleService.isRuleSetAssociatedWithFolder(RULE_SET_NODE, FOLDER_NODE);
then(runtimeNodeService).should().getParentAssocs(RULE_SET_NODE, ASSOC_RULE_FOLDER, ASSOC_RULE_FOLDER);
then(runtimeNodeService).should().hasAspect(FOLDER_NODE, ASPECT_IGNORE_INHERITED_RULES);
then(runtimeNodeService).should().getParentAssocs(FOLDER_NODE);
then(runtimeNodeService).should().hasAspect(parent, ASPECT_IGNORE_INHERITED_RULES);
then(runtimeNodeService).should().getParentAssocs(parent);
then(runtimeNodeService).shouldHaveNoMoreInteractions();
then(nodeService).shouldHaveNoInteractions();
assertThat(associated).isTrue();
}
@Test
public void testIsRuleAssociatedWithRuleSet()
{