Commit 3d9b463e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

documentation for update map API call

parent b5485d6f
......@@ -19,6 +19,7 @@ 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.
......@@ -34,6 +35,23 @@ include::{snippets}/projects/project_maps/get_by_id/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_by_id/response-body.adoc[]
== Update map
Updates map data.
=== Path Parameters
include::{snippets}/projects/project_maps/update/path-parameters.adoc[]
=== Request Fields
include::{snippets}/projects/project_maps/update/request-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/update/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/update/response-body.adoc[]
== Get connections between maps
Returns list of connections between (sub)maps in a project.
......
......@@ -17,6 +17,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
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.MvcResult;
......@@ -201,23 +202,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
.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>")
)))
getMapDescription()))
.andReturn().getResponse().getContentAsString();
int mapId = new JsonParser()
......@@ -227,6 +212,29 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
assertEquals((int) map.getId(), mapId);
}
private ResponseFieldsSnippet getMapDescription() {
return 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>"));
}
@Test
public void testGetMapByIdWithUndefinedProject() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
......@@ -266,6 +274,46 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
responseFields(subsectionWithPath("[]").description("list of maps").type("Array<Map>"))));
}
@Test
public void testUpdateMapWithMissingContent() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
String content = "{}";
RequestBuilder request = patch("/projects/{projectId}/models/{mapId}", TEST_PROJECT, map.getId())
.session(session).content(content);
mockMvc.perform(request)
.andExpect(status().isBadRequest());
}
@Test
public void testUpdateMap() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
String content = "{\"model\":{\"defaultCenterX\":10, \"defaultCenterY\":20, \"defaultZoomLevel\":3}}";
RequestBuilder request = patch("/projects/{projectId}/models/{mapId}", TEST_PROJECT, map.getId())
.session(session)
.content(content);
mockMvc.perform(request)
.andExpect(status().is2xxSuccessful())
.andDo(document("projects/project_maps/update",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier")),
requestFields(
fieldWithPath("model.defaultCenterX").description("default x center used in frontend visualization")
.type("number"),
fieldWithPath("model.defaultCenterY").description("default y center used in frontend visualization")
.type("number"),
fieldWithPath("model.defaultZoomLevel").description("default zoom level used in frontend visualization")
.type("number")),
getMapDescription()));
}
@Test
public void testUpdateMapWithUndefinedProject() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
......
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