Commit 0eb60cbd authored by Piotr Gawron's avatar Piotr Gawron
Browse files

documentation for get data overlays API call

parent 0b5f46cc
......@@ -2,7 +2,12 @@ package lcsb.mapviewer.web;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
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.requestParameters;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
......@@ -17,6 +22,8 @@ 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.restdocs.request.RequestParametersSnippet;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.RequestBuilder;
......@@ -87,10 +94,14 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/" + TEST_PROJECT + "/overlays/?creator=" + TEST_CURATOR_LOGIN)
RequestBuilder request = get("/projects/{projectId}/overlays/?creator=" + TEST_CURATOR_LOGIN, TEST_PROJECT)
.session(session);
String response = mockMvc.perform(request)
.andDo(document("projects/project_overlays/get_all_by_creator",
getProjectPathParameters(),
getOverlayFilter(),
listOfOverlayFields()))
.andExpect(status().is2xxSuccessful())
.andReturn().getResponse().getContentAsString();
......@@ -185,10 +196,14 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
MockHttpSession session = createSession(TEST_CURATOR_LOGIN, TEST_CURATOR_PASSWORD);
RequestBuilder request = get("/projects/" + TEST_PROJECT + "/overlays/")
RequestBuilder request = get("/projects/{projectId}/overlays/", TEST_PROJECT)
.session(session);
String response = mockMvc.perform(request)
.andDo(document("projects/project_overlays/get_all",
getProjectPathParameters(),
getOverlayFilter(),
listOfOverlayFields()))
.andExpect(status().is2xxSuccessful())
.andReturn().getResponse().getContentAsString();
......@@ -1215,7 +1230,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
new BasicNameValuePair("googleLicenseConsent", "overlay name"),
new BasicNameValuePair("type", "GENERIC"))));
RequestBuilder request = post("/projects/"+TEST_PROJECT+"/overlays/")
RequestBuilder request = post("/projects/" + TEST_PROJECT + "/overlays/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body)
.session(session);
......@@ -1224,5 +1239,54 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
.andExpect(status().isForbidden());
}
protected RequestParametersSnippet getOverlayFilter() {
return requestParameters(
parameterWithName("creator")
.description("login of the user who created the overlay")
.optional(),
parameterWithName("publicOverlay")
.description(
"true/false - are we interested in public overlays or private custom data sets (default: false)")
.optional());
}
private ResponseFieldsSnippet listOfOverlayFields() {
return responseFields(
fieldWithPath("[].name")
.description("name")
.type("string"),
fieldWithPath("[].description")
.description("description")
.type("string"),
fieldWithPath("[].defaultOverlay")
.description("should the overlay be used as default (at most one per project should be marked with true)")
.type("boolean"),
fieldWithPath("[].idObject")
.description("identifier")
.type("number"),
fieldWithPath("[].inputDataAvailable")
.description("is the source data for the overlay available")
.type("string"),
fieldWithPath("[].publicOverlay")
.description("is the data overlay publicaly available to all users")
.type("boolean"),
fieldWithPath("[].googleLicenseConsent")
.description("did creator accepted license required by Google Maps API")
.type("boolean"),
fieldWithPath("[].images")
.description(
"in case the data overlay is a background data overlay this object contains map between submaps and folders where background images are stored")
.type("string"),
fieldWithPath("[].deprecatedColumns")
.description("list of columns in the input datasource that are deprecated and should be avoided")
.type("Array<String>"),
fieldWithPath("[].order")
.description("sort order")
.type("number"),
fieldWithPath("[].creator")
.description("login of the user who uploaded data overlay")
.type("string")
.optional());
}
}
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