REPO-1868: added 400 and 401 status tests.

Also fixed jackson deserialisation that I had unwittingly broken
in the last commit by taking out the "id" field in ActionDefinition.
This commit is contained in:
Matt Ward
2017-11-23 17:20:37 +00:00
parent fae67efcb5
commit 34ca56759c
3 changed files with 19 additions and 3 deletions

View File

@@ -94,6 +94,7 @@ public class ActionsImpl implements Actions
map(this::toModel). map(this::toModel).
collect(Collectors.toList()); collect(Collectors.toList());
return new ActionDefinition( return new ActionDefinition(
actionDefinition.getName(), // ID is a synonym for name.
actionDefinition.getName(), actionDefinition.getName(),
actionDefinition.getTitle(), actionDefinition.getTitle(),
actionDefinition.getDescription(), actionDefinition.getDescription(),

View File

@@ -29,6 +29,7 @@ import java.util.List;
public class ActionDefinition public class ActionDefinition
{ {
private String id;
private String name; private String name;
private String title; private String title;
private String description; private String description;
@@ -44,7 +45,8 @@ public class ActionDefinition
{ {
} }
public ActionDefinition(String name, public ActionDefinition(String id,
String name,
String title, String title,
String description, String description,
List<String> applicableTypes, List<String> applicableTypes,
@@ -52,6 +54,7 @@ public class ActionDefinition
boolean trackStatus, boolean trackStatus,
List<ParameterDefinition> parameterDefinitions) List<ParameterDefinition> parameterDefinitions)
{ {
this.id = id;
this.name = name; this.name = name;
this.title = title; this.title = title;
this.description = description; this.description = description;
@@ -62,11 +65,11 @@ public class ActionDefinition
} }
/** /**
* Synonym for name. * Will be used as a synonym for name.
*/ */
public String getId() public String getId()
{ {
return getName(); return id;
} }
public String getName() public String getName()

View File

@@ -399,6 +399,12 @@ public class TestActions extends AbstractBaseApiTest
assertEquals(expectedActions, retrievedActions); assertEquals(expectedActions, retrievedActions);
} }
// Badly formed request -> 400
{
PublicApiClient.Paging paging = getPaging(0, -1); // -1 is not acceptable
actions.getActionDefinitionsForNode(validNode.getId(), createParams(paging, null), 400);
}
// Non-existent node ID // Non-existent node ID
{ {
NodeRef nodeRef = new NodeRef( NodeRef nodeRef = new NodeRef(
@@ -408,5 +414,11 @@ public class TestActions extends AbstractBaseApiTest
actions.getActionDefinitionsForNode(nodeRef.getId(), emptyParams, 404); actions.getActionDefinitionsForNode(nodeRef.getId(), emptyParams, 404);
} }
// Unauthorized -> 401
{
publicApiClient.setRequestContext(new RequestContext(account1.getId(), person1, "invalid-password"));
actions.getActionDefinitionsForNode(validNode.getId(), emptyParams, 401);
}
} }
} }