Commit 449a72ce authored by Piotr Gawron's avatar Piotr Gawron
Browse files

documentation for get map by id API call

parent 6509933d
......@@ -79,7 +79,6 @@ public class ModelRestImpl extends BaseRestImpl {
return null;
} else {
Map<String, Object> result = new LinkedHashMap<>();
result.put("version", null);
result.put("name", submodel.getName());
result.put("idObject", submodel.getId());
result.put("tileSize", submodel.getTileSize());
......
......@@ -18,3 +18,18 @@ include::{snippets}/projects/project_maps/list/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/list/response-body.adoc[]
== Get by id
Returns map identified by id.
=== Path Parameters
include::{snippets}/projects/project_maps/get_by_id/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/get_by_id/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/get_by_id/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_by_id/response-body.adoc[]
......@@ -3,9 +3,11 @@ package lcsb.mapviewer.web;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.request.RequestDocumentation.*;
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;
......@@ -192,11 +194,30 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
public void testGetMapById() throws Exception {
userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId());
RequestBuilder request = get("/projects/" + TEST_PROJECT + "/models/" + map.getId())
.contentType(MediaType.APPLICATION_FORM_URLENCODED);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}", TEST_PROJECT, map.getId());
String response = mockMvc.perform(request)
.andExpect(status().is2xxSuccessful())
.andDo(document("projects/project_maps/get_by_id",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier")),
responseFields(fieldWithPath("name").description("name of the map").type("string"),
fieldWithPath("description").description("description").type("string"),
fieldWithPath("idObject").description("map id").type("number"),
fieldWithPath("width").description("map width").type("number"),
fieldWithPath("height").description("map height").type("number"),
fieldWithPath("tileSize").description("size of the png tile used to visualize in frontend").type("number"),
fieldWithPath("defaultCenterX").description("default x center used in frontend visualization").type("number"),
fieldWithPath("defaultCenterY").description("default y center used in frontend visualization").type("number"),
fieldWithPath("defaultZoomLevel").description("default zoom level used in frontend visualization").type("number"),
fieldWithPath("minZoom").description("minimum zoom level availbale for the map").type("number"),
fieldWithPath("maxZoom").description("maximum zoom level available for the map").type("number"),
fieldWithPath("submodelType").description("type of the submap").type("string"),
fieldWithPath("authors").description("list of authors").type("Array<Author>"),
fieldWithPath("references").description("list of references").type("Array<Reference>"),
fieldWithPath("creationDate").description("creation date").type("timestamp"),
fieldWithPath("modificationDates").description("modification dates").type("Array<timestamp>")
)))
.andReturn().getResponse().getContentAsString();
int mapId = new JsonParser()
......@@ -242,8 +263,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
.andExpect(status().is2xxSuccessful())
.andDo(document("projects/project_maps/list",
pathParameters(parameterWithName("projectId").description("project identifier")),
responseFields(subsectionWithPath("[]").description("list of maps").type("Array<Map>"))))
.andReturn().getResponse().getContentAsString();
responseFields(subsectionWithPath("[]").description("list of maps").type("Array<Map>"))));
}
@Test
......
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