mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 02:24:18 +00:00
68860: test fixes after merging latest dspace-origin/master
This commit is contained in:
@@ -23,6 +23,7 @@ public class WorkflowActionConverter implements DSpaceConverter<WorkflowActionCo
|
|||||||
@Override
|
@Override
|
||||||
public WorkflowActionRest convert(WorkflowActionConfig modelObject, Projection projection) {
|
public WorkflowActionRest convert(WorkflowActionConfig modelObject, Projection projection) {
|
||||||
WorkflowActionRest restModel = new WorkflowActionRest();
|
WorkflowActionRest restModel = new WorkflowActionRest();
|
||||||
|
restModel.setProjection(projection);
|
||||||
restModel.setId(modelObject.getId());
|
restModel.setId(modelObject.getId());
|
||||||
restModel.setOptions(modelObject.getOptions());
|
restModel.setOptions(modelObject.getOptions());
|
||||||
return restModel;
|
return restModel;
|
||||||
|
@@ -30,6 +30,7 @@ public class WorkflowStepConverter implements DSpaceConverter<Step, WorkflowStep
|
|||||||
@Override
|
@Override
|
||||||
public WorkflowStepRest convert(Step modelObject, Projection projection) {
|
public WorkflowStepRest convert(Step modelObject, Projection projection) {
|
||||||
WorkflowStepRest restModel = new WorkflowStepRest();
|
WorkflowStepRest restModel = new WorkflowStepRest();
|
||||||
|
restModel.setProjection(projection);
|
||||||
restModel.setId(modelObject.getId());
|
restModel.setId(modelObject.getId());
|
||||||
restModel.setWorkflowactions(modelObject.getActions().stream()
|
restModel.setWorkflowactions(modelObject.getActions().stream()
|
||||||
.map(x -> (WorkflowActionRest) converter.toRest(x, projection))
|
.map(x -> (WorkflowActionRest) converter.toRest(x, projection))
|
||||||
|
@@ -11,7 +11,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import org.dspace.app.rest.RestResourceController;
|
import org.dspace.app.rest.RestResourceController;
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rest resource used for workflow definitions
|
* The rest resource used for workflow definitions
|
||||||
@@ -21,10 +20,7 @@ import org.dspace.xmlworkflow.state.Step;
|
|||||||
@LinksRest(links = {
|
@LinksRest(links = {
|
||||||
@LinkRest(
|
@LinkRest(
|
||||||
name = WorkflowDefinitionRest.COLLECTIONS_MAPPED_TO,
|
name = WorkflowDefinitionRest.COLLECTIONS_MAPPED_TO,
|
||||||
linkClass = CollectionRest.class,
|
method = "getCollections"
|
||||||
method = "getCollections",
|
|
||||||
embedOptional = true,
|
|
||||||
linkOptional = true
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
public class WorkflowDefinitionRest extends BaseObjectRest<String> {
|
public class WorkflowDefinitionRest extends BaseObjectRest<String> {
|
||||||
@@ -75,7 +71,7 @@ public class WorkflowDefinitionRest extends BaseObjectRest<String> {
|
|||||||
this.isDefault = isDefault;
|
this.isDefault = isDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LinkRest(linkClass = Step.class)
|
@LinkRest
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public List<WorkflowStepRest> getSteps() {
|
public List<WorkflowStepRest> getSteps() {
|
||||||
return steps;
|
return steps;
|
||||||
|
@@ -11,7 +11,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import org.dspace.app.rest.RestResourceController;
|
import org.dspace.app.rest.RestResourceController;
|
||||||
import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rest resource used for workflow steps
|
* The rest resource used for workflow steps
|
||||||
@@ -41,7 +40,7 @@ public class WorkflowStepRest extends BaseObjectRest {
|
|||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LinkRest(linkClass = WorkflowActionConfig.class)
|
@LinkRest
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public List<WorkflowActionRest> getWorkflowactions() {
|
public List<WorkflowActionRest> getWorkflowactions() {
|
||||||
return workflowactions;
|
return workflowactions;
|
||||||
|
@@ -35,7 +35,7 @@ public class WorkflowActionRestRepository extends DSpaceRestRepository<WorkflowA
|
|||||||
public WorkflowActionRest findOne(Context context, String workflowActionName) {
|
public WorkflowActionRest findOne(Context context, String workflowActionName) {
|
||||||
WorkflowActionConfig actionConfig = this.xmlWorkflowFactory.getActionByName(workflowActionName);
|
WorkflowActionConfig actionConfig = this.xmlWorkflowFactory.getActionByName(workflowActionName);
|
||||||
if (actionConfig != null) {
|
if (actionConfig != null) {
|
||||||
return converter.toRest(actionConfig, utils.obtainProjection(true));
|
return converter.toRest(actionConfig, utils.obtainProjection());
|
||||||
} else {
|
} else {
|
||||||
throw new ResourceNotFoundException("No workflow action with name " + workflowActionName
|
throw new ResourceNotFoundException("No workflow action with name " + workflowActionName
|
||||||
+ " is configured");
|
+ " is configured");
|
||||||
|
@@ -46,8 +46,7 @@ public class WorkflowDefinitionRestRepository extends DSpaceRestRepository<Workf
|
|||||||
public WorkflowDefinitionRest findOne(Context context, String workflowName) {
|
public WorkflowDefinitionRest findOne(Context context, String workflowName) {
|
||||||
if (xmlWorkflowFactory.workflowByThisNameExists(workflowName)) {
|
if (xmlWorkflowFactory.workflowByThisNameExists(workflowName)) {
|
||||||
try {
|
try {
|
||||||
return converter.toRest(xmlWorkflowFactory.getWorkflowByName(workflowName),
|
return converter.toRest(xmlWorkflowFactory.getWorkflowByName(workflowName), utils.obtainProjection());
|
||||||
utils.obtainProjection(true));
|
|
||||||
} catch (WorkflowConfigurationException e) {
|
} catch (WorkflowConfigurationException e) {
|
||||||
// Should never occur, since xmlWorkflowFactory.getWorkflowByName only throws a
|
// Should never occur, since xmlWorkflowFactory.getWorkflowByName only throws a
|
||||||
// WorkflowConfigurationException if no workflow by that name is configured (tested earlier)
|
// WorkflowConfigurationException if no workflow by that name is configured (tested earlier)
|
||||||
@@ -62,7 +61,7 @@ public class WorkflowDefinitionRestRepository extends DSpaceRestRepository<Workf
|
|||||||
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
||||||
public Page<WorkflowDefinitionRest> findAll(Context context, Pageable pageable) {
|
public Page<WorkflowDefinitionRest> findAll(Context context, Pageable pageable) {
|
||||||
List<Workflow> workflows = xmlWorkflowFactory.getAllConfiguredWorkflows();
|
List<Workflow> workflows = xmlWorkflowFactory.getAllConfiguredWorkflows();
|
||||||
return converter.toRestPage(utils.getPage(workflows, pageable), utils.obtainProjection(true));
|
return converter.toRestPage(utils.getPage(workflows, pageable), utils.obtainProjection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -35,7 +35,7 @@ public class WorkflowStepRestRepository extends DSpaceRestRepository<WorkflowSte
|
|||||||
public WorkflowStepRest findOne(Context context, String workflowStepName) {
|
public WorkflowStepRest findOne(Context context, String workflowStepName) {
|
||||||
Step step = this.xmlWorkflowFactory.getStepByName(workflowStepName);
|
Step step = this.xmlWorkflowFactory.getStepByName(workflowStepName);
|
||||||
if (step != null) {
|
if (step != null) {
|
||||||
return converter.toRest(step, utils.obtainProjection(true));
|
return converter.toRest(step, utils.obtainProjection());
|
||||||
} else {
|
} else {
|
||||||
throw new ResourceNotFoundException("No workflow step with name " + workflowStepName
|
throw new ResourceNotFoundException("No workflow step with name " + workflowStepName
|
||||||
+ " is configured");
|
+ " is configured");
|
||||||
|
@@ -239,7 +239,7 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
|
|||||||
//When we call this facets endpoint
|
//When we call this facets endpoint
|
||||||
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/search/findByCollection?uuid=" + nonValidUUID))
|
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/search/findByCollection?uuid=" + nonValidUUID))
|
||||||
//We expect a 422 Unprocessable Entity status
|
//We expect a 422 Unprocessable Entity status
|
||||||
.andExpect(status().is(422));
|
.andExpect(status().isUnprocessableEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -388,7 +388,8 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
|
|||||||
|
|
||||||
//When we call this facets endpoint
|
//When we call this facets endpoint
|
||||||
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + workflowName + "/collections"))
|
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + workflowName + "/collections"))
|
||||||
.andExpect(status().isInternalServerError());
|
//We expect a 404 Not Found
|
||||||
|
.andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -399,7 +400,8 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
|
|||||||
//When we call this facets endpoint
|
//When we call this facets endpoint
|
||||||
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
|
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
|
||||||
+ "/collections"))
|
+ "/collections"))
|
||||||
.andExpect(status().isInternalServerError());
|
//We expect a 403 Forbidden status
|
||||||
|
.andExpect(status().isForbidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -410,7 +412,8 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
|
|||||||
//When we call this facets endpoint
|
//When we call this facets endpoint
|
||||||
getClient().perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
|
getClient().perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
|
||||||
+ "/collections"))
|
+ "/collections"))
|
||||||
.andExpect(status().isInternalServerError());
|
//We expect a 401 Unauthorized
|
||||||
|
.andExpect(status().isUnauthorized());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -420,7 +423,8 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
|
|||||||
|
|
||||||
//When we call this facets endpoint
|
//When we call this facets endpoint
|
||||||
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
|
getClient(token).perform(get(WORKFLOW_DEFINITIONS_ENDPOINT + "/" + defaultWorkflow.getID()
|
||||||
+ "/steps"))
|
+ "/steps")
|
||||||
|
.param("projection", "full"))
|
||||||
//We expect a 200 OK status
|
//We expect a 200 OK status
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
//Number of total workflows is equals to number of non-mapped collections
|
//Number of total workflows is equals to number of non-mapped collections
|
||||||
|
@@ -75,7 +75,8 @@ public class WorkflowStepRestRepositoryIT extends AbstractControllerIntegrationT
|
|||||||
String nameStep = "reviewstep";
|
String nameStep = "reviewstep";
|
||||||
Step existentStep = xmlWorkflowFactory.getStepByName(nameStep);
|
Step existentStep = xmlWorkflowFactory.getStepByName(nameStep);
|
||||||
//When we call this facets endpoint
|
//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
|
//We expect a 200 is ok status
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
//Matches expected step
|
//Matches expected step
|
||||||
|
Reference in New Issue
Block a user