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

documentation for taxonomy API call

parent ef729f1b
= Rest API Documentation - Taxonomy
Piotr Gawron
v{project-version} {build-time}
:toc: left
:sectnums:
== Get information about taxonomy
=== CURL sample
include::{snippets}/taxonomy/get_taxonomy/curl-request.adoc[]
=== Path Parameters
include::{snippets}/taxonomy/get_taxonomy/path-parameters.adoc[]
=== Response Fields
include::{snippets}/taxonomy/get_taxonomy/response-fields.adoc[]
=== Sample Response
include::{snippets}/taxonomy/get_taxonomy/response-body.adoc[]
......@@ -140,7 +140,7 @@ abstract public class ControllerIntegrationTest {
.operationPreprocessors()
.withResponseDefaults(Preprocessors.prettyPrint())
.and()
.uris().withHost("minerva-dev.lcsb.uni.lu").withPort(80)
.uris().withHost("minerva-service.lcsb.uni.lu/minerva/api").withPort(443).withScheme("https")
.and().snippets().withDefaults(
CliDocumentation.curlRequest(new CommandFormatterWithReplacingPostFilenameHeader(" \\%n ")),
CliDocumentation.httpieRequest(),
......
package lcsb.mapviewer.web;
import static org.junit.Assert.assertTrue;
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.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.http.MediaType;
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 com.google.gson.JsonParser;
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@Rollback
......@@ -32,19 +33,21 @@ public class TaxonomiesControllerIntegrationTest extends ControllerIntegrationTe
}
@Test
public void testGetTaxonomies() throws Exception {
RequestBuilder request = get("/genomics/taxonomies/").contentType(MediaType.APPLICATION_FORM_URLENCODED);
String response = mockMvc.perform(request)
.andExpect(status().is2xxSuccessful())
.andReturn().getResponse().getContentAsString();
int taxonomies = new JsonParser()
.parse(response)
.getAsJsonArray().size();
assertTrue("list of taxonomies shouldn't be empty", taxonomies > 0);
public void testGetTaxonomy() throws Exception {
RequestBuilder request = get("/taxonomy/{taxonomyId}/", "9606");
mockMvc.perform(request)
.andDo(document("taxonomy/get_taxonomy",
pathParameters(parameterWithName("taxonomyId").description("mesh id")),
responseFields(
fieldWithPath("name")
.description("name")
.type("String"),
fieldWithPath("id")
.description("mesh id")
.type("String"))))
.andExpect(status().is2xxSuccessful());
}
}
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