Commit ff34db52 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

documentation for get publication list API call added

parent f7b8a6e5
......@@ -22,7 +22,6 @@ import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.graphics.PolylineDataComparator;
import lcsb.mapviewer.model.map.InconsistentModelException;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.*;
import lcsb.mapviewer.model.map.reaction.*;
......
......@@ -6,8 +6,6 @@ import java.util.Map;
import javax.servlet.ServletContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
......
......@@ -140,3 +140,21 @@ include::{snippets}/projects/project_data/get_project_statistics/curl-request.ad
=== Sample Response
include::{snippets}/projects/project_data/get_project_statistics/response-body.adoc[]
== Get publications
Gets publication list used in the project.
=== Path Parameters
include::{snippets}/projects/project_data/get_publications/path-parameters.adoc[]
=== Request Parameters
include::{snippets}/projects/project_data/get_project_logs/request-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_data/get_publications/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_data/get_publications/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_data/get_publications/response-body.adoc[]
......@@ -246,6 +246,7 @@ abstract public class ControllerIntegrationTest {
Reaction reaction = new TransportReaction("re1");
reaction.setZ(2);
reaction.setLine(new PolylineData(new Point2D.Double(0, 0), new Point2D.Double(10, 0)));
reaction.addMiriamData(new MiriamData(MiriamType.PUBMED, "28725475"));
map.addReaction(reaction);
Element element = new GenericProtein("p1");
element.setWidth(100.0);
......
......@@ -153,13 +153,13 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
mockMvc.perform(request)
.andDo(document("projects/project_data/get_project_logs",
requestParameters(
parameterWithName("start").description("number of first entry in this response"),
parameterWithName("start").description("number of first entry in this response").optional(),
parameterWithName("sortColumn")
.description("log entry column that should be used for sorting (default: id)"),
parameterWithName("sortOrder").description("log entry sort order (asc, desc)"),
parameterWithName("level").description("level of log entry (warning, error)"),
parameterWithName("length").description("number of log entres we want to obtain"),
parameterWithName("search").description("search query used for filtering")),
.description("log entry column that should be used for sorting (default: id)").optional(),
parameterWithName("sortOrder").description("log entry sort order (asc, desc)").optional(),
parameterWithName("level").description("level of log entry (warning, error)").optional(),
parameterWithName("length").description("number of log entres we want to obtain").optional(),
parameterWithName("search").description("search query used for filtering").optional()),
pathParameters(parameterWithName("projectId").description("project identifier")),
responseFields(
subsectionWithPath("data")
......
package lcsb.mapviewer.web;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.request.RequestDocumentation.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.apache.logging.log4j.LogManager;
......@@ -8,36 +11,28 @@ import org.apache.logging.log4j.Logger;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.transaction.annotation.Transactional;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.security.PrivilegeType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.services.interfaces.IUserService;
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@Rollback
public class PublicationsControllerIntegrationTest extends ControllerIntegrationTest {
Logger logger = LogManager.getLogger();
private static final String TEST_PROJECT = "test_project";
@Autowired
private IUserService userService;
Logger logger = LogManager.getLogger();
@Autowired
private ProjectDao projectDao;
private User anonymous;
private Project project;
private ModelData map;
......@@ -45,7 +40,6 @@ public class PublicationsControllerIntegrationTest extends ControllerIntegration
public void setup() {
project = projectDao.getProjectByProjectId(BUILT_IN_PROJECT);
map = project.getModels().iterator().next();
anonymous = userService.getUserByLogin(Configuration.ANONYMOUS_LOGIN);
}
@After
......@@ -54,12 +48,41 @@ public class PublicationsControllerIntegrationTest extends ControllerIntegration
@Test
public void testGetPublicationsForMap() throws Exception {
userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, BUILT_IN_PROJECT);
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
project = createProject(TEST_PROJECT);
map = project.getModels().iterator().next();
RequestBuilder request = get("/projects/" + BUILT_IN_PROJECT + "/models/" + map.getId() + "/publications/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/publications/", TEST_PROJECT, map.getId())
.session(session);
mockMvc.perform(request)
.andDo(document("projects/project_data/get_publications",
requestParameters(
parameterWithName("start").description("number of first entry in this response").optional(),
parameterWithName("sortColumn")
.description("entry column that should be used for sorting (default: pubmedId)").optional(),
parameterWithName("sortOrder").description("entry sort order (asc, desc)").optional(),
parameterWithName("length").description("number of entres we want to obtain").optional(),
parameterWithName("search").description("search query used for filtering").optional()),
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("submap identifier (use '*' to indicate all maps)")),
responseFields(
subsectionWithPath("data")
.description("list of publications")
.type("Array<Article>"),
fieldWithPath("filteredSize")
.description("number of entries that match filter criteria")
.type("number"),
fieldWithPath("length")
.description("number of entries in this response")
.type("number"),
fieldWithPath("start")
.description("number of first entry in this response")
.type("number"),
fieldWithPath("totalSize")
.description("number of all log entries")
.type("number"))))
.andExpect(status().is2xxSuccessful());
}
......@@ -69,7 +92,6 @@ public class PublicationsControllerIntegrationTest extends ControllerIntegration
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/*/models/" + map.getId() + "/publications/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment