ACS-3345 e2e REST API TAS tests delete rule (#1256)

* ACS-3345: REST API TAS tests for delete rule.

* ACS-3345: REST API TAS tests for delete rule.

* ACS-3345: REST API TAS tests for delete rule.

* ACS-3345: Fixing the naming.

* ACS-3345: REST API TAS tests for delete rule.
This commit is contained in:
Maciej Pichura
2022-07-29 14:29:56 +02:00
committed by GitHub
parent d84424ee5b
commit 7b4f7c9174
4 changed files with 292 additions and 2 deletions

View File

@@ -41,6 +41,7 @@ import org.alfresco.rest.api.model.rules.Rule;
import org.alfresco.rest.api.model.rules.RuleSet;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.ListPage;
import org.alfresco.rest.framework.resource.parameters.Paging;
@@ -183,7 +184,13 @@ public class RulesImpl implements Rules
{
if (RuleSet.isDefaultId(ruleSetId))
{
return ruleService.getRuleSetNode(associatedFolderNodeRef);
final NodeRef ruleSetNodeRef = ruleService.getRuleSetNode(associatedFolderNodeRef);
if (ruleSetNodeRef == null)
{
//folder doesn't have a -default- rule set
throw new RelationshipResourceNotFoundException(associatedFolderNodeRef.getId(), ruleSetId);
}
return ruleSetNodeRef;
}
final NodeRef ruleSetNodeRef = validateNode(ruleSetId, ContentModel.TYPE_SYSTEM_FOLDER, RULE_SET_EXPECTED_TYPE_NAME);

View File

@@ -53,6 +53,7 @@ import org.alfresco.rest.api.model.rules.Rule;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.service.Experimental;
@@ -196,6 +197,20 @@ public class RulesImplTest extends TestCase
then(ruleServiceMock).shouldHaveNoInteractions();
}
@Test
public void testGetRulesForNotExistingDefaultRuleSetNode()
{
given(nodesMock.nodeMatches(eq(folderNodeRef), any(), any())).willReturn(true);
given(ruleServiceMock.getRuleSetNode(folderNodeRef)).willReturn(null);
// when
assertThatExceptionOfType(RelationshipResourceNotFoundException.class).isThrownBy(
() -> rules.getRules(FOLDER_NODE_ID, DEFAULT_ID, paging));
then(ruleServiceMock).should().getRuleSetNode(folderNodeRef);
then(ruleServiceMock).shouldHaveNoMoreInteractions();
}
@Test
public void testGetRulesForNotAssociatedRuleSetToFolder()
{