Commit 4d6a314a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

documentation for sbml kinetic related API calls

parent b3545b43
......@@ -168,6 +168,7 @@ include::{snippets}/projects/project_maps/search_by_query/response-body.adoc[]
=== CURL sample 2
include::{snippets}/projects/project_maps/search_by_coordinates/curl-request.adoc[]
== Get list of suggested search queries
=== Path Parameters
......@@ -181,3 +182,100 @@ include::{snippets}/projects/project_maps/suggested_query_list/curl-request.adoc
=== Sample Response
include::{snippets}/projects/project_maps/suggested_query_list/response-body.adoc[]
== Kinetic functions
Get list of kinetic functions.
=== Path Parameters
include::{snippets}/projects/project_maps/get_functions/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/get_functions/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/get_functions/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_functions/response-body.adoc[]
== Kinetic function
Get information about specific kinetic function.
=== Path Parameters
include::{snippets}/projects/project_maps/get_function/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/get_function/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/get_function/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_function/response-body.adoc[]
== Kinetic parameters
Get list of kinetic parameters.
=== Path Parameters
include::{snippets}/projects/project_maps/get_parameters/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/get_parameters/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/get_parameters/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_parameters/response-body.adoc[]
== Kinetic parameter
Get information about specific kinetic parameter.
=== Path Parameters
include::{snippets}/projects/project_maps/get_parameter/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/get_parameter/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/get_parameter/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_parameter/response-body.adoc[]
== Get units
Get list of units.
=== Path Parameters
include::{snippets}/projects/project_maps/get_units/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/get_units/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/get_units/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_units/response-body.adoc[]
== Get unit
Get information about specific unit.
=== Path Parameters
include::{snippets}/projects/project_maps/get_unit/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/get_unit/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/get_unit/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_unit/response-body.adoc[]
......@@ -39,6 +39,7 @@ import lcsb.mapviewer.model.*;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.kinetics.*;
import lcsb.mapviewer.model.map.layout.ColorSchemaType;
import lcsb.mapviewer.model.map.layout.Layout;
import lcsb.mapviewer.model.map.model.ModelData;
......@@ -232,7 +233,8 @@ abstract public class ControllerIntegrationTest {
entry.setContent("This is warning message");
project.addLogEntry(entry);
try {
project.setInputData(createFile(Files.readAllBytes(Paths.get("./src/test/resources/generic.xml")), userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN)));
project.setInputData(createFile(Files.readAllBytes(Paths.get("./src/test/resources/generic.xml")),
userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN)));
} catch (IOException e) {
e.printStackTrace();
}
......@@ -242,6 +244,19 @@ abstract public class ControllerIntegrationTest {
map.setTileSize(256);
map.setWidth(100);
map.setHeight(100);
SbmlFunction sbmlFunction = new SbmlFunction("f1");
sbmlFunction.setName("name");
sbmlFunction.setDefinition("test");
map.addFunction(sbmlFunction);
SbmlParameter sbmlParameter = new SbmlParameter("param1");
sbmlParameter.setName("ppp");
sbmlParameter.setValue(1.2);
map.addParameter(sbmlParameter);
SbmlUnit sbmlUnit = new SbmlUnit("u1");
sbmlUnit.setName("uuu");
map.addUnit(sbmlUnit);
Reaction reaction = new TransportReaction("re1");
reaction.setZ(2);
......
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.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.http.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.ResponseFieldsSnippet;
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.model.Project;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.services.interfaces.IModelService;
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@Rollback
public class FunctionControllerIntegrationTest extends ControllerIntegrationTest {
private static final String TEST_PROJECT = "test_project";
Project project;
ModelData map;
@Autowired
private IModelService modelService;
@Before
public void setup() {
project = createProject(TEST_PROJECT);
map = project.getModels().iterator().next();
}
@After
public void tearDown() {
modelService.removeModelFromCache(map);
}
@Test
public void testGetFunctionListWithUndefinedProject() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/*/models/*/functions/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetFunctionWithUndefinedProject() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/*/models/*/functions/1")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetFunctions() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/functions/", TEST_PROJECT, "*")
.session(session);
mockMvc.perform(request)
.andDo(document("projects/project_maps/get_functions",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier")),
listOfFunctionFields()))
.andExpect(status().is2xxSuccessful());
}
@Test
public void testGetFunction() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/functions/{functionId}", TEST_PROJECT, "*",
map.getFunctions().iterator().next().getId())
.session(session);
mockMvc.perform(request)
.andDo(document("projects/project_maps/get_function",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier"),
parameterWithName("functionId").description("function identifier")),
responseFields(functionFields())))
.andExpect(status().is2xxSuccessful());
}
private List<FieldDescriptor> functionFields() {
return Arrays.asList(
fieldWithPath("id")
.description("unique function identifier")
.type("number"),
fieldWithPath("name")
.description("name")
.type("string"),
fieldWithPath("definition")
.description("definition")
.type("string"),
fieldWithPath("functionId")
.description("function identifier taken from source file")
.type("string"),
fieldWithPath("arguments")
.description("list of function parameters")
.type("Array<Object>"));
}
private ResponseFieldsSnippet listOfFunctionFields() {
return responseFields(
fieldWithPath("[]").description("list of functions"))
.andWithPrefix("[].", functionFields());
}
}
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.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.http.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.ResponseFieldsSnippet;
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.model.Project;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.services.interfaces.IModelService;
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@Rollback
public class ParameterControllerIntegrationTest extends ControllerIntegrationTest {
private static final String TEST_PROJECT = "test_project";
Project project;
ModelData map;
@Autowired
private IModelService modelService;
@Before
public void setup() {
project = createProject(TEST_PROJECT);
map = project.getModels().iterator().next();
}
@After
public void tearDown() {
modelService.removeModelFromCache(map);
}
@Test
public void testGetParameterListWithUndefinedProject() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/*/models/*/parameters/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetParameterWithUndefinedProject() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/*/models/*/parameters/1")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetParameters() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/parameters/", TEST_PROJECT, "*")
.session(session);
mockMvc.perform(request)
.andDo(document("projects/project_maps/get_parameters",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier")),
listOfParameterFields()))
.andExpect(status().is2xxSuccessful());
}
@Test
public void testGetParameter() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/parameters/{parameterId}", TEST_PROJECT, "*",
map.getParameters().iterator().next().getId())
.session(session);
mockMvc.perform(request)
.andDo(document("projects/project_maps/get_parameter",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier"),
parameterWithName("parameterId").description("parameter identifier")),
responseFields(parameterFields())))
.andExpect(status().is2xxSuccessful());
}
private List<FieldDescriptor> parameterFields() {
return Arrays.asList(
fieldWithPath("id")
.description("unique parameter identifier")
.type("number"),
fieldWithPath("name")
.description("name")
.type("string"),
fieldWithPath("value")
.description("value")
.type("number"),
fieldWithPath("unitsId")
.description("unit identifier")
.type("number"),
fieldWithPath("global")
.description("is parameter global")
.type("boolean"),
fieldWithPath("parameterId")
.description("parameter identifier taken from source file")
.type("string"));
}
private ResponseFieldsSnippet listOfParameterFields() {
return responseFields(
fieldWithPath("[]").description("list of parameters"))
.andWithPrefix("[].", parameterFields());
}
}
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.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.http.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.ResponseFieldsSnippet;
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.model.Project;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.services.interfaces.IModelService;
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@Rollback
public class UnitsControllerIntegrationTest extends ControllerIntegrationTest {
private static final String TEST_PROJECT = "test_project";
Project project;
ModelData map;
@Autowired
private IModelService modelService;
@Before
public void setup() {
project = createProject(TEST_PROJECT);
map = project.getModels().iterator().next();
}
@After
public void tearDown() {
modelService.removeModelFromCache(map);
}
@Test
public void testGetUnitListWithUndefinedProject() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/*/models/*/units/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetUnitWithUndefinedProject() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/*/models/*/units/1")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetUnits() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/units/", TEST_PROJECT, "*")
.session(session);
mockMvc.perform(request)
.andDo(document("projects/project_maps/get_units",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier")),
listOfUnitsFields()))
.andExpect(status().is2xxSuccessful());
}
@Test
public void testGetUnit() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/units/{unitId}", TEST_PROJECT, "*",
map.getUnits().iterator().next().getId())
.session(session);
mockMvc.perform(request)
.andDo(document("projects/project_maps/get_unit",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier"),
parameterWithName("unitId").description("unit identifier")),
responseFields(unitFields())))
.andExpect(status().is2xxSuccessful());
}
private List<FieldDescriptor> unitFields() {
return Arrays.asList(
fieldWithPath("id")
.description("unique unit identifier")
.type("number"),
fieldWithPath("name")
.description("name")
.type("string"),
subsectionWithPath("unitTypeFactors")
.description("in complex unit this define how specific unit types are associated")
.type("Array<Object>"),
fieldWithPath("unitId")
.description("unit identifier taken from source file")
.type("string"));
}
private ResponseFieldsSnippet listOfUnitsFields() {
return responseFields(
fieldWithPath("[]").description("list of units"))
.andWithPrefix("[].", unitFields());
}
}
Markdown is supported
0% or