Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
3d9b463e
Commit
3d9b463e
authored
Feb 13, 2020
by
Piotr Gawron
Browse files
documentation for update map API call
parent
b5485d6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
web/src/main/asciidoc/projects/project_maps.adoc
View file @
3d9b463e
...
...
@@ -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.
...
...
web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java
View file @
3d9b463e
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment