Commit 1b60d7be authored by Piotr Gawron's avatar Piotr Gawron
Browse files

doc for search miRNA API calls

parent 5e12e539
......@@ -226,7 +226,9 @@ public class BigFileCache {
localPath = entry.getLocalPath() + "/" + entry.getId() + "/";
File dirFile = new File(Configuration.getWebAppDir() + localPath);
if (!dirFile.mkdirs()) {
if (dirFile.exists() && dirFile.isDirectory()) {
logger.warn("Directory for the file already exists: " + dirFile.getAbsolutePath());
} else if (!dirFile.mkdirs()) {
throw new IOException("Cannot create directory: " + dirFile.getAbsolutePath());
}
......
= Rest API Documentation - Project micro RNAs
Piotr Gawron
v{project-version} {build-time}
:toc: left
:sectnums:
== Get miRNA
Returns miRNAs data with project related connections.
=== CURL sample
include::{snippets}/projects/project_mirna/search_by_query/curl-request.adoc[]
=== Path Parameters
include::{snippets}/projects/project_mirna/search_by_query/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_mirna/search_by_query/response-fields.adoc[]
=== Sample Response
include::{snippets}/projects/project_mirna/search_by_query/response-body.adoc[]
== Get suggested miRNA queries
Get list of suggested miRNA queries in the context of the project.
=== CURL sample
include::{snippets}/projects/project_mirna/suggested_query_list/curl-request.adoc[]
=== Path Parameters
include::{snippets}/projects/project_mirna/suggested_query_list/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_mirna/suggested_query_list/response-fields.adoc[]
=== Sample Response
include::{snippets}/projects/project_mirna/suggested_query_list/response-body.adoc[]
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.test.web.servlet.result.MockMvcResultMatchers.status;
import org.apache.logging.log4j.LogManager;
......@@ -8,8 +10,8 @@ import org.apache.logging.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpSession;
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;
......@@ -30,11 +32,15 @@ public class MiRnaControllerIntegrationTest extends ControllerIntegrationTest {
public void testSearchMiRnasInProjectUrl() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/" + BUILT_IN_PROJECT + "/miRnas:search")
RequestBuilder request = get("/projects/{projectId}/miRnas:search?query=hsa-miR-125a-3p", BUILT_IN_PROJECT)
.session(session);
mockMvc.perform(request)
.andExpect(status().is2xxSuccessful());
.andExpect(status().is2xxSuccessful())
.andDo(document("projects/project_mirna/search_by_query",
getProjectPathParameters(),
getChemicalFilter(),
listOfMiRnaFields()));
}
@Test
......@@ -63,11 +69,18 @@ public class MiRnaControllerIntegrationTest extends ControllerIntegrationTest {
public void testGetSuggestedList() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/" + BUILT_IN_PROJECT + "/miRnas/suggestedQueryList")
RequestBuilder request = get("/projects/{projectId}/miRnas/suggestedQueryList", BUILT_IN_PROJECT)
.session(session);
mockMvc.perform(request)
.andExpect(status().is2xxSuccessful());
.andDo(document("projects/project_mirna/suggested_query_list",
getProjectPathParameters(),
responseFields(
fieldWithPath("[]")
.description("list of suggested mirna queries")
.type("Array<String>"))))
.andExpect(status().is2xxSuccessful())
.andReturn().getResponse().getContentAsString();
}
@Test
......@@ -81,4 +94,29 @@ public class MiRnaControllerIntegrationTest extends ControllerIntegrationTest {
.andExpect(status().isNotFound());
}
private ResponseFieldsSnippet listOfMiRnaFields() {
return responseFields(
subsectionWithPath("[].id")
.description("identifier of the mirna")
.type("Object"),
fieldWithPath("[].name")
.description("name")
.type("string"),
fieldWithPath("[].targets")
.description("list of targets")
.type("Array<Target>"),
fieldWithPath("[].targets[].name")
.description("target name")
.type("string"),
subsectionWithPath("[].targets[].references")
.description("list of target references")
.type("Array<Reference>"),
subsectionWithPath("[].targets[].targetElements")
.description("list of elements on the map associated with this target")
.type("Array<Object>"),
subsectionWithPath("[].targets[].targetParticipants")
.description("list of identifiers associated with this target")
.type("Array<Object>"));
}
}
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