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

documentation for convert API call

parent 2a519253
......@@ -20,3 +20,15 @@ include::{snippets}/converter/list_formats/response-fields.adoc[]
include::{snippets}/converter/list_formats/response-body.adoc[]
=== Convert network from an input format to an output format
==== CURL sample
include::{snippets}/converter/format_conversion/curl-request.adoc[]
==== Path Parameters
include::{snippets}/converter/format_conversion/path-parameters.adoc[]
==== Response Fields
include::{snippets}/converter/format_conversion/response-fields.adoc[]
......@@ -2,15 +2,17 @@ package lcsb.mapviewer.web;
import static org.junit.Assert.assertEquals;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
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 java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
......@@ -123,4 +125,23 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest
.type("Array<String>"))));
}
@Test
public void convertCellDesignerToGpml() throws Exception {
File file = new File("src/test/resources/convert/cd-sample.xml");
String content = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
RequestBuilder request = post("/convert/{inputFormat}:{outputFormat}", "CellDesigner_SBML", "GPML")
.header("post-filename","input_file.xml")
.content(content.getBytes("UTF-8"))
.characterEncoding("UTF-8");
mockMvc.perform(request)
.andDo(document("converter/format_conversion",
pathParameters(
parameterWithName("inputFormat")
.description("input format (list of available formats be obtained from the /convert/ API)"),
parameterWithName("outputFormat")
.description("output format (list of available formats be obtained from the /convert/ API)"))))
.andExpect(status().is2xxSuccessful());
}
}
This diff is collapsed.
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