mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merge pull request #1478 from Alfresco/feature/ACS-3615_AllowNullParams
ACS-3615 Allow actions in rules without any params.
This commit is contained in:
@@ -26,11 +26,14 @@
|
||||
|
||||
package org.alfresco.rest.api.impl.mapper.rules;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
import static org.alfresco.repo.action.access.ActionAccessRestriction.ACTION_CONTEXT_PARAM_NAME;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.repo.action.ActionImpl;
|
||||
@@ -100,8 +103,9 @@ public class RestRuleActionModelMapper implements RestModelMapper<Action, org.al
|
||||
|
||||
private org.alfresco.service.cmr.action.Action toServiceAction(Action action)
|
||||
{
|
||||
final Map<String, Serializable> params = Optional.ofNullable(action.getParams()).orElse(emptyMap());
|
||||
final Map<String, Serializable> convertedParams =
|
||||
parameterConverter.getConvertedParams(action.getParams(), action.getActionDefinitionId());
|
||||
parameterConverter.getConvertedParams(params, action.getActionDefinitionId());
|
||||
return new ActionImpl(null, GUID.generate(), action.getActionDefinitionId(), convertedParams);
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,8 @@
|
||||
|
||||
package org.alfresco.rest.api.impl.mapper.rules;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
import static org.alfresco.repo.action.access.ActionAccessRestriction.ACTION_CONTEXT_PARAM_NAME;
|
||||
import static org.alfresco.repo.action.executer.SetPropertyValueActionExecuter.PARAM_PROPERTY;
|
||||
import static org.alfresco.repo.action.executer.SetPropertyValueActionExecuter.PARAM_VALUE;
|
||||
@@ -89,7 +91,7 @@ public class RestRuleActionModelMapperTest
|
||||
public void testToRestModelWithNullValues()
|
||||
{
|
||||
final org.alfresco.service.cmr.action.Action actionServiceModel = new ActionImpl(null, null, null);
|
||||
final Action expectedAction = Action.builder().params(Collections.emptyMap()).create();
|
||||
final Action expectedAction = Action.builder().params(emptyMap()).create();
|
||||
|
||||
//when
|
||||
final Action actualAction = objectUnderTest.toRestModel(actionServiceModel);
|
||||
@@ -122,4 +124,16 @@ public class RestRuleActionModelMapperTest
|
||||
assertThat(serviceModelAction).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToServiceModelWithNullParams()
|
||||
{
|
||||
final Action action = Action.builder().actionDefinitionId(ACTION_DEFINITION_NAME).params(null).create();
|
||||
final List<Action> actions = List.of(action);
|
||||
|
||||
//when
|
||||
final org.alfresco.service.cmr.action.Action serviceModelAction = objectUnderTest.toServiceModel(actions);
|
||||
then(parameterConverter).should().getConvertedParams(emptyMap(), ACTION_DEFINITION_NAME);
|
||||
then(parameterConverter).shouldHaveNoMoreInteractions();
|
||||
assertThat(serviceModelAction).isNotNull();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user