68860: test fixes after merging latest dspace-origin/master

This commit is contained in:
Marie Verdonck
2020-02-19 15:14:29 +01:00
parent c498838e39
commit 570f77d1a6
9 changed files with 20 additions and 19 deletions

View File

@@ -23,6 +23,7 @@ public class WorkflowActionConverter implements DSpaceConverter<WorkflowActionCo
@Override
public WorkflowActionRest convert(WorkflowActionConfig modelObject, Projection projection) {
WorkflowActionRest restModel = new WorkflowActionRest();
restModel.setProjection(projection);
restModel.setId(modelObject.getId());
restModel.setOptions(modelObject.getOptions());
return restModel;

View File

@@ -30,6 +30,7 @@ public class WorkflowStepConverter implements DSpaceConverter<Step, WorkflowStep
@Override
public WorkflowStepRest convert(Step modelObject, Projection projection) {
WorkflowStepRest restModel = new WorkflowStepRest();
restModel.setProjection(projection);
restModel.setId(modelObject.getId());
restModel.setWorkflowactions(modelObject.getActions().stream()
.map(x -> (WorkflowActionRest) converter.toRest(x, projection))

View File

@@ -11,7 +11,6 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dspace.app.rest.RestResourceController;
import org.dspace.xmlworkflow.state.Step;
/**
* The rest resource used for workflow definitions
@@ -21,10 +20,7 @@ import org.dspace.xmlworkflow.state.Step;
@LinksRest(links = {
@LinkRest(
name = WorkflowDefinitionRest.COLLECTIONS_MAPPED_TO,
linkClass = CollectionRest.class,
method = "getCollections",
embedOptional = true,
linkOptional = true
method = "getCollections"
)
})
public class WorkflowDefinitionRest extends BaseObjectRest<String> {
@@ -75,7 +71,7 @@ public class WorkflowDefinitionRest extends BaseObjectRest<String> {
this.isDefault = isDefault;
}
@LinkRest(linkClass = Step.class)
@LinkRest
@JsonIgnore
public List<WorkflowStepRest> getSteps() {
return steps;

View File

@@ -11,7 +11,6 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dspace.app.rest.RestResourceController;
import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
/**
* The rest resource used for workflow steps
@@ -41,7 +40,7 @@ public class WorkflowStepRest extends BaseObjectRest {
return NAME;
}
@LinkRest(linkClass = WorkflowActionConfig.class)
@LinkRest
@JsonIgnore
public List<WorkflowActionRest> getWorkflowactions() {
return workflowactions;

View File

@@ -35,7 +35,7 @@ public class WorkflowActionRestRepository extends DSpaceRestRepository<WorkflowA
public WorkflowActionRest findOne(Context context, String workflowActionName) {
WorkflowActionConfig actionConfig = this.xmlWorkflowFactory.getActionByName(workflowActionName);
if (actionConfig != null) {
return converter.toRest(actionConfig, utils.obtainProjection(true));
return converter.toRest(actionConfig, utils.obtainProjection());
} else {
throw new ResourceNotFoundException("No workflow action with name " + workflowActionName
+ " is configured");

View File

@@ -46,8 +46,7 @@ public class WorkflowDefinitionRestRepository extends DSpaceRestRepository<Workf
public WorkflowDefinitionRest findOne(Context context, String workflowName) {
if (xmlWorkflowFactory.workflowByThisNameExists(workflowName)) {
try {
return converter.toRest(xmlWorkflowFactory.getWorkflowByName(workflowName),
utils.obtainProjection(true));
return converter.toRest(xmlWorkflowFactory.getWorkflowByName(workflowName), utils.obtainProjection());
} catch (WorkflowConfigurationException e) {
// Should never occur, since xmlWorkflowFactory.getWorkflowByName only throws a
// WorkflowConfigurationException if no workflow by that name is configured (tested earlier)
@@ -62,7 +61,7 @@ public class WorkflowDefinitionRestRepository extends DSpaceRestRepository<Workf
@PreAuthorize("hasAuthority('AUTHENTICATED')")
public Page<WorkflowDefinitionRest> findAll(Context context, Pageable pageable) {
List<Workflow> workflows = xmlWorkflowFactory.getAllConfiguredWorkflows();
return converter.toRestPage(utils.getPage(workflows, pageable), utils.obtainProjection(true));
return converter.toRestPage(utils.getPage(workflows, pageable), utils.obtainProjection());
}
/**

View File

@@ -35,7 +35,7 @@ public class WorkflowStepRestRepository extends DSpaceRestRepository<WorkflowSte
public WorkflowStepRest findOne(Context context, String workflowStepName) {
Step step = this.xmlWorkflowFactory.getStepByName(workflowStepName);
if (step != null) {
return converter.toRest(step, utils.obtainProjection(true));
return converter.toRest(step, utils.obtainProjection());
} else {
throw new ResourceNotFoundException("No workflow step with name " + workflowStepName
+ " is configured");

View File

@@ -239,7 +239,7 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
//When we call this facets endpoint
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/search/findByCollection?uuid=" + nonValidUUID))
//We expect a 422 Unprocessable Entity status
.andExpect(status().is(422));
.andExpect(status().isUnprocessableEntity());
}
@Test
@@ -388,7 +388,8 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
//When we call this facets endpoint
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + workflowName + "/collections"))
.andExpect(status().isInternalServerError());
//We expect a 404 Not Found
.andExpect(status().isNotFound());
}
@Test
@@ -399,7 +400,8 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
//When we call this facets endpoint
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
+ "/collections"))
.andExpect(status().isInternalServerError());
//We expect a 403 Forbidden status
.andExpect(status().isForbidden());
}
@Test
@@ -410,7 +412,8 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
//When we call this facets endpoint
getClient().perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
+ "/collections"))
.andExpect(status().isInternalServerError());
//We expect a 401 Unauthorized
.andExpect(status().isUnauthorized());
}
@Test
@@ -420,7 +423,8 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
//When we call this facets endpoint
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
+ "/steps"))
+ "/steps")
.param("projection", "full"))
//We expect a 200 OK status
.andExpect(status().isOk())
//Number of total workflows is equals to number of non-mapped collections

View File

@@ -75,7 +75,8 @@ public class WorkflowStepRestRepositoryIT extends AbstractControllerIntegrationT
String nameStep = "reviewstep";
Step existentStep = xmlWorkflowFactory.getStepByName(nameStep);
//When we call this facets endpoint
getClient(token).perform(get(WORKFLOW_ACTIONS_ENDPOINT + "/" + nameStep))
getClient(token).perform(get(WORKFLOW_ACTIONS_ENDPOINT + "/" + nameStep)
.param("projection", "full"))
//We expect a 200 is ok status
.andExpect(status().isOk())
//Matches expected step