Commit 7e1c15b1 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

documentation for update project API call

parent 6807150c
......@@ -42,8 +42,8 @@ include::{snippets}/projects/project_data/create_simple/path-parameters.adoc[]
=== Request Parameters
include::{snippets}/projects/project_data/create_simple/request-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_data/create_simple/response-fields.adoc[]
//=== Response Fields
//include::{snippets}/projects/project_data/create_simple/response-fields.adoc[]
=== Example 1.
Upload of project from simple file
......@@ -64,3 +64,21 @@ include::{snippets}/projects/project_data/create_zip/curl-request.adoc[]
include::{snippets}/projects/project_data/create_zip/response-body.adoc[]
== Update project
Updates project.
=== Path Parameters
include::{snippets}/projects/project_data/update/path-parameters.adoc[]
=== Request Fields
include::{snippets}/projects/project_data/update/request-fields.adoc[]
//=== Response Fields
//include::{snippets}/projects/project_data/update/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_data/update/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_data/update/response-body.adoc[]
......@@ -3,8 +3,7 @@ package lcsb.mapviewer.web;
import static org.junit.Assert.*;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
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;
......@@ -30,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.google.gson.JsonParser;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.graphics.MapCanvasType;
import lcsb.mapviewer.model.security.Privilege;
import lcsb.mapviewer.model.security.PrivilegeType;
import lcsb.mapviewer.model.user.User;
......@@ -201,14 +201,51 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
Project project = createProject(TEST_PROJECT);
String content = "{\"project\":{\"version\":\"xxx\"}}";
String content = "{\"project\":{"
+ "\"version\":\"xxx\", "
+ "\"name\": \"new name\", "
+ "\"notifyEmail\": \"notify@uni.lu\", "
+ "\"organism\": {\"type\": \"TAXONOMY\", \"resource\": \"9605\"}, "
+ "\"disease\": {\"type\": \"MESH_2012\", \"resource\": \"D010300\"}, "
+ "\"mapCanvasType\": \"OPEN_LAYERS\" "
+ "}}";
RequestBuilder request = patch("/projects/" + TEST_PROJECT + "/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
RequestBuilder request = patch("/projects/{projectId}/", TEST_PROJECT)
.content(content)
.session(session);
mockMvc.perform(request)
.andDo(document("projects/project_data/update",
pathParameters(parameterWithName("projectId").description("project identifier")),
requestFields(
fieldWithPath("project.version")
.description("version of the project")
.type("String")
.optional(),
fieldWithPath("project.name")
.description("name of the project")
.type("String")
.optional(),
fieldWithPath("project.notifyEmail")
.description("email address that should be when something change in the project")
.type("String")
.optional(),
subsectionWithPath("project.organism")
.description("organism associated with the project")
.type("MiriamAnnotation")
.optional(),
subsectionWithPath("project.disease")
.description("disease associated with the project")
.type("MiriamAnnotation")
.optional(),
fieldWithPath("project.mapCanvasType")
.description(
"type of map canvas engine to be used when visualizing map, for now there are only two options available: "
+ snippets.getOptionsAsString(MapCanvasType.class))
.type("String")
.optional()),
snippets.getProjectSnippet()))
.andExpect(status().is2xxSuccessful());
assertEquals("xxx", project.getVersion());
......
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