diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9ef5896ca98fbc9c4af419abaf623dd727eb9423..f3190afa4fc2bcab9b4c67b09c1e55e73f2c4bd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -400,7 +400,7 @@ build_jar: - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs - mvn clean compile install -DskipTests=true - echo "logger.minerva.level = info" >> web/src/test/resources/log4j2.properties - - mvn install -pl web + - mvn install -pl web -Dtest="*Test#testDocs*" - cp web/target/*exec.jar minerva.jar test:dependency_conflict: diff --git a/model/src/main/java/lcsb/mapviewer/model/plugin/Plugin.java b/model/src/main/java/lcsb/mapviewer/model/plugin/Plugin.java index e5c0336ed10ea7082864d593990aabac769ed244..a7854a0958b4018a502d410ddcf22d183510bc51 100644 --- a/model/src/main/java/lcsb/mapviewer/model/plugin/Plugin.java +++ b/model/src/main/java/lcsb/mapviewer/model/plugin/Plugin.java @@ -12,6 +12,7 @@ import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -76,7 +77,7 @@ public class Plugin implements MinervaEntity { /** * List of urls from which plugin can be downloaded. */ - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) @CollectionTable(name = "plugin_urls", joinColumns = @JoinColumn(name = "plugin_id")) @Column(name = "url") @OrderBy("idx") diff --git a/persist/src/main/java/lcsb/mapviewer/persist/dao/plugin/PluginDao.java b/persist/src/main/java/lcsb/mapviewer/persist/dao/plugin/PluginDao.java index 0369e9f960c7d9c62229b358de6dc7ca0a6d9d7e..4d147a64e5ba9370e83f3ea5e119a61a6c6b3f8c 100644 --- a/persist/src/main/java/lcsb/mapviewer/persist/dao/plugin/PluginDao.java +++ b/persist/src/main/java/lcsb/mapviewer/persist/dao/plugin/PluginDao.java @@ -37,6 +37,9 @@ public class PluginDao extends BaseDao<Plugin, PluginProperty> { if (key.equals(PluginProperty.DEFAULT_VALUE)) { final Predicate predicate = builder.and(root.get("isDefault").in(filterOptions.get(key))); predicates.add(predicate); + } else if (key.equals(PluginProperty.PUBLIC_VALUE)) { + final Predicate predicate = builder.and(root.get("isPublic").in(filterOptions.get(key))); + predicates.add(predicate); } else { throw new InvalidArgumentException("Unknown property: " + key); } diff --git a/persist/src/main/java/lcsb/mapviewer/persist/dao/plugin/PluginProperty.java b/persist/src/main/java/lcsb/mapviewer/persist/dao/plugin/PluginProperty.java index 79b1ba0c9d544774d50d40003259f446092dec8e..84a1ab28c9c1c757c693832b3c3dd2b6d74b1294 100644 --- a/persist/src/main/java/lcsb/mapviewer/persist/dao/plugin/PluginProperty.java +++ b/persist/src/main/java/lcsb/mapviewer/persist/dao/plugin/PluginProperty.java @@ -5,4 +5,5 @@ import lcsb.mapviewer.persist.dao.MinervaEntityProperty; public enum PluginProperty implements MinervaEntityProperty<Plugin> { DEFAULT_VALUE, + PUBLIC_VALUE, } diff --git a/web/src/main/asciidoc/converter.adoc b/web/src/main/asciidoc/converter.adoc index 0c357e2f0e46f87bfe70aee2a8b06ab4097d8608..dadf64aa48e1ff4ef9e0d5822c51fef0563ac1b3 100644 --- a/web/src/main/asciidoc/converter.adoc +++ b/web/src/main/asciidoc/converter.adoc @@ -6,60 +6,80 @@ v{project-version} {build-time} Conversion API provides access to MINERVA’s ability convert between different systems biology network formats and to export of layouts to different graphical formats. - == Conversion to systems biology formats === List available formats + ==== CURL sample + include::{snippets}/converter/list_formats/curl-request.adoc[] ==== Response Fields + include::{snippets}/converter/list_formats/response-fields.adoc[] ==== Sample Response -include::{snippets}/converter/list_formats/response-body.adoc[] +include::{snippets}/converter/list_formats/response-body.adoc[] === Convert network from an input format to an output format + ==== CURL sample + include::{snippets}/converter/format_conversion/curl-request.adoc[] ==== Path Parameters + include::{snippets}/converter/format_conversion/path-parameters.adoc[] == Convert network from an input format to an output image === List available formats + ==== CURL sample + include::{snippets}/converter/list_image_formats/curl-request.adoc[] ==== Response Fields + include::{snippets}/converter/list_image_formats/response-fields.adoc[] ==== Sample Response -include::{snippets}/converter/list_image_formats/response-body.adoc[] +include::{snippets}/converter/list_image_formats/response-body.adoc[] === Convert network from an input format to an output image + ==== CURL sample + include::{snippets}/converter/image_conversion/curl-request.adoc[] ==== Path Parameters + include::{snippets}/converter/image_conversion/path-parameters.adoc[] == Merging of maps === Merge -This API call allows to merge few files into one. Layout of merged map files will be a simple matrix. By default all notes are removed from maps (it's impossible to merge them properly in formats like SBML/CellDesigner because there is one Species with the notes and alias to it in the whole diagram). Minerva can be asked to keep the notes by providing custom header "X-MINERVA-KEEP-NOTES: true", but the notes in output files might not be properly defined. + +This API call allows to merge few files into one. +Layout of merged map files will be a simple matrix. +By default, all notes are removed from maps (it's impossible to merge them properly in formats like SBML/CellDesigner because there is one Species with the notes and alias to it in the whole diagram). +Minerva can be asked to keep the notes by providing custom header "X-MINERVA-KEEP-NOTES: true", but the notes in output files might not be properly defined. ==== CURL sample + include::{snippets}/converter/merge_maps/curl-request.adoc[] ==== CURL sample 2 + include::{snippets}/converter/merge_maps_keep_notes/curl-request.adoc[] ==== Path Parameters + include::{snippets}/converter/merge_maps/path-parameters.adoc[] ==== Input file structure -Input file should be a zip file with single zip folder called "maps". All map files to merge should be located in this folder. + +Input file should be a zip file with single zip folder called "maps". +All map files to merge should be located in this folder. diff --git a/web/src/main/asciidoc/index.adoc b/web/src/main/asciidoc/index.adoc index d238420c938968fd2fa4dc8318212b048334e556..7faa4973747678316179274ef9273760c63f2cde 100644 --- a/web/src/main/asciidoc/index.adoc +++ b/web/src/main/asciidoc/index.adoc @@ -7,57 +7,71 @@ v{project-version} {build-time} == Introduction -Rest API is located in /api/ path of the deployed application. For instance, Rest API of pdmap project that can be browsed using https://pdmap.uni.lu/minerva/ will be located here: https://pdmap.uni.lu/minerva/api/ +Rest API is located in /api/ path of the deployed application. +For instance, Rest API of Parkinson's Disease Map project that can be browsed using https://pdmap.uni.lu/minerva/ will be located here: https://pdmap.uni.lu/minerva/api/ Rest API tries to follow link:https://cloud.google.com/apis/design/[API Design Guide] by Google. For API calls that require authentication MINERVA_AUTH_TOKEN obtained during login process must be included. - == QuickStart guide + Here is sample example that shows information about all projects accessible by guest account (anonymous user): include::{snippets}/projects/project_data/list_guest/curl-request.adoc[] -If we are interested in the API calls that require more privileges than anonymous user we need to login first: +If we are interested in the API calls that require more privileges than anonymous user we need to log in first: include::{snippets}/authentication/login/curl-request.adoc[] include::{snippets}/authentication/login/response-body.adoc[] -The response creates an authentication token and puts it into a cookie MINERVA_AUTH_TOKEN=xxxxxxxx. When using console curl command this cookie must be attached to every query that follows. When we have authentication token we can access information about specific user on the server: +The response creates an authentication token and puts it into a cookie MINERVA_AUTH_TOKEN=xxxxxxxx. +When using console curl command this cookie must be attached to every query that follows. +When we have authentication token we can access information about specific user on the server: include::{snippets}/user/get_user/curl-request.adoc[] == Categories === <<authentication.adoc#,Authentication>> + === <<configuration.adoc#,Configuration>> + Methods allowing to obtain configuration information from server and updating it with proper privileges === <<converter.adoc#,Converter>> + Conversion API provides access to MINERVA’s ability to convert between different systems biology network formats and to export of layouts to different graphical formats === <<file.adoc#,Files>> + Methods that allow to upload files into the system === <<genomics.adoc#,Genomics>> + Methods allowing to access genome data === <<license.adoc#,License>> + Methods allowing to access information about available licenses === <<mesh.adoc#,Mesh>> + Methods allowing to access info about mesh data === <<plugin.adoc#,Plugins>> + Methods allowing to store some data for plugin infrastructure === <<project.adoc#,Project>> + Set of methods allowing to obtain information about projects and allowing to create new project and modifying existing ones === <<taxonomy.adoc#,Taxonomy>> + Methods allowing to access info about taxonomy data === <<user.adoc#,Users>> + Set of methods allowing to obtain and manage users and their access control diff --git a/web/src/main/asciidoc/new_api/new_api.adoc b/web/src/main/asciidoc/new_api/new_api.adoc index e8b9c7da4e680a0c56c4b2485a971b29451f1e0b..e2bed6f0f4d601d56576012da897a86763cde4fe 100644 --- a/web/src/main/asciidoc/new_api/new_api.adoc +++ b/web/src/main/asciidoc/new_api/new_api.adoc @@ -6,152 +6,15 @@ v{project-version} {build-time} == Introduction -Here will be a list of endpoints in the new format. This is a development unstable version and might change. At some point the whole API will be rewritten. -== Search for bio entities -Returns list of bio entities matching the query. +Here will be a list of endpoints in the new format. +This is a development unstable version and might change. +At some point the whole API will be rewritten. -=== Path Parameters -include::{snippets}/new_api/projects/maps/bioEntites/search/path-parameters.adoc[] +== Categories -=== Request Parameters -include::{snippets}/new_api/projects/maps/bioEntites/search/request-parameters.adoc[] +=== <<new_api_project.adoc#,Project>> -=== Response Fields -include::{snippets}/new_api/projects/maps/bioEntites/search/response-fields.adoc[] +=== <<new_api_user.adoc#,Users>> -=== CURL sample -include::{snippets}/new_api/projects/maps/bioEntites/search/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/maps/bioEntites/search/response-body.adoc[] - -== Get element by id -Returns list of bio entities matching the query. - -=== Path Parameters -include::{snippets}/new_api/projects/maps/bioEntites/elements/get_by_id/path-parameters.adoc[] - -=== Response Fields -include::{snippets}/new_api/projects/maps/bioEntites/elements/get_by_id/response-fields.adoc[] - -=== CURL sample -include::{snippets}/new_api/projects/maps/bioEntites/elements/get_by_id/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/maps/bioEntites/elements/get_by_id/response-body.adoc[] - -== Download element list as csv file -Returns csv file with list of elements. - -=== Path Parameters -include::{snippets}/new_api/projects/maps/bioEntites/elements/export_to_csv/path-parameters.adoc[] - -=== Request Fields -include::{snippets}/new_api/projects/maps/bioEntites/elements/export_to_csv/request-fields.adoc[] - -=== CURL sample -include::{snippets}/new_api/projects/maps/bioEntites/elements/export_to_csv/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/maps/bioEntites/elements/export_to_csv/response-body.adoc[] - - - -== Get reaction by id -Returns list of bio entities matching the query. - -=== Path Parameters -include::{snippets}/new_api/projects/maps/bioEntites/reactions/get_by_id/path-parameters.adoc[] - -=== Response Fields -include::{snippets}/new_api/projects/maps/bioEntites/reactions/get_by_id/response-fields.adoc[] - -=== CURL sample -include::{snippets}/new_api/projects/maps/bioEntites/reactions/get_by_id/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/maps/bioEntites/reactions/get_by_id/response-body.adoc[] - -== Download reaction list as csv file -Returns csv file with list of reactions. - -=== Path Parameters -include::{snippets}/new_api/projects/maps/bioEntites/reactions/export_to_csv/path-parameters.adoc[] - -=== Request Fields -include::{snippets}/new_api/projects/maps/bioEntites/reactions/export_to_csv/request-fields.adoc[] - -=== CURL sample -include::{snippets}/new_api/projects/maps/bioEntites/reactions/export_to_csv/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/maps/bioEntites/reactions/export_to_csv/response-body.adoc[] - - - -== Chemical search -Search chemical database. - -=== Path Parameters -include::{snippets}/new_api/projects/project_chemicals/search_by_query/path-parameters.adoc[] - -=== Request Parameters -include::{snippets}/new_api/projects/project_chemicals/search_by_query/request-parameters.adoc[] - -=== Response Fields -include::{snippets}/new_api/projects/project_chemicals/search_by_query/response-fields.adoc[] - -=== CURL sample -include::{snippets}/new_api/projects/project_chemicals/search_by_query/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/project_chemicals/search_by_query/response-body.adoc[] - -== Drug search -Search drug database. - -=== Path Parameters -include::{snippets}/new_api/projects/project_drugs/search_by_query/path-parameters.adoc[] - -=== Request Parameters -include::{snippets}/new_api/projects/project_drugs/search_by_query/request-parameters.adoc[] - -=== Response Fields -include::{snippets}/new_api/projects/project_drugs/search_by_query/response-fields.adoc[] - -=== CURL sample -include::{snippets}/new_api/projects/project_drugs/search_by_query/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/project_drugs/search_by_query/response-body.adoc[] - -== Get list of associated bioEntities in the overlay -Returns list of bioEntities that match entries in the overlay. - -=== Path Parameters -include::{snippets}/new_api/projects/overlays/get_bioEntities/path-parameters.adoc[] - -=== Response Fields -include::{snippets}/new_api/projects/overlays/get_bioEntities/response-fields.adoc[] - -=== CURL sample -include::{snippets}/new_api/projects/overlays/get_bioEntities/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/overlays/get_bioEntities/response-body.adoc[] - -== Get project -Returns info about project. - -=== Path Parameters -include::{snippets}/new_api/projects/get_by_project_id/path-parameters.adoc[] - -=== Response Fields -include::{snippets}/new_api/projects/get_by_project_id/response-fields.adoc[] - -=== CURL sample -include::{snippets}/new_api/projects/get_by_project_id/curl-request.adoc[] - -=== Sample Response -include::{snippets}/new_api/projects/get_by_project_id/response-body.adoc[] +=== <<new_api_plugin.adoc#,Plugins>> diff --git a/web/src/main/asciidoc/new_api/plugins/new_api_plugin.adoc b/web/src/main/asciidoc/new_api/plugins/new_api_plugin.adoc new file mode 100644 index 0000000000000000000000000000000000000000..b09f837b2b5dc6450b36e7befafd9e0c44fe39e5 --- /dev/null +++ b/web/src/main/asciidoc/new_api/plugins/new_api_plugin.adoc @@ -0,0 +1,60 @@ += Rest New API Documentation - Plugin +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + + +== List registered plugins on the server + +=== CURL sample + +include::{snippets}/new_api/plugins/list_plugins/curl-request.adoc[] + +=== Response Fields + +include::{snippets}/new_api/plugins/list_plugins/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/plugins/list_plugins/response-body.adoc[] + +== Register new plugin on the server + +=== CURL sample + +include::{snippets}/new_api/plugins/create_plugin/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/plugins/create_plugin/path-parameters.adoc[] + +=== Request Fields + +include::{snippets}/new_api/plugins/create_plugin/request-fields.adoc[] + +=== Response Fields + +include::{snippets}/new_api/plugins/create_plugin/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/plugins/create_plugin/response-body.adoc[] + +== Access information about plugin + +=== CURL sample + +include::{snippets}/new_api/plugins/get_by_hash/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/plugins/get_by_hash/path-parameters.adoc[] + +=== Response Fields + +include::{snippets}/new_api/plugins/get_by_hash/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/plugins/get_by_hash/response-body.adoc[] \ No newline at end of file diff --git a/web/src/main/asciidoc/new_api/projects/chemicals/new_api_chemicals.adoc b/web/src/main/asciidoc/new_api/projects/chemicals/new_api_chemicals.adoc new file mode 100644 index 0000000000000000000000000000000000000000..7ab0126d22f94e7d2fdb00225224c6a17b241cba --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/chemicals/new_api_chemicals.adoc @@ -0,0 +1,24 @@ += Rest New API Documentation +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + + +== Chemical search +Search chemical database. + +=== Path Parameters +include::{snippets}/new_api/projects/project_chemicals/search_by_query/path-parameters.adoc[] + +=== Request Parameters +include::{snippets}/new_api/projects/project_chemicals/search_by_query/request-parameters.adoc[] + +=== Response Fields +include::{snippets}/new_api/projects/project_chemicals/search_by_query/response-fields.adoc[] + +=== CURL sample +include::{snippets}/new_api/projects/project_chemicals/search_by_query/curl-request.adoc[] + +=== Sample Response +include::{snippets}/new_api/projects/project_chemicals/search_by_query/response-body.adoc[] diff --git a/web/src/main/asciidoc/new_api/projects/drugs/new_api_drugs.adoc b/web/src/main/asciidoc/new_api/projects/drugs/new_api_drugs.adoc new file mode 100644 index 0000000000000000000000000000000000000000..337d3bdc2612ad43424668503a0de9bca1cae445 --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/drugs/new_api_drugs.adoc @@ -0,0 +1,23 @@ += Rest New API Documentation +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + +== Drug search +Search drug database. + +=== Path Parameters +include::{snippets}/new_api/projects/project_drugs/search_by_query/path-parameters.adoc[] + +=== Request Parameters +include::{snippets}/new_api/projects/project_drugs/search_by_query/request-parameters.adoc[] + +=== Response Fields +include::{snippets}/new_api/projects/project_drugs/search_by_query/response-fields.adoc[] + +=== CURL sample +include::{snippets}/new_api/projects/project_drugs/search_by_query/curl-request.adoc[] + +=== Sample Response +include::{snippets}/new_api/projects/project_drugs/search_by_query/response-body.adoc[] diff --git a/web/src/main/asciidoc/new_api/projects/maps/bioEntities/elements/new_api_elements.adoc b/web/src/main/asciidoc/new_api/projects/maps/bioEntities/elements/new_api_elements.adoc new file mode 100644 index 0000000000000000000000000000000000000000..873ab1212235b28afefbb624854dc948f73e3592 --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/maps/bioEntities/elements/new_api_elements.adoc @@ -0,0 +1,36 @@ += Rest New API Documentation +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + + +== Get element by id +Returns list of bio entities matching the query. + +=== Path Parameters +include::{snippets}/new_api/projects/maps/bioEntities/elements/get_by_id/path-parameters.adoc[] + +=== Response Fields +include::{snippets}/new_api/projects/maps/bioEntities/elements/get_by_id/response-fields.adoc[] + +=== CURL sample +include::{snippets}/new_api/projects/maps/bioEntities/elements/get_by_id/curl-request.adoc[] + +=== Sample Response +include::{snippets}/new_api/projects/maps/bioEntities/elements/get_by_id/response-body.adoc[] + +== Download element list as csv file +Returns csv file with list of elements. + +=== Path Parameters +include::{snippets}/new_api/projects/maps/bioEntities/elements/export_to_csv/path-parameters.adoc[] + +=== Request Fields +include::{snippets}/new_api/projects/maps/bioEntities/elements/export_to_csv/request-fields.adoc[] + +=== CURL sample +include::{snippets}/new_api/projects/maps/bioEntities/elements/export_to_csv/curl-request.adoc[] + +=== Sample Response +include::{snippets}/new_api/projects/maps/bioEntities/elements/export_to_csv/response-body.adoc[] diff --git a/web/src/main/asciidoc/new_api/projects/maps/bioEntities/new_api_bioEntities.adoc b/web/src/main/asciidoc/new_api/projects/maps/bioEntities/new_api_bioEntities.adoc new file mode 100644 index 0000000000000000000000000000000000000000..c3918332f8eeb82c079691042d13a30c619f7973 --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/maps/bioEntities/new_api_bioEntities.adoc @@ -0,0 +1,28 @@ += Rest New API Documentation +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + + +== <<new_api_elements.adoc#,Elements>> + +== <<new_api_reactions.adoc#,Reactions>> + +== Search for bio entities +Returns list of bio entities matching the query. + +=== Path Parameters +include::{snippets}/new_api/projects/maps/bioEntities/search/path-parameters.adoc[] + +=== Request Parameters +include::{snippets}/new_api/projects/maps/bioEntities/search/request-parameters.adoc[] + +=== Response Fields +include::{snippets}/new_api/projects/maps/bioEntities/search/response-fields.adoc[] + +=== CURL sample +include::{snippets}/new_api/projects/maps/bioEntities/search/curl-request.adoc[] + +=== Sample Response +include::{snippets}/new_api/projects/maps/bioEntities/search/response-body.adoc[] diff --git a/web/src/main/asciidoc/new_api/projects/maps/bioEntities/reactions/new_api_reactions.adoc b/web/src/main/asciidoc/new_api/projects/maps/bioEntities/reactions/new_api_reactions.adoc new file mode 100644 index 0000000000000000000000000000000000000000..048f029a50193d424d6ba0a2b876f542cf591cda --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/maps/bioEntities/reactions/new_api_reactions.adoc @@ -0,0 +1,36 @@ += Rest New API Documentation +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + + +== Get reaction by id +Returns list of bio entities matching the query. + +=== Path Parameters +include::{snippets}/new_api/projects/maps/bioEntities/reactions/get_by_id/path-parameters.adoc[] + +=== Response Fields +include::{snippets}/new_api/projects/maps/bioEntities/reactions/get_by_id/response-fields.adoc[] + +=== CURL sample +include::{snippets}/new_api/projects/maps/bioEntities/reactions/get_by_id/curl-request.adoc[] + +=== Sample Response +include::{snippets}/new_api/projects/maps/bioEntities/reactions/get_by_id/response-body.adoc[] + +== Download reaction list as csv file +Returns csv file with list of reactions. + +=== Path Parameters +include::{snippets}/new_api/projects/maps/bioEntities/reactions/export_to_csv/path-parameters.adoc[] + +=== Request Fields +include::{snippets}/new_api/projects/maps/bioEntities/reactions/export_to_csv/request-fields.adoc[] + +=== CURL sample +include::{snippets}/new_api/projects/maps/bioEntities/reactions/export_to_csv/curl-request.adoc[] + +=== Sample Response +include::{snippets}/new_api/projects/maps/bioEntities/reactions/export_to_csv/response-body.adoc[] diff --git a/web/src/main/asciidoc/new_api/projects/maps/layers/images/new_api_images.adoc b/web/src/main/asciidoc/new_api/projects/maps/layers/images/new_api_images.adoc index d2389bf453040c1c277530686459906f54607c3a..5a3048ddac490ef293142b1697d20d6cfc926c17 100644 --- a/web/src/main/asciidoc/new_api/projects/maps/layers/images/new_api_images.adoc +++ b/web/src/main/asciidoc/new_api/projects/maps/layers/images/new_api_images.adoc @@ -23,8 +23,7 @@ include::{snippets}/new_api/projects/maps/layers/images/get_image/curl-request.a === Sample Response include::{snippets}/new_api/projects/maps/layers/images/get_image/response-body.adoc[] -== Add layer -Returns info about layer. +== Add layer image === Path Parameters include::{snippets}/new_api/projects/maps/layers/images/add_image/path-parameters.adoc[] @@ -41,8 +40,8 @@ include::{snippets}/new_api/projects/maps/layers/images/add_image/curl-request.a === Sample Response include::{snippets}/new_api/projects/maps/layers/images/add_image/response-body.adoc[] -== Update layer -Update layer. +== Update layer image +Update layer image. === Path Parameters include::{snippets}/new_api/projects/maps/layers/images/update_image/path-parameters.adoc[] @@ -59,8 +58,8 @@ include::{snippets}/new_api/projects/maps/layers/images/update_image/curl-reques === Sample Response include::{snippets}/new_api/projects/maps/layers/images/update_image/response-body.adoc[] -== Delete layer -Delete layer. +== Delete layer image +Delete layer image. === Path Parameters include::{snippets}/new_api/projects/maps/layers/images/delete_image/path-parameters.adoc[] @@ -68,8 +67,8 @@ include::{snippets}/new_api/projects/maps/layers/images/delete_image/path-parame === CURL sample include::{snippets}/new_api/projects/maps/layers/images/delete_image/curl-request.adoc[] -== List layers -List layers. +== List layer images +List layer images. === Path Parameters include::{snippets}/new_api/projects/maps/layers/images/list_images/path-parameters.adoc[] diff --git a/web/src/main/asciidoc/new_api/projects/maps/layers/new_api_layers.adoc b/web/src/main/asciidoc/new_api/projects/maps/layers/new_api_layers.adoc index ac0dbf24ec0ef618765a798f7c00c1ff60daee81..92558830edc8ca5bb5cf7e866948e74eec62f55a 100644 --- a/web/src/main/asciidoc/new_api/projects/maps/layers/new_api_layers.adoc +++ b/web/src/main/asciidoc/new_api/projects/maps/layers/new_api_layers.adoc @@ -8,6 +8,10 @@ v{project-version} {build-time} == Introduction Here will be a list of endpoints in the new format. This is a development unstable version and might change. At some point the whole API will be rewritten. +== <<new_api_images.adoc#,Images>> + +== <<new_api_texts.adoc#,Texts>> + == Get layer Returns info about layer. @@ -24,7 +28,6 @@ include::{snippets}/new_api/projects/maps/layers/get_layer/curl-request.adoc[] include::{snippets}/new_api/projects/maps/layers/get_layer/response-body.adoc[] == Add layer -Returns info about layer. === Path Parameters include::{snippets}/new_api/projects/maps/layers/add_layer/path-parameters.adoc[] diff --git a/web/src/main/asciidoc/new_api/projects/maps/layers/texts/new_api_texts.adoc b/web/src/main/asciidoc/new_api/projects/maps/layers/texts/new_api_texts.adoc index d1379c81a96fb857c4e17f4c70ab8060fccd2da0..5f8bb42955adb69e91c6f5c22c86ab9ffc67b28b 100644 --- a/web/src/main/asciidoc/new_api/projects/maps/layers/texts/new_api_texts.adoc +++ b/web/src/main/asciidoc/new_api/projects/maps/layers/texts/new_api_texts.adoc @@ -23,8 +23,7 @@ include::{snippets}/new_api/projects/maps/layers/texts/get_text/curl-request.ado === Sample Response include::{snippets}/new_api/projects/maps/layers/texts/get_text/response-body.adoc[] -== Add layer -Returns info about layer. +== Add layer text === Path Parameters include::{snippets}/new_api/projects/maps/layers/texts/add_text/path-parameters.adoc[] @@ -41,8 +40,8 @@ include::{snippets}/new_api/projects/maps/layers/texts/add_text/curl-request.ado === Sample Response include::{snippets}/new_api/projects/maps/layers/texts/add_text/response-body.adoc[] -== Update layer -Update layer. +== Update layer text +Update layer text === Path Parameters include::{snippets}/new_api/projects/maps/layers/texts/update_text/path-parameters.adoc[] @@ -59,8 +58,8 @@ include::{snippets}/new_api/projects/maps/layers/texts/update_text/curl-request. === Sample Response include::{snippets}/new_api/projects/maps/layers/texts/update_text/response-body.adoc[] -== Delete layer -Delete layer. +== Delete layer text +Delete layer text === Path Parameters include::{snippets}/new_api/projects/maps/layers/texts/delete_text/path-parameters.adoc[] @@ -68,8 +67,8 @@ include::{snippets}/new_api/projects/maps/layers/texts/delete_text/path-paramete === CURL sample include::{snippets}/new_api/projects/maps/layers/texts/delete_text/curl-request.adoc[] -== List layers -List layers. +== List layer texts +List layer texts === Path Parameters include::{snippets}/new_api/projects/maps/layers/texts/list_texts/path-parameters.adoc[] diff --git a/web/src/main/asciidoc/new_api/projects/maps/new_api_maps.adoc b/web/src/main/asciidoc/new_api/projects/maps/new_api_maps.adoc new file mode 100644 index 0000000000000000000000000000000000000000..24dfa0e96ff3bedfcda689648e000e1aea4be8c3 --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/maps/new_api_maps.adoc @@ -0,0 +1,9 @@ += Rest New API Documentation - Project +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + +== <<new_api_bioEntities.adoc#,BioEntities>> + +== <<new_api_layers.adoc#,Layers>> \ No newline at end of file diff --git a/web/src/main/asciidoc/new_api/projects/new_api_project.adoc b/web/src/main/asciidoc/new_api/projects/new_api_project.adoc new file mode 100644 index 0000000000000000000000000000000000000000..46a2ef7a29ab3b4cf6b0bc16edefe41d36054c3b --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/new_api_project.adoc @@ -0,0 +1,17 @@ += Rest New API Documentation - Project +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + +== <<new_api_project_data.adoc#,Project Data>> + +== <<new_api_chemicals.adoc#,Chemicals>> + +== <<new_api_drugs.adoc#,Drugs>> + +== <<new_api_glyphs.adoc#,Glyphs>> + +== <<new_api_maps.adoc#,Maps>> + +=== <<new_api_overlays.adoc#,Overlays>> diff --git a/web/src/main/asciidoc/new_api/projects/new_api_project_data.adoc b/web/src/main/asciidoc/new_api/projects/new_api_project_data.adoc new file mode 100644 index 0000000000000000000000000000000000000000..6cb8a721efc01daf1006db85ca9d44cdd98e469c --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/new_api_project_data.adoc @@ -0,0 +1,128 @@ += Rest New API Documentation - Projects +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + +== Get project by projectId + +Returns metadata of the project. + +=== CURL sample + +include::{snippets}/new_api/projects/get_by_project_id/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/projects/get_by_project_id/path-parameters.adoc[] + +=== Response Fields + +include::{snippets}/new_api/projects/get_by_project_id/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/projects/get_by_project_id/response-body.adoc[] + +== List + +List all projects. + +=== CURL sample + +include::{snippets}/new_api/projects/list_projects/curl-request.adoc[] + +=== Response Fields + +include::{snippets}/new_api/projects/list_projects/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/projects/list_projects/response-body.adoc[] + +== Create project (for editor) + +Creates project without a diagram. +This is not useful yet. + +=== Path Parameters + +include::{snippets}/new_api/projects/create_project_from_json/path-parameters.adoc[] + +=== Request Fields + +include::{snippets}/new_api/projects/create_project_from_json/request-fields.adoc[] + +=== Response Fields + +include::{snippets}/new_api/projects/create_project_from_json/response-fields.adoc[] + +=== CURL sample + +include::{snippets}/new_api/projects/create_project_from_json/curl-request.adoc[] + +=== Sample Response + +include::{snippets}/new_api/projects/create_project_from_json/response-body.adoc[] + +== Update project + +Updates project. + +=== Path Parameters + +include::{snippets}/new_api/projects/update_project/path-parameters.adoc[] + +=== Request Fields + +include::{snippets}/new_api/projects/update_project/request-fields.adoc[] + +=== Response Fields + +include::{snippets}/new_api/projects/update_project/response-fields.adoc[] + +=== CURL sample + +include::{snippets}/new_api/projects/update_project/curl-request.adoc[] + +=== Sample Response + +include::{snippets}/new_api/projects/update_project/response-body.adoc[] + +== Delete project + +=== Path Parameters + +include::{snippets}/new_api/projects/delete_project/path-parameters.adoc[] + +=== CURL sample + +include::{snippets}/new_api/projects/delete_project/curl-request.adoc[] + +=== Sample Response + +include::{snippets}/new_api/projects/delete_project/response-body.adoc[] + +== Get logs + +Gets logs generated on project upload. + +=== Path Parameters + +include::{snippets}/new_api/projects/logs/list/path-parameters.adoc[] + +=== Request Parameters + +include::{snippets}/new_api/projects/logs/list/request-parameters.adoc[] + +=== Response Fields + +include::{snippets}/new_api/projects/logs/list/response-fields.adoc[] + +=== CURL sample + +include::{snippets}/new_api/projects/logs/list/curl-request.adoc[] + +=== Sample Response + +include::{snippets}/new_api/projects/logs/list/response-body.adoc[] \ No newline at end of file diff --git a/web/src/main/asciidoc/new_api/projects/overlays/new_api_overlays.adoc b/web/src/main/asciidoc/new_api/projects/overlays/new_api_overlays.adoc new file mode 100644 index 0000000000000000000000000000000000000000..e601eeabb962e77c5b341c5fa8ec0116d3b21284 --- /dev/null +++ b/web/src/main/asciidoc/new_api/projects/overlays/new_api_overlays.adoc @@ -0,0 +1,21 @@ += Rest New API Documentation +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + + +== Get list of associated bioEntities in the overlay +Returns list of bioEntities that match entries in the overlay. + +=== Path Parameters +include::{snippets}/new_api/projects/overlays/get_bioEntities/path-parameters.adoc[] + +=== Response Fields +include::{snippets}/new_api/projects/overlays/get_bioEntities/response-fields.adoc[] + +=== CURL sample +include::{snippets}/new_api/projects/overlays/get_bioEntities/curl-request.adoc[] + +=== Sample Response +include::{snippets}/new_api/projects/overlays/get_bioEntities/response-body.adoc[] diff --git a/web/src/main/asciidoc/new_api/users/new_api_user.adoc b/web/src/main/asciidoc/new_api/users/new_api_user.adoc new file mode 100644 index 0000000000000000000000000000000000000000..c1e5967451630e01c8bf8f4655efd96e45f8047c --- /dev/null +++ b/web/src/main/asciidoc/new_api/users/new_api_user.adoc @@ -0,0 +1,202 @@ += Rest New API Documentation - User +minerva +v{project-version} {build-time} +:toc: left +:sectnums: + + +== Get user by id + +Returns user data. + +=== CURL sample + +include::{snippets}/new_api/users/get_by_id/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/users/get_by_id/path-parameters.adoc[] + +=== Response Fields + +include::{snippets}/new_api/users/get_by_id/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/users/get_by_id/response-body.adoc[] + +== List all users + +=== CURL sample + +include::{snippets}/new_api/users/list_users/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/users/list_users/path-parameters.adoc[] + +=== Response Fields + +include::{snippets}/new_api/users/list_users/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/users/list_users/response-body.adoc[] + +== Create user + +=== CURL sample + +include::{snippets}/new_api/users/create_user/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/users/create_user/path-parameters.adoc[] + +=== Request Fields + +include::{snippets}/new_api/users/create_user/request-fields.adoc[] + +=== Response Fields + +include::{snippets}/new_api/users/create_user/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/users/create_user/response-body.adoc[] + +== Update user + +=== CURL sample + +include::{snippets}/new_api/users/update_user/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/users/update_user/path-parameters.adoc[] + +=== Request Fields + +include::{snippets}/new_api/users/update_user/request-fields.adoc[] + +=== Response Fields + +include::{snippets}/new_api/users/update_user/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/users/update_user/response-body.adoc[] + +== Grant user privilege + +=== Path Parameters + +include::{snippets}/new_api/users/grant_privilege/path-parameters.adoc[] + +=== Request Fields + +include::{snippets}/new_api/users/grant_privilege/request-fields.adoc[] + +=== Response Fields + +include::{snippets}/new_api/users/grant_privilege/response-fields.adoc[] + +=== CURL sample + +include::{snippets}/new_api/users/grant_privilege/curl-request.adoc[] + +=== Sample Response + +include::{snippets}/new_api/users/grant_privilege/response-body.adoc[] + +== Revoke user privilege + +=== Path Parameters + +include::{snippets}/new_api/users/revoke_privilege/path-parameters.adoc[] + +=== Request Fields + +include::{snippets}/new_api/users/revoke_privilege/request-fields.adoc[] + +=== Response Fields + +include::{snippets}/new_api/users/revoke_privilege/response-fields.adoc[] + +=== CURL sample + +include::{snippets}/new_api/users/revoke_privilege/curl-request.adoc[] + +=== Sample Response + +include::{snippets}/new_api/users/revoke_privilege/response-body.adoc[] + +== Delete user + +=== CURL sample + +include::{snippets}/new_api/users/delete_user/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/users/delete_user/path-parameters.adoc[] + +== Request password reset over email + +=== CURL sample + +include::{snippets}/new_api/users/request_reset_password/curl-request.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/users/request_reset_password/path-parameters.adoc[] + +== Reset password using token obtained over email + +=== CURL sample + +include::{snippets}/new_api/users/reset_password/curl-request.adoc[] + +=== Request Fields + +include::{snippets}/new_api/users/reset_password/request-fields.adoc[] + +== Register new user + +=== CURL sample + +include::{snippets}/new_api/users/register_user/curl-request.adoc[] + +=== Request Fields + +include::{snippets}/new_api/users/register_user/request-fields.adoc[] + +=== Response Fields + +include::{snippets}/new_api/users/register_user/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/users/register_user/response-body.adoc[] + +== Confirm email + +=== CURL sample + +include::{snippets}/new_api/users/confirm_email/curl-request.adoc[] + +=== Request Parameters + +include::{snippets}/new_api/users/confirm_email/request-parameters.adoc[] + +=== Path Parameters + +include::{snippets}/new_api/users/confirm_email/path-parameters.adoc[] + +=== Response Fields + +include::{snippets}/new_api/users/confirm_email/response-fields.adoc[] + +=== Sample Response + +include::{snippets}/new_api/users/confirm_email/response-body.adoc[] diff --git a/web/src/main/asciidoc/project.adoc b/web/src/main/asciidoc/project.adoc index a91134a53667fa9ae62bea8d2d0032e4951007ef..26fb0c1be3734133dfbd386e1b007bf6cd1489cf 100644 --- a/web/src/main/asciidoc/project.adoc +++ b/web/src/main/asciidoc/project.adoc @@ -5,11 +5,18 @@ v{project-version} {build-time} :sectnums: -=== <<project_data.adoc#,Project Data>> -=== <<project_backgrounds.adoc#,Project Backgrounds>> -=== <<project_chemicals.adoc#,Project Chemicals>> -=== <<project_comments.adoc#,Project Comments>> -=== <<project_drugs.adoc#,Project Drugs>> -=== <<project_maps.adoc#,Project Maps>> -=== <<project_overlays.adoc#,Project Overlays>> -=== <<project_privileges.adoc#,Project Privileges>> +== <<project_data.adoc#,Project Data>> + +== <<project_backgrounds.adoc#,Project Backgrounds>> + +== <<project_chemicals.adoc#,Project Chemicals>> + +== <<project_comments.adoc#,Project Comments>> + +== <<project_drugs.adoc#,Project Drugs>> + +== <<project_maps.adoc#,Project Maps>> + +== <<project_overlays.adoc#,Project Overlays>> + +== <<project_privileges.adoc#,Project Privileges>> diff --git a/web/src/main/asciidoc/projects/project_data.adoc b/web/src/main/asciidoc/projects/project_data.adoc index 07bb0dab29712ca69e18a650bff35b468f2db656..b8302e6c9d0f7c6db5d8b3bd945ce33669874175 100644 --- a/web/src/main/asciidoc/projects/project_data.adoc +++ b/web/src/main/asciidoc/projects/project_data.adoc @@ -5,156 +5,198 @@ v{project-version} {build-time} :sectnums: == Get project -Returns meta data of the project. + +Returns metadata of the project. === CURL sample + include::{snippets}/projects/project_data/get_project/curl-request.adoc[] === Path Parameters + include::{snippets}/projects/project_data/get_project/path-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_data/get_project/response-fields.adoc[] === Sample Response -include::{snippets}/projects/project_data/get_project/response-body.adoc[] +include::{snippets}/projects/project_data/get_project/response-body.adoc[] == List + List all projects. === CURL sample + include::{snippets}/projects/project_data/list/curl-request.adoc[] === Response Fields + include::{snippets}/projects/project_data/list/response-fields.adoc[] === Sample Response -include::{snippets}/projects/project_data/list/response-body.adoc[] +include::{snippets}/projects/project_data/list/response-body.adoc[] == Create project + Creates project from file that is already uploaded to minerva. === Path Parameters + 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[] === Example 1. + Upload of project from simple file ==== CURL sample + include::{snippets}/projects/project_data/create_simple/curl-request.adoc[] ==== Sample Response + include::{snippets}/projects/project_data/create_simple/response-body.adoc[] === Example 2. + Upload of project from complex zip file ==== CURL sample + include::{snippets}/projects/project_data/create_zip/curl-request.adoc[] ==== Sample Response -include::{snippets}/projects/project_data/create_zip/response-body.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[] +include::{snippets}/projects/project_data/update/response-body.adoc[] == Delete project === Path Parameters + include::{snippets}/projects/project_data/delete/path-parameters.adoc[] === CURL sample + include::{snippets}/projects/project_data/delete/curl-request.adoc[] === Sample Response -include::{snippets}/projects/project_data/delete/response-body.adoc[] +include::{snippets}/projects/project_data/delete/response-body.adoc[] == Get source + Gets source file used to create the project. === Path Parameters + include::{snippets}/projects/project_data/get_source_file/path-parameters.adoc[] === CURL sample + include::{snippets}/projects/project_data/get_source_file/curl-request.adoc[] === Sample Response + include::{snippets}/projects/project_data/get_source_file/response-body.adoc[] == Get logs + Gets logs generated on project upload. === Path Parameters + include::{snippets}/projects/project_data/get_project_logs/path-parameters.adoc[] === Request Parameters + include::{snippets}/projects/project_data/get_project_logs/request-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_data/get_project_logs/response-fields.adoc[] === CURL sample + include::{snippets}/projects/project_data/get_project_logs/curl-request.adoc[] === Sample Response + include::{snippets}/projects/project_data/get_project_logs/response-body.adoc[] == Get statistics + Gets set of statistics about the project. === Path Parameters + include::{snippets}/projects/project_data/get_project_statistics/path-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_data/get_project_statistics/response-fields.adoc[] === CURL sample + include::{snippets}/projects/project_data/get_project_statistics/curl-request.adoc[] === Sample Response + include::{snippets}/projects/project_data/get_project_statistics/response-body.adoc[] == Get publications + Gets publication list used in the project. === Path Parameters + include::{snippets}/projects/project_data/get_publications/path-parameters.adoc[] === Request Parameters + include::{snippets}/projects/project_data/get_project_logs/request-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_data/get_publications/response-fields.adoc[] === CURL sample + include::{snippets}/projects/project_data/get_publications/curl-request.adoc[] === Sample Response + include::{snippets}/projects/project_data/get_publications/response-body.adoc[] diff --git a/web/src/main/asciidoc/projects/project_drugs.adoc b/web/src/main/asciidoc/projects/project_drugs.adoc index 68f66110ef833b49343042425cf24dbdad577ca4..5ed51468b8f55283243c463b6eac332187c4c3dd 100644 --- a/web/src/main/asciidoc/projects/project_drugs.adoc +++ b/web/src/main/asciidoc/projects/project_drugs.adoc @@ -5,39 +5,50 @@ v{project-version} {build-time} :sectnums: == Get drug -Returns drugs data with project related connections. + +Returns drug data with project related connections. === CURL sample 1 + include::{snippets}/projects/project_drugs/search_by_query/curl-request.adoc[] === CURL sample 2 + include::{snippets}/projects/project_drugs/search_by_target/curl-request.adoc[] === Path Parameters + include::{snippets}/projects/project_drugs/search_by_query/path-parameters.adoc[] === Request Parameters + include::{snippets}/projects/project_drugs/search_by_query/request-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_drugs/search_by_query/response-fields.adoc[] === Sample Response -include::{snippets}/projects/project_drugs/search_by_query/response-body.adoc[] +include::{snippets}/projects/project_drugs/search_by_query/response-body.adoc[] == Get suggested drug queries + Get list of suggested drug queries in the context of the project. === CURL sample + include::{snippets}/projects/project_drugs/suggested_query_list/curl-request.adoc[] === Path Parameters + include::{snippets}/projects/project_drugs/suggested_query_list/path-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_drugs/suggested_query_list/response-fields.adoc[] === Sample Response + include::{snippets}/projects/project_drugs/suggested_query_list/response-body.adoc[] diff --git a/web/src/main/asciidoc/projects/project_overlays.adoc b/web/src/main/asciidoc/projects/project_overlays.adoc index 999c38e1be21dc0097c9ca119b74f04230ecd819..7f5e4ac8d423167dfe6d089df000ce3e2fb5b572 100644 --- a/web/src/main/asciidoc/projects/project_overlays.adoc +++ b/web/src/main/asciidoc/projects/project_overlays.adoc @@ -7,152 +7,184 @@ v{project-version} {build-time} == List data overlays === Path Parameters + include::{snippets}/projects/project_overlays/get_all_by_creator/path-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_overlays/get_all_by_creator/response-fields.adoc[] === CURL sample 1 + include::{snippets}/projects/project_overlays/get_all/curl-request.adoc[] === Sample Response 1 + include::{snippets}/projects/project_overlays/get_all/response-body.adoc[] === CURL sample 2 + include::{snippets}/projects/project_overlays/get_all_by_creator/curl-request.adoc[] === Sample Response 2 -include::{snippets}/projects/project_overlays/get_all_by_creator/response-body.adoc[] +include::{snippets}/projects/project_overlays/get_all_by_creator/response-body.adoc[] -== Get data overlay +== Get data overlay === Path Parameters + include::{snippets}/projects/project_overlays/get_by_id/path-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_overlays/get_by_id/response-fields.adoc[] === CURL sample + include::{snippets}/projects/project_overlays/get_by_id/curl-request.adoc[] === Sample Response -include::{snippets}/projects/project_overlays/get_by_id/response-body.adoc[] +include::{snippets}/projects/project_overlays/get_by_id/response-body.adoc[] == Add overlay === Path Parameters + include::{snippets}/projects/project_overlays/create_from_file/path-parameters.adoc[] === Request Parameters + include::{snippets}/projects/project_overlays/create_from_file/request-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_overlays/create_from_file/response-fields.adoc[] === CURL sample from file + include::{snippets}/projects/project_overlays/create_from_file/curl-request.adoc[] === Sample Response from file + include::{snippets}/projects/project_overlays/create_from_file/response-body.adoc[] === CURL sample from content + include::{snippets}/projects/project_overlays/create_from_content/curl-request.adoc[] === Sample Response from content -include::{snippets}/projects/project_overlays/create_from_content/response-body.adoc[] +include::{snippets}/projects/project_overlays/create_from_content/response-body.adoc[] == Update overlay === Path Parameters + include::{snippets}/projects/project_overlays/update_overlay/path-parameters.adoc[] === Request Fields + include::{snippets}/projects/project_overlays/update_overlay/request-fields.adoc[] === Response Fields + include::{snippets}/projects/project_overlays/update_overlay/response-fields.adoc[] === CURL sample + include::{snippets}/projects/project_overlays/update_overlay/curl-request.adoc[] === Sample Response -include::{snippets}/projects/project_overlays/update_overlay/response-body.adoc[] +include::{snippets}/projects/project_overlays/update_overlay/response-body.adoc[] == Delete overlay === CURL sample + include::{snippets}/projects/project_overlays/delete_overlay/curl-request.adoc[] === Path Parameters -include::{snippets}/projects/project_overlays/delete_overlay/path-parameters.adoc[] +include::{snippets}/projects/project_overlays/delete_overlay/path-parameters.adoc[] == Download source data === Path Parameters + include::{snippets}/projects/project_overlays/download_source/path-parameters.adoc[] === CURL sample + include::{snippets}/projects/project_overlays/download_source/curl-request.adoc[] === Sample Response -include::{snippets}/projects/project_overlays/download_source/response-body.adoc[] +include::{snippets}/projects/project_overlays/download_source/response-body.adoc[] == Download legend === Path Parameters -include::{snippets}/projects/project_legend/download_source/path-parameters.adoc[] + +include::{snippets}/projects/project_overlays/download_legend/path-parameters.adoc[] === CURL sample -include::{snippets}/projects/project_legend/download_source/curl-request.adoc[] +include::{snippets}/projects/project_overlays/download_legend/curl-request.adoc[] -== Get list of associated bioEntites +== Get list of associated bioEntities === Path Parameters + include::{snippets}/projects/project_overlays/get_bio_entities/path-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_overlays/get_bio_entities/response-fields.adoc[] === CURL sample + include::{snippets}/projects/project_overlays/get_bio_entities/curl-request.adoc[] === Sample Response -include::{snippets}/projects/project_overlays/get_bio_entities/response-body.adoc[] +include::{snippets}/projects/project_overlays/get_bio_entities/response-body.adoc[] == Get reaction data === Path Parameters + include::{snippets}/projects/project_overlays/get_reaction/path-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_overlays/get_reaction/response-fields.adoc[] === CURL sample + include::{snippets}/projects/project_overlays/get_reaction/curl-request.adoc[] === Sample Response -include::{snippets}/projects/project_overlays/get_reaction/response-body.adoc[] +include::{snippets}/projects/project_overlays/get_reaction/response-body.adoc[] == Get element data === Path Parameters + include::{snippets}/projects/project_overlays/get_element/path-parameters.adoc[] === Response Fields + include::{snippets}/projects/project_overlays/get_element/response-fields.adoc[] === CURL sample + include::{snippets}/projects/project_overlays/get_element/curl-request.adoc[] === Sample Response + include::{snippets}/projects/project_overlays/get_element/response-body.adoc[] diff --git a/web/src/main/java/lcsb/mapviewer/web/api/plugin/NewPluginController.java b/web/src/main/java/lcsb/mapviewer/web/api/plugin/NewPluginController.java index 1803cbd3b94cb4f6ebedc16a6563811abcaeda39..d30f236e74071654dea2cd630c1f5f78978cafce 100644 --- a/web/src/main/java/lcsb/mapviewer/web/api/plugin/NewPluginController.java +++ b/web/src/main/java/lcsb/mapviewer/web/api/plugin/NewPluginController.java @@ -127,7 +127,7 @@ public class NewPluginController { @GetMapping(value = "/") public ResponseEntity<?> listPlugins(final Pageable pageable) { final Map<PluginProperty, Object> pluginFilter = new HashMap<>(); - pluginFilter.put(PluginProperty.DEFAULT_VALUE, true); + pluginFilter.put(PluginProperty.PUBLIC_VALUE, true); final Page<Plugin> plugins = pluginService.getAll(pluginFilter, pageable); return serializer.prepareResponse(plugins); } diff --git a/web/src/main/java/lcsb/mapviewer/web/api/project/NewProjectController.java b/web/src/main/java/lcsb/mapviewer/web/api/project/NewProjectController.java index 72c72660895c9467b3134b38d604be8b85a9133f..c7bdce6b3c82fa2adf3741fdc7c3bb91c9925457 100644 --- a/web/src/main/java/lcsb/mapviewer/web/api/project/NewProjectController.java +++ b/web/src/main/java/lcsb/mapviewer/web/api/project/NewProjectController.java @@ -49,6 +49,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; @RestController @Validated @@ -100,7 +101,7 @@ public class NewProjectController { public ResponseEntity<?> addProject( final Authentication authentication, final @Valid @RequestBody NewProjectDTO data) - throws QueryException, ObjectNotFoundException, ObjectExistsException { + throws QueryException, ObjectNotFoundException, ObjectExistsException, FailedDependencyException, IOException { Project project = projectService.getProjectByProjectId(data.getProjectId()); if (project != null) { @@ -109,17 +110,18 @@ public class NewProjectController { project = new Project(data.getProjectId()); data.saveToProject(project); project.setOwner(userService.getUserByLogin(authentication.getName())); + project.setDirectory(UUID.randomUUID().toString()); projectService.add(project); project = projectService.getProjectByProjectId(data.getProjectId(), true); - return serializer.prepareResponse(project, HttpStatus.CREATED); + return serializer.prepareResponse(project, + new ProjectResponseDecorator(minervaNetController.getSharedProjects(), meshService, taxonomyService), HttpStatus.CREATED); } @PreAuthorize("hasAnyAuthority('IS_ADMIN', 'IS_CURATOR')") @PostMapping(value = "/{projectId:.+}:move") public ResponseEntity<?> moveProject( final @NotBlank @PathVariable(value = "projectId") String projectId, - final Authentication authentication, final @Valid @RequestBody NewMoveProjectDTO data) throws ObjectNotFoundException, ObjectExistsException, UpdateConflictException { @@ -136,7 +138,7 @@ public class NewProjectController { throw new UpdateConflictException("Cannot move project. Project is shared in minerva net"); } - boolean sharedProject = false; + boolean sharedProject; try { sharedProject = minervaNetController.getSharedProjects().contains(data.getProjectId()); } catch (Exception e) { diff --git a/web/src/main/java/lcsb/mapviewer/web/api/project/map/bioentity/elements/NewElementsController.java b/web/src/main/java/lcsb/mapviewer/web/api/project/map/bioentity/elements/NewElementsController.java index 7fca9770d4ede9a52bcb7ad285f7878da6c9d002..cd2728315c0f12246adf3c745a72667e21c81e65 100644 --- a/web/src/main/java/lcsb/mapviewer/web/api/project/map/bioentity/elements/NewElementsController.java +++ b/web/src/main/java/lcsb/mapviewer/web/api/project/map/bioentity/elements/NewElementsController.java @@ -100,10 +100,9 @@ public class NewElementsController extends BaseController { } final List<Element> elements = elementService.getElementsByFilter(properties, Pageable.unpaged(), true).getContent(); - if (elements.size() == 0) { + if (elements.isEmpty()) { throw new ObjectNotFoundException("Element does not exists"); } - logger.debug(elements.get(0).getGlyph()); return serializer.prepareResponse(elements.get(0), bioEntityResponseDecorator); } diff --git a/web/src/main/java/lcsb/mapviewer/web/api/user/NewUserController.java b/web/src/main/java/lcsb/mapviewer/web/api/user/NewUserController.java index abefda97ed55655b347da82eae753d350abf9d23..3885a7cf96534a61305be090957e7252ea958d7c 100644 --- a/web/src/main/java/lcsb/mapviewer/web/api/user/NewUserController.java +++ b/web/src/main/java/lcsb/mapviewer/web/api/user/NewUserController.java @@ -283,7 +283,6 @@ public class NewUserController extends BaseController { final @Valid @RequestBody ResetPasswordDTO data) throws IOException, QueryException, ObjectNotFoundException { try { - logger.debug("XXX"); userService.resetPassword(data.getToken(), passwordEncoder.encode(data.getPassword())); return okStatus(); } catch (final InvalidTokenException e) { diff --git a/web/src/test/java/lcsb/mapviewer/web/ChemicalControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/ChemicalControllerIntegrationTest.java index 5c8a7fb8616349af9237700dc203bf7acd3c6ba8..1fd2cf6635f209f1031adc7bf378ae871e80c04c 100644 --- a/web/src/test/java/lcsb/mapviewer/web/ChemicalControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/ChemicalControllerIntegrationTest.java @@ -67,7 +67,7 @@ public class ChemicalControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testSearchChemicalsInProjectUrl() throws Exception { + public void testDocsSearchChemicalsInProjectUrl() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/api/projects/{projectId}/chemicals:search?query=stilbene oxide", TEST_PROJECT) @@ -98,7 +98,7 @@ public class ChemicalControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetSuggestedList() throws Exception { + public void testDocsGetSuggestedList() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final MiriamData bloodLossDisease = new MiriamData(MiriamType.MESH_2012, "D016063"); @@ -185,7 +185,7 @@ public class ChemicalControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testSearchChemicalsByTarget() throws Exception { + public void testDocsSearchChemicalsByTarget() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); Element element = null; diff --git a/web/src/test/java/lcsb/mapviewer/web/CommentControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/CommentControllerIntegrationTest.java index de5a422215f3258dc04ec5b691264f47d55d82a5..a6af56f93f1dc9a7ebb4b6deedad5ca06edbde7a 100644 --- a/web/src/test/java/lcsb/mapviewer/web/CommentControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/CommentControllerIntegrationTest.java @@ -102,7 +102,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAdminSeesAllComments() throws Exception { + public void testDocsAdminSeesAllComments() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createComments(); @@ -358,7 +358,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testRemoveAsAdmin() throws Exception { + public void testDocsRemoveAsAdmin() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); Comment comment = createAndPersistComment(map, null); @@ -436,7 +436,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetReactionCommentsAsAdmin() throws Exception { + public void testDocsGetReactionCommentsAsAdmin() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createReactionComment(); @@ -508,7 +508,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetElementCommentsAsAdmin() throws Exception { + public void testDocsGetElementCommentsAsAdmin() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createElementComment(); @@ -585,7 +585,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetPointCommentsAsAdmin() throws Exception { + public void testDocsGetPointCommentsAsAdmin() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createAndPersistComment(map, null); @@ -664,7 +664,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAddElementCommentAsUserWithAccess() throws Exception { + public void testDocsAddElementCommentAsUserWithAccess() throws Exception { MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD); String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList( @@ -807,7 +807,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAddReactionCommentAsUserWithAccess() throws Exception { + public void testDocsAddReactionCommentAsUserWithAccess() throws Exception { MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD); String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList( @@ -884,7 +884,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAddPointCommentAsUserWithAccess() throws Exception { + public void testDocsAddPointCommentAsUserWithAccess() throws Exception { MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD); String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList( diff --git a/web/src/test/java/lcsb/mapviewer/web/ConfigurationControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/ConfigurationControllerIntegrationTest.java index 19f32ea9daef1701a2e6291e7804c5ecdf5ef19b..2ca82ae2d5edbdbb2cc2375f2c58bd254df6d1bc 100644 --- a/web/src/test/java/lcsb/mapviewer/web/ConfigurationControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/ConfigurationControllerIntegrationTest.java @@ -88,7 +88,7 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio } @Test - public void accessConfigurationAsAnonymous() throws Exception { + public void testDocsAccessConfigurationAsAnonymous() throws Exception { RequestBuilder request = get("/minerva/api/configuration/"); mockMvc.perform(request) @@ -99,7 +99,7 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio } @Test - public void accessConfigurationOptionsAsAnonymous() throws Exception { + public void testDocsAccessConfigurationOptionsAsAnonymous() throws Exception { RequestBuilder request = get("/minerva/api/configuration/options/"); String response = mockMvc.perform(request) @@ -120,7 +120,7 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio } @Test - public void testSetSmtpPort() throws Exception { + public void testDocsSetSmtpPort() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); Map<String, Object> option = new HashMap<>(); diff --git a/web/src/test/java/lcsb/mapviewer/web/ConfigurationDapiControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/ConfigurationDapiControllerIntegrationTest.java index f2d0729e9c937410afe0b56851c696f73f2a80d2..fade729d5e4ab58e275f4235565b4a6298be3a6e 100644 --- a/web/src/test/java/lcsb/mapviewer/web/ConfigurationDapiControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/ConfigurationDapiControllerIntegrationTest.java @@ -33,7 +33,7 @@ public class ConfigurationDapiControllerIntegrationTest extends ControllerIntegr private ObjectMapper objectMapper; @Test - public void getDapiConfiguration() throws Exception { + public void testDocsGetDapiConfiguration() throws Exception { RequestBuilder request = get("/minerva/api/configuration/dapi/"); mockMvc.perform(request) @@ -45,7 +45,7 @@ public class ConfigurationDapiControllerIntegrationTest extends ControllerIntegr } @Test - public void getDapiDatabasesConfiguration() throws Exception { + public void testDocsGetDapiDatabasesConfiguration() throws Exception { RequestBuilder request = get("/minerva/api/configuration/dapi/database/"); mockMvc.perform(request) @@ -61,7 +61,7 @@ public class ConfigurationDapiControllerIntegrationTest extends ControllerIntegr } @Test - public void getDapiDrugBankReleaseConfiguration() throws Exception { + public void testDocsGetDapiDrugBankReleaseConfiguration() throws Exception { assumeTrue("DAPI credentials are not provided", isDapiConfigurationAvailable()); RequestBuilder request = get("/minerva/api/configuration/dapi/database/{database}/release/", "DrugBank"); @@ -97,7 +97,7 @@ public class ConfigurationDapiControllerIntegrationTest extends ControllerIntegr } @Test - public void acceptLicenseReleaseWithAccess() throws Exception { + public void testDocsAcceptLicenseReleaseWithAccess() throws Exception { assumeTrue("DAPI credentials are not provided", isDapiConfigurationAvailable()); MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -125,7 +125,7 @@ public class ConfigurationDapiControllerIntegrationTest extends ControllerIntegr } @Test - public void testRegisterExistingDapiUser() throws Exception { + public void testDocsRegisterExistingDapiUser() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); UserDto user = new UserDto(); @@ -161,11 +161,9 @@ public class ConfigurationDapiControllerIntegrationTest extends ControllerIntegr .contentType(MediaType.APPLICATION_JSON) .session(session); - String content = mockMvc.perform(request) + mockMvc.perform(request) .andExpect(status().isBadRequest()) .andReturn().getResponse().getContentAsString(); - - logger.debug(content); } } diff --git a/web/src/test/java/lcsb/mapviewer/web/ConvertControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/ConvertControllerIntegrationTest.java index 2713295db5f679173bbf56c9e7b1f7e063cea14d..fffb39097a0a0936489391f91c36eabede4d6885 100644 --- a/web/src/test/java/lcsb/mapviewer/web/ConvertControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/ConvertControllerIntegrationTest.java @@ -94,7 +94,7 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testMergeCellDesignerMaps() throws Exception { + public void testDocsMergeCellDesignerMaps() throws Exception { byte[] body = Files.readAllBytes(new File("src/test/resources/convert/cd-maps.zip").toPath()); RequestBuilder request = post("/minerva/api/convert/merge/{inputFormat}:{outputFormat}", "CellDesigner_SBML", "CellDesigner_SBML") @@ -163,7 +163,7 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testListAvailableFormats() throws Exception { + public void testDocsListAvailableFormats() throws Exception { RequestBuilder request = get("/minerva/api/convert/"); mockMvc.perform(request) @@ -185,7 +185,7 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void convertCellDesignerToGpml() throws Exception { + public void testDocsConvertCellDesignerToGpml() throws Exception { File file = new File("src/test/resources/convert/cd-sample.xml"); String content = FileUtils.readFileToString(file, StandardCharsets.UTF_8); RequestBuilder request = post("/minerva/api/convert/{inputFormat}:{outputFormat}", "CellDesigner_SBML", "GPML") @@ -204,7 +204,7 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testListAvailableImageFormats() throws Exception { + public void testDocsListAvailableImageFormats() throws Exception { RequestBuilder request = get("/minerva/api/convert/image/"); mockMvc.perform(request) @@ -226,7 +226,7 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void convertCellDesignerToSvg() throws Exception { + public void testDocsConvertCellDesignerToSvg() throws Exception { File file = new File("src/test/resources/convert/cd-sample.xml"); String content = FileUtils.readFileToString(file, StandardCharsets.UTF_8); RequestBuilder request = post("/minerva/api/convert/image/{inputFormat}:{outputFormat}", "CellDesigner_SBML", "png") @@ -503,7 +503,7 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testMergeCellDesignerWithTextArea() throws Exception { + public void testDocsMergeCellDesignerWithTextArea() throws Exception { Model model = new ModelFullIndexed(null); Layer layer = createLayer(); LayerText text = new LayerText(new Rectangle2D.Double(10, 20, 30, 40), "test text"); @@ -568,7 +568,7 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testPreserveNotesWithCustomHeader() throws Exception { + public void testDocsPreserveNotesWithCustomHeader() throws Exception { byte[] body = Files.readAllBytes(new File("src/test/resources/convert/cd-maps-with-notes.zip").toPath()); RequestBuilder request = post("/minerva/api/convert/merge/{inputFormat}:{outputFormat}", "CellDesigner_SBML", "CellDesigner_SBML") diff --git a/web/src/test/java/lcsb/mapviewer/web/DrugControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/DrugControllerIntegrationTest.java index 818e5b458c26dd76c82a4c9ff52d030c307c40a2..93eb33fc1424b513a7eb41ea8fdd12eae2a88379 100644 --- a/web/src/test/java/lcsb/mapviewer/web/DrugControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/DrugControllerIntegrationTest.java @@ -38,7 +38,7 @@ public class DrugControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testSearchDrugsInProjectUrl() throws Exception { + public void testDocsSearchDrugsInProjectUrl() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/api/projects/{projectId}/drugs:search?query=aspirin", TEST_PROJECT) @@ -75,7 +75,7 @@ public class DrugControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testSearchDrugsByTargetInSubmap() throws Exception { + public void testDocsSearchDrugsByTargetInSubmap() throws Exception { Project project = createAndPersistProject(TEST_PROJECT_ID); MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -84,19 +84,17 @@ public class DrugControllerIntegrationTest extends ControllerIntegrationTest { final RequestBuilder request = get("/minerva/api/projects/{projectId}/drugs:search?target=ALIAS:" + submapId, project.getProjectId()) .session(session); - String content = mockMvc.perform(request) + mockMvc.perform(request) .andDo(document("projects/project_drugs/search_by_target", getProjectPathParameters(), getChemicalFilter(), listOfDrugFields())) .andExpect(status().is2xxSuccessful()) .andReturn().getResponse().getContentAsString(); - - logger.debug(content); } @Test - public void testGetSuggestedList() throws Exception { + public void testDocsGetSuggestedList() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/api/projects/{projectId}/drugs/suggestedQueryList", TEST_PROJECT) diff --git a/web/src/test/java/lcsb/mapviewer/web/FileControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/FileControllerIntegrationTest.java index f2772b0fff26aae6cb56b934509c2529a005ca63..caf5fb1512c9d1bcb48b846ac45aaac5ade23a55 100644 --- a/web/src/test/java/lcsb/mapviewer/web/FileControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/FileControllerIntegrationTest.java @@ -1,21 +1,10 @@ package lcsb.mapviewer.web; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -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.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import lcsb.mapviewer.model.cache.UploadedFileEntry; +import lcsb.mapviewer.services.interfaces.IFileService; +import lcsb.mapviewer.services.interfaces.IUserService; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; @@ -29,12 +18,21 @@ import org.springframework.restdocs.payload.FieldDescriptor; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.RequestBuilder; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.Arrays; +import java.util.List; +import java.util.Map; -import lcsb.mapviewer.model.cache.UploadedFileEntry; -import lcsb.mapviewer.services.interfaces.IFileService; -import lcsb.mapviewer.services.interfaces.IUserService; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; +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.pathParameters; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) public class FileControllerIntegrationTest extends ControllerIntegrationTest { @@ -53,7 +51,7 @@ public class FileControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void canCreateAndUploadFile() throws Exception { + public void testDocsCanCreateAndUploadFile() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList( @@ -107,7 +105,7 @@ public class FileControllerIntegrationTest extends ControllerIntegrationTest { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); UploadedFileEntry file = new UploadedFileEntry(); - file.setFileContent(new byte[] {}); + file.setFileContent(new byte[]{}); file.setLength(99999); fileService.add(file); @@ -130,7 +128,7 @@ public class FileControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void getInfoAboutFile() throws Exception { + public void testDocsGetInfoAboutFile() throws Exception { UploadedFileEntry file = createFile("Hello world", userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN)); try { diff --git a/web/src/test/java/lcsb/mapviewer/web/FunctionControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/FunctionControllerIntegrationTest.java index df091300e3cf3e5a787501eec0e71e5b523fee72..15e2f7b3160bf7a4b83507e16318df7214565ea4 100644 --- a/web/src/test/java/lcsb/mapviewer/web/FunctionControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/FunctionControllerIntegrationTest.java @@ -1,19 +1,8 @@ package lcsb.mapviewer.web; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -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.pathParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - +import com.fasterxml.jackson.core.type.TypeReference; +import lcsb.mapviewer.model.Project; +import lcsb.mapviewer.model.map.model.ModelData; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -25,10 +14,19 @@ import org.springframework.restdocs.payload.ResponseFieldsSnippet; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.RequestBuilder; -import com.fasterxml.jackson.core.type.TypeReference; +import java.util.Arrays; +import java.util.List; +import java.util.Map; -import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.model.ModelData; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +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.pathParameters; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) public class FunctionControllerIntegrationTest extends ControllerIntegrationTest { @@ -76,7 +74,7 @@ public class FunctionControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetFunctions() throws Exception { + public void testDocsGetFunctions() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/functions/", TEST_PROJECT, map.getId()) @@ -91,13 +89,13 @@ public class FunctionControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetFunction() throws Exception { + public void testDocsGetFunction() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/functions/{functionId}", TEST_PROJECT, map.getId(), map.getFunctions().iterator().next().getId()) - .session(session); + .session(session); String response = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) @@ -136,7 +134,7 @@ public class FunctionControllerIntegrationTest extends ControllerIntegrationTest private ResponseFieldsSnippet listOfFunctionFields() { return responseFields( fieldWithPath("[]").description("list of functions")) - .andWithPrefix("[].", functionFields()); + .andWithPrefix("[].", functionFields()); } } diff --git a/web/src/test/java/lcsb/mapviewer/web/GenomicsControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/GenomicsControllerIntegrationTest.java index 61f7b1879a8aea8f1d1f3dc3aae87ec258bd58c5..84ae0eff669d555626acf3592777d9c0bfc05600 100644 --- a/web/src/test/java/lcsb/mapviewer/web/GenomicsControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/GenomicsControllerIntegrationTest.java @@ -17,7 +17,6 @@ import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -34,7 +33,7 @@ import java.util.Calendar; import java.util.List; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; @@ -49,8 +48,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringJUnit4ClassRunner.class) public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest { - private MiriamData ebolaId = new MiriamData(MiriamType.TAXONOMY, "1570291"); - private String ebolaUrl = "ftp://hgdownload.cse.ucsc.edu/goldenPath/eboVir3/bigZips/eboVir3.2bit"; + private final MiriamData ebolaId = new MiriamData(MiriamType.TAXONOMY, "1570291"); + private final String ebolaUrl = "ftp://hgdownload.cse.ucsc.edu/goldenPath/eboVir3/bigZips/eboVir3.2bit"; @Autowired private ProjectSnippets snippets; @@ -85,8 +84,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest } @Test - @Ignore("Taxonomy database issue") - public void testGetTaxonomies() throws Exception { + public void testDocsGetTaxonomies() throws Exception { RequestBuilder request = get("/minerva/api/genomics/taxonomies/"); @@ -101,7 +99,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest List<Object> data = objectMapper.readValue(response, new TypeReference<List<Object>>() { }); - assertTrue("list of taxonomies shouldn't be empty", data.size() > 0); + assertFalse("list of taxonomies shouldn't be empty", data.isEmpty()); } private List<FieldDescriptor> organismResponseFields() { @@ -116,8 +114,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest } @Test - @Ignore("Taxonomy database issue") - public void testGetGenomeTypes() throws Exception { + public void testDocsGetGenomeTypes() throws Exception { RequestBuilder request = get("/minerva/api/genomics/taxonomies/{taxonomyId}/genomeTypes/", "9606"); @@ -141,8 +138,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest } @Test - @Ignore("Taxonomy database issue") - public void testGetAllGenomeVersions() throws Exception { + public void testDocsGetAllGenomeVersions() throws Exception { RequestBuilder request = get("/minerva/api/genomics/taxonomies/{taxonomyId}/genomeTypes/{genomeType}/versions/", "9606", ReferenceGenomeType.UCSC.name()); @@ -165,11 +161,11 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest List<Object> data = objectMapper.readValue(response, new TypeReference<List<Object>>() { }); - assertTrue(data.size() > 0); + assertFalse(data.isEmpty()); } @Test - public void testGetRemoteUrl() throws Exception { + public void testDocsGetRemoteUrl() throws Exception { RequestBuilder request = get( "/minerva/api/genomics/taxonomies/{taxonomyId}/genomeTypes/{genomeType}/versions/{version}:getAvailableRemoteUrls", @@ -195,11 +191,11 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest List<Object> data = objectMapper.readValue(response, new TypeReference<List<Object>>() { }); - assertTrue(data.size() > 0); + assertFalse(data.isEmpty()); } @Test - public void testDownloadGenomeDataFromRemote() throws Exception { + public void testDocsDownloadGenomeDataFromRemote() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); String body = EntityUtils.toString(new UrlEncodedFormEntity( @@ -207,7 +203,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest new BasicNameValuePair("organismId", ebolaId.getResource()), new BasicNameValuePair("type", ReferenceGenomeType.UCSC.name()), new BasicNameValuePair("version", "eboVir3"), - new BasicNameValuePair("url", "http://minerva-dev.lcsb.uni.lu/eboVir3.2bit")))); + new BasicNameValuePair("url", "https://minerva-dev.lcsb.uni.lu/eboVir3.2bit")))); RequestBuilder request = post("/minerva/api/genomics/") .contentType(MediaType.APPLICATION_FORM_URLENCODED) @@ -228,7 +224,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetDownloadedGenomes() throws Exception { + public void testDocsGetDownloadedGenomes() throws Exception { createGenome(); RequestBuilder request = get("/minerva/api/genomics/"); @@ -242,7 +238,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest .andReturn().getResponse().getContentAsString(); } - private ReferenceGenome createGenome() throws Exception { + private ReferenceGenome createGenome() { ReferenceGenome genome = new ReferenceGenome(); genome.setOrganism(ebolaId); genome.setSourceUrl(ebolaUrl); @@ -260,7 +256,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetGenomeInformation() throws Exception { + public void testDocsGetGenomeInformation() throws Exception { createGenome(); BigFileEntry entry = new BigFileEntry(); @@ -349,7 +345,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void deleteGenomeInformation() throws Exception { + public void testDocsDeleteGenomeInformation() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); ReferenceGenome genome = createGenome(); @@ -390,7 +386,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void addGeneMappingInformation() throws Exception { + public void testDocsAddGeneMappingInformation() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); ReferenceGenome genome = createGenome(); @@ -416,7 +412,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void deleteGeneMappingInformation() throws Exception { + public void testDocsDeleteGeneMappingInformation() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); ReferenceGenome genome = createGenome(); @@ -480,7 +476,7 @@ public class GenomicsControllerIntegrationTest extends ControllerIntegrationTest new BasicNameValuePair("organismId", ""), new BasicNameValuePair("type", ReferenceGenomeType.UCSC.name()), new BasicNameValuePair("version", "eboVir3"), - new BasicNameValuePair("url", "http://minerva-dev.lcsb.uni.lu/eboVir3.2bit")))); + new BasicNameValuePair("url", "https://minerva-dev.lcsb.uni.lu/eboVir3.2bit")))); RequestBuilder request = post("/minerva/api/genomics/") .contentType(MediaType.APPLICATION_FORM_URLENCODED) diff --git a/web/src/test/java/lcsb/mapviewer/web/LicenseControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/LicenseControllerIntegrationTest.java index d2ec2f366aefe41e3429e0076bdc9836a9a54ab0..d037c7046947da34b45fb0e060cff7fc618817a9 100644 --- a/web/src/test/java/lcsb/mapviewer/web/LicenseControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/LicenseControllerIntegrationTest.java @@ -24,7 +24,7 @@ public class LicenseControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testListLicenses() throws Exception { + public void testDocsListLicenses() throws Exception { final RequestBuilder request = get("/minerva/api/licenses/"); diff --git a/web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java index 8547b0cd899eb69073511c34f78f351ec9a4f2b2..39086ea37e9f759e52908a6ae06832c1014cb1ba 100644 --- a/web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java @@ -42,48 +42,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.RequestBuilder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.util.EntityUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -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.FieldDescriptor; -import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.restdocs.payload.ResponseFieldsSnippet; -import org.springframework.restdocs.request.PathParametersSnippet; -import org.springframework.restdocs.request.RequestParametersSnippet; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.RequestBuilder; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -426,7 +384,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testGetAllElementsFilteredByType() throws Exception { + public void testDocsGetAllElementsFilteredByType() throws Exception { RequestBuilder request = get( "/minerva/api/projects/{projectId}/models/{mapId}/bioEntities/elements/?columns=name,complexId&type=Protein", TEST_PROJECT, "*"); @@ -487,7 +445,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testGetAllReactions() throws Exception { + public void testDocsGetAllReactions() throws Exception { RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/bioEntities/reactions/", TEST_PROJECT, "*"); String response = mockMvc.perform(request) @@ -506,7 +464,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testGetAllReactionsWithFilteredColumns() throws Exception { + public void testDocsGetAllReactionsWithFilteredColumns() throws Exception { RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/bioEntities/reactions/?columns=id,notes", TEST_PROJECT, "*"); @@ -529,7 +487,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testSearchBioEntitiesAsAnonymous() throws Exception { + public void testDocsSearchBioEntitiesAsAnonymous() throws Exception { RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/bioEntities:search?coordinates={coords}", TEST_PROJECT, map.getId(), "104.36,182.81"); @@ -610,7 +568,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testSearchBioEntitiesOnEverySubmap() throws Exception { + public void testDocsSearchBioEntitiesOnEverySubmap() throws Exception { Element element = map.getElements().iterator().next(); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/bioEntities:search?query={query}", @@ -683,7 +641,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testSuggestedQueryList() throws Exception { + public void testDocsSuggestedQueryList() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/bioEntities/suggestedQueryList", @@ -763,7 +721,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testUpdateMap() throws Exception { + public void testDocsUpdateMap() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); Double centerX = 10.0; @@ -875,7 +833,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testDownloadImage() throws Exception { + public void testDocsDownloadImage() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}:downloadImage?" @@ -956,7 +914,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testDownloadImageDataOverlay() throws Exception { + public void testDocsDownloadImageDataOverlay() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); DataOverlay overlay = createOverlay(TEST_PROJECT, @@ -1010,7 +968,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testDownloadImagePolygon() throws Exception { + public void testDocsDownloadImagePolygon() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}:downloadImage?" @@ -1072,7 +1030,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest { }); int elements = ((List<?>) result.get("data")).size(); - assertTrue(elements == 1); + assertEquals(1, elements); } @Test diff --git a/web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTestWithGlyph.java b/web/src/test/java/lcsb/mapviewer/web/MapWithGlyphControllerIntegrationTest.java similarity index 94% rename from web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTestWithGlyph.java rename to web/src/test/java/lcsb/mapviewer/web/MapWithGlyphControllerIntegrationTest.java index 23ae3675e8b81b06396fefe19fb66770e1b3a44f..6c73bed9acc6981613baf1049c3b3a4ee31e2e65 100644 --- a/web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTestWithGlyph.java +++ b/web/src/test/java/lcsb/mapviewer/web/MapWithGlyphControllerIntegrationTest.java @@ -1,20 +1,14 @@ package lcsb.mapviewer.web; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.List; -import java.util.Map; - +import com.fasterxml.jackson.core.type.TypeReference; +import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.converter.graphics.PngImageGenerator; +import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; +import lcsb.mapviewer.model.Project; +import lcsb.mapviewer.model.map.model.ModelData; +import lcsb.mapviewer.model.security.PrivilegeType; +import lcsb.mapviewer.model.user.User; +import lcsb.mapviewer.services.interfaces.IUserService; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -25,19 +19,23 @@ import org.springframework.restdocs.request.RequestParametersSnippet; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.RequestBuilder; -import com.fasterxml.jackson.core.type.TypeReference; +import java.util.List; +import java.util.Map; -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.converter.graphics.PngImageGenerator; -import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.model.ModelData; -import lcsb.mapviewer.model.security.PrivilegeType; -import lcsb.mapviewer.model.user.User; -import lcsb.mapviewer.services.interfaces.IUserService; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) -public class MapControllerIntegrationTestWithGlyph extends ControllerIntegrationTest { +public class MapWithGlyphControllerIntegrationTest extends ControllerIntegrationTest { private User anonymous; @@ -76,14 +74,14 @@ public class MapControllerIntegrationTestWithGlyph extends ControllerIntegration RequestBuilder request = get("/minerva/api/projects/" + TEST_PROJECT + "/models/" + map.getId() + ":downloadImage?" + "handlerClass=" + PngImageGenerator.class.getCanonicalName()) - .session(session); + .session(session); mockMvc.perform(request) .andExpect(status().is2xxSuccessful()); } @Test - public void testGetMapsWithForProject() throws Exception { + public void testDocsGetMapsWithForProject() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/", BUILT_IN_PROJECT).session(session); @@ -96,7 +94,7 @@ public class MapControllerIntegrationTestWithGlyph extends ControllerIntegration } @Test - public void testGetAllElements() throws Exception { + public void testDocsGetAllElements() throws Exception { userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId()); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/bioEntities/elements/", TEST_PROJECT, "*"); @@ -118,7 +116,7 @@ public class MapControllerIntegrationTestWithGlyph extends ControllerIntegration } @Test - public void testGetMapById() throws Exception { + public void testDocsGetMapById() throws Exception { userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId()); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}", TEST_PROJECT, map.getId()); @@ -151,13 +149,13 @@ public class MapControllerIntegrationTestWithGlyph extends ControllerIntegration } @Test - public void testDownloadModelByElementList() throws Exception { + public void testDocsDownloadModelByElementList() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}:downloadModel?" + "handlerClass=" + CellDesignerXmlParser.class.getCanonicalName() + "&elementIds=" + map.getElements().iterator().next().getId(), TEST_PROJECT, map.getId()) - .session(session); + .session(session); mockMvc.perform(request) .andDo(document("projects/project_maps/download_with_element_list", @@ -168,12 +166,12 @@ public class MapControllerIntegrationTestWithGlyph extends ControllerIntegration } @Test - public void testDownloadModel() throws Exception { + public void testDocsDownloadModel() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}:downloadModel?" + "handlerClass=" + CellDesignerXmlParser.class.getCanonicalName(), TEST_PROJECT, map.getId()) - .session(session); + .session(session); mockMvc.perform(request) .andDo(document("projects/project_maps/download_model_simple", @@ -198,13 +196,13 @@ public class MapControllerIntegrationTestWithGlyph extends ControllerIntegration } @Test - public void testDownloadModelByPolygon() throws Exception { + public void testDocsDownloadModelByPolygon() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}:downloadModel?" + "handlerClass=" + CellDesignerXmlParser.class.getCanonicalName() + "&polygonString=0,0;100,0;0,100&strictCutoff=false", TEST_PROJECT, map.getId()) - .session(session); + .session(session); mockMvc.perform(request) .andDo(document("projects/project_maps/download_from_polygon", diff --git a/web/src/test/java/lcsb/mapviewer/web/MeshControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/MeshControllerIntegrationTest.java index 5e311400d5d6fbabfb38737395fdb8aebb315e39..6c7ffe2fa4008432d3b1ebe1aa3d2ed8252701a3 100644 --- a/web/src/test/java/lcsb/mapviewer/web/MeshControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/MeshControllerIntegrationTest.java @@ -13,18 +13,6 @@ import org.springframework.test.web.servlet.RequestBuilder; import java.util.Map; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.web.servlet.RequestBuilder; - -import java.util.Map; - import static org.junit.Assert.assertTrue; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; @@ -49,7 +37,7 @@ public class MeshControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testGetMesh() throws Exception { + public void testDocsGetMesh() throws Exception { RequestBuilder request = get("/minerva/api/mesh/{meshId}", "D010300"); diff --git a/web/src/test/java/lcsb/mapviewer/web/OverlayControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/OverlayControllerIntegrationTest.java index 95a71410de0e1850b4b74e55a5764218e8e5ae00..6dd0ad29820357f0138b691d8e6f6e553abd8593 100644 --- a/web/src/test/java/lcsb/mapviewer/web/OverlayControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/OverlayControllerIntegrationTest.java @@ -102,7 +102,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testListOverlaysByCreator() throws Exception { + public void testDocsListOverlaysByCreator() throws Exception { createOverlay(TEST_PROJECT, user); @@ -153,7 +153,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testCuratorShouldSeeAllOverlays() throws Exception { + public void testDocsCuratorShouldSeeAllOverlays() throws Exception { final DataOverlay layout = createOverlay(TEST_PROJECT, project.getOwner()); layout.setPublic(true); @@ -225,7 +225,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAdminCanAccessUserOverlay() throws Exception { + public void testDocsAdminCanAccessUserOverlay() throws Exception { final DataOverlay overlay = createOverlay(TEST_PROJECT, user); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -280,7 +280,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetBioEntitiesForOverlay() throws Exception { + public void testDocsGetBioEntitiesForOverlay() throws Exception { final ModelData submap = map.getSubmodels().iterator().next().getSubmodel(); final String content = createOverlayContentForAllEntities(map); final DataOverlay overlay = createOverlay(project, user, content); @@ -456,7 +456,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetReactionForOverlay() throws Exception { + public void testDocsGetReactionForOverlay() throws Exception { final DataOverlay overlay = createOverlay(user); final MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD); @@ -501,7 +501,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetReactionForOverlayWithColor() throws Exception { + public void testDocsGetReactionForOverlayWithColor() throws Exception { final DataOverlay overlay = createOverlayWithColor(project, user); final MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD); @@ -550,7 +550,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetElementsForOverlay() throws Exception { + public void testDocsGetElementsForOverlay() throws Exception { final User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN); final DataOverlay overlay = createOverlay(admin); @@ -600,7 +600,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAdminCreateOverlay() throws Exception { + public void testDocsAdminCreateOverlay() throws Exception { final User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN); final UploadedFileEntry file = createFile("element_identifier\tvalue\n\t-1", admin); @@ -630,7 +630,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAdminCreateOverlayFromContent() throws Exception { + public void testDocsAdminCreateOverlayFromContent() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList( @@ -731,7 +731,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAdminCanRemoveOverlay() throws Exception { + public void testDocsAdminCanRemoveOverlay() throws Exception { final DataOverlay overlay = createOverlay(user); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -788,7 +788,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAdminCanUpdateOverlay() throws Exception { + public void testDocsAdminCanUpdateOverlay() throws Exception { final DataOverlay overlay = createOverlay(user); final Map<String, Object> updateOverlay = @@ -883,7 +883,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testAdminCanAccessOverlaySource() throws Exception { + public void testDocsAdminCanAccessOverlaySource() throws Exception { final DataOverlay overlay = createOverlay(user); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -1668,7 +1668,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testDownloadOverlayLegend() throws Exception { + public void testDocsDownloadOverlayLegend() throws Exception { final DataOverlay overlay = createOverlay(user); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); diff --git a/web/src/test/java/lcsb/mapviewer/web/ParameterControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/ParameterControllerIntegrationTest.java index 2f2d0214d47aa9ec9e59b073f454ee3a817e0c4c..ecaaf997fd40fb9b866bacc7cee04bc52c129057 100644 --- a/web/src/test/java/lcsb/mapviewer/web/ParameterControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/ParameterControllerIntegrationTest.java @@ -72,7 +72,7 @@ public class ParameterControllerIntegrationTest extends ControllerIntegrationTes } @Test - public void testGetParameters() throws Exception { + public void testDocsGetParameters() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/parameters/", TEST_PROJECT, "*") @@ -87,7 +87,7 @@ public class ParameterControllerIntegrationTest extends ControllerIntegrationTes } @Test - public void testGetParameter() throws Exception { + public void testDocsGetParameter() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/parameters/{parameterId}", TEST_PROJECT, "*", diff --git a/web/src/test/java/lcsb/mapviewer/web/PluginControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/PluginControllerIntegrationTest.java index 6d5f2947b8baae8596740b32ed8eb2fef9f76f69..505ea66f20d15fc20fe3665672e07b310e1a41f7 100644 --- a/web/src/test/java/lcsb/mapviewer/web/PluginControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/PluginControllerIntegrationTest.java @@ -70,7 +70,7 @@ public class PluginControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void listPlugins() throws Exception { + public void testDocsListPlugins() throws Exception { createPlugin(); RequestBuilder request = get("/minerva/api/plugins/"); @@ -104,7 +104,7 @@ public class PluginControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void createPublicPluginWithPrivileges() throws Exception { + public void testDocsCreatePublicPluginWithPrivileges() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList( @@ -146,7 +146,7 @@ public class PluginControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void getPluginInfo() throws Exception { + public void testDocsGetPluginInfo() throws Exception { Plugin plugin = createPlugin(); RequestBuilder request = get("/minerva/api/plugins/{hash}", plugin.getHash()); @@ -246,7 +246,7 @@ public class PluginControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void setAndGetGlobalPluginData() throws Exception { + public void testDocsTestDocsSetAndGetGlobalPluginData() throws Exception { String body = "value=xxx"; Plugin plugin = createPlugin(); @@ -279,7 +279,7 @@ public class PluginControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void setAndGetUserPluginData() throws Exception { + public void testDocsSetAndGetUserPluginData() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_LOGIN); String body = "value=xxx"; diff --git a/web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationForDocsTest.java b/web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationForDocsTest.java index 574fc65d93564e434735119f85a0696398a30cc5..93f54874aa2e87f61b55d36fd3135611df24ae0e 100644 --- a/web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationForDocsTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationForDocsTest.java @@ -75,7 +75,7 @@ public class ProjectControllerIntegrationForDocsTest extends ControllerIntegrati } @Test - public void addComplexProjectAsCurator() throws Exception { + public void testDocsAddComplexProjectAsCurator() throws Exception { User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN); try { UploadedFileEntry fileEntry = createFile( @@ -144,7 +144,7 @@ public class ProjectControllerIntegrationForDocsTest extends ControllerIntegrati } @Test - public void addProjectAsCurator() throws Exception { + public void testDocsAddProjectAsCurator() throws Exception { User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN); try { UploadedFileEntry fileEntry = createFile( diff --git a/web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTest.java index 29819fe5e649b8e86f2b6fb61ca03bc723b7571b..3b42686a9406118e880c45a247785677c0d2057b 100644 --- a/web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTest.java @@ -115,7 +115,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetAllProjectsAsAdmin() throws Exception { + public void testDocsGetAllProjectsAsAdmin() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/api/projects/") .session(session); @@ -139,7 +139,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetSourceFile() throws Exception { + public void testDocsGetSourceFile() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createAndPersistProject(TEST_PROJECT); final RequestBuilder request = get("/minerva/api/projects/{projectId}:downloadSource", TEST_PROJECT) @@ -176,7 +176,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetLimitedProjectsAsGuest() throws Exception { + public void testDocsGetLimitedProjectsAsGuest() throws Exception { final Project project2 = new Project(TEST_PROJECT_2); project2.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN)); projectService.add(project2); @@ -198,7 +198,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testUserPrivilegesChangeDuringActiveSession() throws Exception { + public void testDocsUserPrivilegesChangeDuringActiveSession() throws Exception { final MockHttpSession session = createSession(CURATOR_LOGIN, CURATOR_PASSWORD); final Project project = createAndPersistProject(TEST_PROJECT); @@ -216,7 +216,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetLogsForProject() throws Exception { + public void testDocsGetLogsForProject() throws Exception { final Project project = createAndPersistProject(TEST_PROJECT); userService.grantUserPrivilege(curator, PrivilegeType.READ_PROJECT, project.getProjectId()); @@ -258,7 +258,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetStatisticsForProject() throws Exception { + public void testDocsGetStatisticsForProject() throws Exception { createAndPersistProject(TEST_PROJECT); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -281,7 +281,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGrantPrivilege() throws Exception { + public void testDocsGrantPrivilege() throws Exception { createAndPersistProject(TEST_PROJECT); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -316,7 +316,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testRevokePrivilege() throws Exception { + public void testDocsRevokePrivilege() throws Exception { final Project project = createAndPersistProject(TEST_PROJECT); userService.grantUserPrivilege(curator, PrivilegeType.READ_PROJECT, project.getProjectId()); @@ -362,7 +362,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testUpdateProject() throws Exception { + public void testDocsUpdateProject() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createAndPersistProject(TEST_PROJECT); @@ -596,7 +596,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetSubmapConnectionsForProject() throws Exception { + public void testDocsGetSubmapConnectionsForProject() throws Exception { createAndPersistProject(TEST_PROJECT); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -721,7 +721,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test(timeout = 10000) - public void removeProjectWithUsedFile() throws Exception { + public void testDocsRemoveProjectWithUsedFile() throws Exception { final User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN); try { createFullProject(admin); @@ -884,7 +884,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetBackgrounds() throws Exception { + public void testDocsGetBackgrounds() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createAndPersistProject(TEST_PROJECT); final RequestBuilder request = get("/minerva/api/projects/{projectId}/backgrounds/", TEST_PROJECT) @@ -966,7 +966,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testGetBackgroundById() throws Exception { + public void testDocsGetBackgroundById() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final Project project = createAndPersistProject(TEST_PROJECT); final RequestBuilder request = get("/minerva/api/projects/{projectId}/backgrounds/{backgroundId}", TEST_PROJECT, @@ -980,7 +980,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testUpdateBackgroundById() throws Exception { + public void testDocsUpdateBackgroundById() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final Project project = createAndPersistProject(TEST_PROJECT); final ProjectBackground background = new ProjectBackground("weird_title"); @@ -1011,7 +1011,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testRemoveBackgroundById() throws Exception { + public void testDocsRemoveBackgroundById() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN); @@ -1343,7 +1343,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testArchiveProject() throws Exception { + public void testDocsArchiveProject() throws Exception { final Project project = createProjectWithBackground(); final String projectHomeDir = projectService.getProjectHomeDir(project); @@ -1397,7 +1397,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest } @Test - public void testReviveProject() throws Exception { + public void testDocsReviveProject() throws Exception { final Project project = createAndPersistProject(TEST_PROJECT); project.setStatus(ProjectStatus.ARCHIVED); project.removeProjectBackground(project.getProjectBackgrounds().get(0)); diff --git a/web/src/test/java/lcsb/mapviewer/web/PublicationsControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/PublicationsControllerIntegrationTest.java index a87d5e2b98ce883b1d1b0fc47977a20246e9ed34..0cf0805e0d59c905f53607e9e7196d7967dddaa5 100644 --- a/web/src/test/java/lcsb/mapviewer/web/PublicationsControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/PublicationsControllerIntegrationTest.java @@ -43,7 +43,7 @@ public class PublicationsControllerIntegrationTest extends ControllerIntegration } @Test - public void testGetPublicationsForMap() throws Exception { + public void testDocsGetPublicationsForMap() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/publications/", TEST_PROJECT, map.getId()) diff --git a/web/src/test/java/lcsb/mapviewer/web/TaxonomiesControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/TaxonomiesControllerIntegrationTest.java index 665cc216f551c53b2618b43e8dc3b75b06fc7195..e965ed0e884639e0e45713341e7c1c8a542281c3 100644 --- a/web/src/test/java/lcsb/mapviewer/web/TaxonomiesControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/TaxonomiesControllerIntegrationTest.java @@ -1,13 +1,5 @@ package lcsb.mapviewer.web; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -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.pathParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -16,6 +8,14 @@ import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.RequestBuilder; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +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.pathParameters; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @RunWith(SpringJUnit4ClassRunner.class) public class TaxonomiesControllerIntegrationTest extends ControllerIntegrationTest { @@ -28,7 +28,7 @@ public class TaxonomiesControllerIntegrationTest extends ControllerIntegrationTe } @Test - public void testGetTaxonomy() throws Exception { + public void testDocsGetTaxonomy() throws Exception { RequestBuilder request = get("/minerva/api/taxonomy/{taxonomyId}/", "9606"); diff --git a/web/src/test/java/lcsb/mapviewer/web/UnitsControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/UnitsControllerIntegrationTest.java index 4d171768d8ec278745ee0eaa832a1bd4055de22b..01eeba221cda5faff91fd3ec3c8185ac5a72de76 100644 --- a/web/src/test/java/lcsb/mapviewer/web/UnitsControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/UnitsControllerIntegrationTest.java @@ -1,17 +1,7 @@ package lcsb.mapviewer.web; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; -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 java.util.Arrays; -import java.util.List; - +import lcsb.mapviewer.model.Project; +import lcsb.mapviewer.model.map.model.ModelData; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -23,8 +13,17 @@ import org.springframework.restdocs.payload.ResponseFieldsSnippet; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.RequestBuilder; -import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.model.ModelData; +import java.util.Arrays; +import java.util.List; + +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; +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; @RunWith(SpringJUnit4ClassRunner.class) public class UnitsControllerIntegrationTest extends ControllerIntegrationTest { @@ -66,7 +65,7 @@ public class UnitsControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testGetUnits() throws Exception { + public void testDocsGetUnits() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/units/", TEST_PROJECT, "*") @@ -81,12 +80,12 @@ public class UnitsControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testGetUnit() throws Exception { + public void testDocsGetUnit() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/projects/{projectId}/models/{mapId}/units/{unitId}", TEST_PROJECT, "*", map.getUnits().iterator().next().getId()) - .session(session); + .session(session); mockMvc.perform(request) .andDo(document("projects/project_maps/get_unit", @@ -117,7 +116,7 @@ public class UnitsControllerIntegrationTest extends ControllerIntegrationTest { private ResponseFieldsSnippet listOfUnitsFields() { return responseFields( fieldWithPath("[]").description("list of units")) - .andWithPrefix("[].", unitFields()); + .andWithPrefix("[].", unitFields()); } } diff --git a/web/src/test/java/lcsb/mapviewer/web/UserControllerAnonymousIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/UserControllerAnonymousIntegrationTest.java index b60a5c673370d2e415d9f4dfc0fe67e935140fd1..08244ac91ae8fe14053ce300892f0ca7dc5aa9cb 100644 --- a/web/src/test/java/lcsb/mapviewer/web/UserControllerAnonymousIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/UserControllerAnonymousIntegrationTest.java @@ -97,7 +97,7 @@ public class UserControllerAnonymousIntegrationTest extends ControllerIntegratio } @Test - public void checkIsAuthenticatedAdmin() throws Exception { + public void testDocsCheckIsAuthenticatedAdmin() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/users/isSessionValid") @@ -131,7 +131,7 @@ public class UserControllerAnonymousIntegrationTest extends ControllerIntegratio } @Test - public void testLogin() throws Exception { + public void testDocsLogin() throws Exception { RequestBuilder request = post("/minerva/api/doLogin") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .content("login=" + BUILT_IN_TEST_ADMIN_LOGIN + "&password=" + BUILT_IN_TEST_ADMIN_PASSWORD); @@ -150,7 +150,7 @@ public class UserControllerAnonymousIntegrationTest extends ControllerIntegratio } @Test - public void testLogout() throws Exception { + public void testDocsLogout() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = post("/minerva/api/doLogout") diff --git a/web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationTest.java b/web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationTest.java index d8a03626b9c9ea62ab5c70a41a09f86bddc40e25..c3f2d496aeb7a4033e7c4cff10f6a5052a8a840b 100644 --- a/web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationTest.java @@ -115,7 +115,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void grantPrivilege() throws Exception { + public void testDocsGrantPrivilege() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); UserPrivilegesDTO data = new UserPrivilegesDTO(); @@ -184,7 +184,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void grantProjectPrivilege() throws Exception { + public void testDocsGrantProjectPrivilege() throws Exception { Project project = new Project(TEST_PROJECT); project.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN)); projectService.add(project); @@ -296,7 +296,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void fetchUserPrivilege() throws Exception { + public void testDocsFetchUserPrivilege() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/api/users/{login}", TEST_USER_LOGIN) @@ -407,7 +407,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testAddUser() throws Exception { + public void testDocsAddUser() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList( @@ -490,7 +490,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void userUpdateOwnPassword() throws Exception { + public void testDocsUserUpdateOwnPassword() throws Exception { MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD); String newPassword = "new pass"; @@ -633,7 +633,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void removeUserWithLayouts() throws Exception { + public void testDocsRemoveUserWithLayouts() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); Project project = new Project(TEST_PROJECT); @@ -675,7 +675,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void testGetUsers() throws Exception { + public void testDocsGetUsers() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder grantRequest = get("/minerva/api/users/") @@ -846,7 +846,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void updateProjectUploadPreferences() throws Exception { + public void testDocsUpdateProjectUploadPreferences() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); UserAnnotationSchema preferences = new UserAnnotationSchema(); @@ -874,7 +874,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void updateElementAnnotatorsPreferences() throws Exception { + public void testDocsUpdateElementAnnotatorsPreferences() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); UserAnnotationSchema preferences = new UserAnnotationSchema(); @@ -912,7 +912,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void updateGuiPreferences() throws Exception { + public void testDocsUpdateGuiPreferences() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); UserAnnotationSchema preferences = new UserAnnotationSchema(); @@ -1128,7 +1128,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest { } @Test - public void registerNewUser() throws Exception { + public void testDocsRegisterNewUser() throws Exception { try { configurationService.setConfigurationValue(ConfigurationElementType.MINERVA_ROOT, "https://minerva-dev.lcsb.uni.lu/minerva/"); diff --git a/web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationTestWithoutTransaction.java b/web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationWithoutTransactionTest.java similarity index 96% rename from web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationTestWithoutTransaction.java rename to web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationWithoutTransactionTest.java index e8e4923cd466d15e01cdcd9df91eb30bf4503e85..1425ffe6e6da73bdca9616e46a16735637858256 100644 --- a/web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationTestWithoutTransaction.java +++ b/web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationWithoutTransactionTest.java @@ -48,7 +48,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringJUnit4ClassRunner.class) @Rollback @ActiveProfiles("EmailSenderEnabledEmailProfile") -public class UserControllerIntegrationTestWithoutTransaction extends ControllerIntegrationTest { +public class UserControllerIntegrationWithoutTransactionTest extends ControllerIntegrationTest { private static final String TEST_USER_LOGIN_2 = "test_user2"; @@ -141,7 +141,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI final int status = mockMvc.perform(request).andReturn().getResponse().getStatus(); assertNotEquals(500, status); } catch (final Throwable e) { - e.printStackTrace(); + logger.error(e, e); exceptionHappened.setTrue(); } } @@ -203,7 +203,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI public void requestResetPasswordForUnknownUser() throws Exception { configureServerForResetPasswordRequest(); - final RequestBuilder grantRequest = post("/minerva/api/users/blabla:requestResetPassword"); + final RequestBuilder grantRequest = post("/minerva/api/users/blah:requestResetPassword"); mockMvc.perform(grantRequest) .andExpect(status().is4xxClientError()); @@ -211,7 +211,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI } @Test - public void resetPassword() throws Exception { + public void testDocsResetPassword() throws Exception { configureServerForResetPasswordRequest(); final String newPassword = "pass2"; @@ -284,7 +284,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI } @Test - public void confirmReigstrationOfNewUser() throws Exception { + public void testDocsConfirmRegistrationOfNewUser() throws Exception { configureServerForResetPasswordRequest(); User user = userService.getUserByLogin(TEST_USER_LOGIN); @@ -342,7 +342,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI } @Test - public void confirmReigstrationOfNewUserWithNotRequiredApproval() throws Exception { + public void confirmRegistrationOfNewUserWithNotRequiredApproval() throws Exception { configureServerForResetPasswordRequest(); configurationService.setConfigurationValue(ConfigurationElementType.REQUIRE_APPROVAL_FOR_AUTO_REGISTERED_USERS, "false"); @@ -379,7 +379,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI configurationService.setConfigurationValue(ConfigurationElementType.ALLOW_AUTO_REGISTER, "true"); final Map<String, Object> data = new HashMap<>(); data.put("email", "blah"); - data.put("password", "123qweasdzxc"); + data.put("password", "123blah"); data.put("name", "Piotr"); data.put("surname", "Gawron"); @@ -393,7 +393,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI } @Test - public void confirmReigstrationOfNewUserWithInvlaidToken() throws Exception { + public void confirmRegistrationOfNewUserWithInvalidToken() throws Exception { configureServerForResetPasswordRequest(); User user = userService.getUserByLogin(TEST_USER_LOGIN); @@ -419,7 +419,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI } @Test - public void resetPasswordWithExpredToken() throws Exception { + public void resetPasswordWithExpiredToken() throws Exception { configureServerForResetPasswordRequest(); final Calendar expires = Calendar.getInstance(); @@ -441,7 +441,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI } @Test - public void requestResetPassword() throws Exception { + public void testDocsRequestResetPassword() throws Exception { final long count = userService.getPasswordTokenCount(); configureServerForResetPasswordRequest(); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/NewApiDocs.java b/web/src/test/java/lcsb/mapviewer/web/api/NewApiDocs.java index f09af5dd47ed71b1b883efc969018f314108b1b8..ad3c9406ca953663e2d65d5b662f2c727fe25061 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/NewApiDocs.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/NewApiDocs.java @@ -10,6 +10,7 @@ import org.apache.logging.log4j.Logger; import org.springframework.restdocs.payload.FieldDescriptor; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.restdocs.payload.RequestFieldsSnippet; +import org.springframework.restdocs.request.ParameterDescriptor; import org.springframework.restdocs.request.RequestParametersSnippet; import org.springframework.restdocs.snippet.Snippet; @@ -54,6 +55,10 @@ public class NewApiDocs { return new NewApiDocs().getProjectFields(prefix); } + public static List<FieldDescriptor> getJobResponse(final String prefix) { + return new NewApiDocs().getJobFields(prefix); + } + public static List<FieldDescriptor> getUserResponse(final String prefix) { return new NewApiDocs().getUserFields(prefix); } @@ -118,6 +123,46 @@ public class NewApiDocs { .optional()); } + public static RequestFieldsSnippet getCreateProjectFields() { + return requestFields( + fieldWithPath("projectId") + .type(JsonFieldType.STRING) + .description("project identifier"), + fieldWithPath("name") + .type(JsonFieldType.STRING) + .description("name"), + fieldWithPath("version") + .type(JsonFieldType.STRING) + .description("version"), + fieldWithPath("notifyEmail") + .type(JsonFieldType.STRING) + .description("email used for notifications about this project"), + fieldWithPath("sbgnFormat") + .type(JsonFieldType.BOOLEAN) + .description("should the project be visualized using sbgn standard") + ); + } + + public static RequestFieldsSnippet getUpdateProjectFields() { + return requestFields( + fieldWithPath("projectId") + .type(JsonFieldType.STRING) + .description("project identifier"), + fieldWithPath("name") + .type(JsonFieldType.STRING) + .description("name"), + fieldWithPath("version") + .type(JsonFieldType.STRING) + .description("version"), + fieldWithPath("notifyEmail") + .type(JsonFieldType.STRING) + .description("email used for notifications about this project"), + fieldWithPath("sbgnFormat") + .type(JsonFieldType.BOOLEAN) + .description("should the project be visualized using sbgn standard") + ); + } + public static RequestFieldsSnippet getReactionCsvRequest() { return requestFields(new NewApiDocs().getReactionCsvFields()); } @@ -172,6 +217,112 @@ public class NewApiDocs { ); } + public static RequestFieldsSnippet getAddUserRequest() { + return requestFields( + fieldWithPath("name") + .description("first name") + .type(JsonFieldType.STRING), + fieldWithPath("surname") + .description("family name") + .type(JsonFieldType.STRING), + fieldWithPath("login") + .description("login") + .type(JsonFieldType.STRING), + fieldWithPath("orcidId") + .description("orcid identifier (https://orcid.org/)") + .optional() + .type(JsonFieldType.STRING), + fieldWithPath("password") + .description("password") + .type(JsonFieldType.STRING), + fieldWithPath("email") + .description("email") + .type(JsonFieldType.STRING), + fieldWithPath("connectedToLdap") + .description("is the account connected to ldap") + .type(JsonFieldType.BOOLEAN), + fieldWithPath("active") + .description("is active") + .type(JsonFieldType.BOOLEAN), + fieldWithPath("termsOfUseConsent") + .description("did user consent to the terms of use") + .type(JsonFieldType.BOOLEAN) + ); + } + + public static RequestFieldsSnippet getAddPluginRequest() { + return requestFields( + fieldWithPath("name") + .description("name") + .type(JsonFieldType.STRING), + fieldWithPath("version") + .description("version of the plugin") + .type(JsonFieldType.STRING), + fieldWithPath("url") + .description("location of the javascript file") + .type(JsonFieldType.STRING), + fieldWithPath("public") + .description("should the plugin be listed in the browser") + .type(JsonFieldType.BOOLEAN), + fieldWithPath("default") + .description("should the plugin be loaded by default when opening diagram browser") + .optional() + .type(JsonFieldType.BOOLEAN), + fieldWithPath("hash") + .description("hash of plugin javascript file") + .type(JsonFieldType.STRING) + ); + } + + public static RequestFieldsSnippet getGrantUserPrivilegeRequest() { + return requestFields( + fieldWithPath("privilegeType") + .description("typo of privilege") + .type(JsonFieldType.STRING), + fieldWithPath("objectId") + .description("referenced object id (if necessary)") + .optional() + .type(JsonFieldType.STRING) + ); + } + + public static RequestFieldsSnippet getRegisterUserRequest() { + return requestFields( + fieldWithPath("email") + .description("user email (and login)") + .type(JsonFieldType.STRING), + fieldWithPath("login") + .ignored(), + fieldWithPath("orcidId") + .ignored(), + fieldWithPath("connectedToLdap") + .ignored(), + fieldWithPath("active") + .ignored(), + fieldWithPath("termsOfUseConsent") + .ignored(), + fieldWithPath("password") + .description("password") + .type(JsonFieldType.STRING), + fieldWithPath("name") + .description("given name)") + .type(JsonFieldType.STRING), + fieldWithPath("surname") + .description("family name") + .type(JsonFieldType.STRING)); + } + + public static RequestFieldsSnippet getPasswordResetRequest() { + return requestFields( + fieldWithPath("password") + .description("new password") + .type(JsonFieldType.STRING), + fieldWithPath("token") + .description("reset password token obtained using email") + .type(JsonFieldType.STRING) + ); + } + public static RequestFieldsSnippet getAddDataOverlayGroupRequest() { return requestFields( fieldWithPath("name") @@ -272,6 +423,26 @@ public class NewApiDocs { ); } + public static List<ParameterDescriptor> getLogsSearchFilter() { + return Arrays.asList( + parameterWithName("level") + .description("warning level") + .optional(), + parameterWithName("sort") + .description("sort order") + .optional(), + parameterWithName("LEVEL.dir") + .ignored() + .description("sort order direction"), + parameterWithName("<SORT>.dir") + .optional() + .description("sort order direction"), + parameterWithName("search") + .optional() + .description("search query") + ); + } + private List<FieldDescriptor> getOverlayBioEntityPairFields(final String prefix) { final List<FieldDescriptor> result = new ArrayList<>(); result.addAll(Arrays.asList( @@ -1124,6 +1295,7 @@ public class NewApiDocs { .type(JsonFieldType.STRING), fieldWithPath(prefix + "topMap.id") .description("id of the top map") + .optional() .type(JsonFieldType.NUMBER), fieldWithPath(prefix + "logEntries") .description("flag indicating that there are log entries attached to the project") @@ -1138,6 +1310,31 @@ public class NewApiDocs { .optional()); } + public List<FieldDescriptor> getJobFields(final String prefix) { + return Arrays.asList( + fieldWithPath(prefix + "id") + .description("job id") + .type(JsonFieldType.NUMBER), + fieldWithPath(prefix + "jobType") + .description("job type") + .type(JsonFieldType.STRING), + fieldWithPath(prefix + "jobStatus") + .description("job status") + .type(JsonFieldType.STRING), + fieldWithPath(prefix + "jobStarted") + .description("when the job execution started") + .optional() + .type(JsonFieldType.STRING), + fieldWithPath(prefix + "jobFinished") + .description("when the job execution finished") + .optional() + .type(JsonFieldType.STRING), + fieldWithPath(prefix + "priority") + .description("job priority (1 is the highest priority)") + .type(JsonFieldType.NUMBER) + ); + } + public List<FieldDescriptor> getUserFields(final String prefix) { return Arrays.asList( fieldWithPath(prefix + "id") @@ -1218,6 +1415,38 @@ public class NewApiDocs { ); } + public List<FieldDescriptor> getProjectLogFields(final String prefix) { + return Arrays.asList( + subsectionWithPath(prefix + "id") + .description("log entry id") + .type(JsonFieldType.NUMBER), + subsectionWithPath(prefix + "content") + .description("log entry content") + .type(JsonFieldType.STRING), + subsectionWithPath(prefix + "severity") + .description("log entry level") + .type(JsonFieldType.STRING), + subsectionWithPath(prefix + "type") + .description("type of the entry") + .type(JsonFieldType.STRING), + subsectionWithPath(prefix + "objectIdentifier") + .description("element identifier related to the log entry") + .optional() + .type(JsonFieldType.STRING), + subsectionWithPath(prefix + "objectClass") + .description("element identifier type related to the log entry") + .optional() + .type(JsonFieldType.STRING), + subsectionWithPath(prefix + "mapName") + .description("map name where element is located") + .type(JsonFieldType.STRING), + subsectionWithPath(prefix + "source") + .description("which module reported the error") + .optional() + .type(JsonFieldType.STRING) + ); + } + public List<FieldDescriptor> getPluginFields(final String prefix) { return Arrays.asList( fieldWithPath(prefix + "hash") @@ -1509,6 +1738,65 @@ public class NewApiDocs { return responseFields(fields); } + public static Snippet getPluginsSearchResult() { + final String prefix = "content[]."; + final List<FieldDescriptor> fields = new ArrayList<>(); + fields.add(fieldWithPath("content") + .description("list of plugins on the page") + .type(JsonFieldType.ARRAY)); + fields.addAll(getPluginResponse(prefix)); + fields.addAll(getPageableFields()); + return responseFields(fields); + } + + public static Snippet getLayerImagesSearchResult() { + final String prefix = "content[]."; + final List<FieldDescriptor> fields = new ArrayList<>(); + fields.add(fieldWithPath("content") + .description("list of layer images on the page") + .type(JsonFieldType.ARRAY)); + fields.addAll(getLayerImageResponse(prefix)); + fields.addAll(getPageableFields()); + return responseFields(fields); + } + + public static Snippet getLayerTextsSearchResult() { + final String prefix = "content[]."; + final List<FieldDescriptor> fields = new ArrayList<>(); + fields.add(fieldWithPath("content") + .description("list of layer texts on the page") + .type(JsonFieldType.ARRAY)); + fields.addAll(getLayerTextResponse(prefix)); + fields.addAll(getPageableFields()); + return responseFields(fields); + } + + public static Snippet getProjectsSearchResult() { + final String prefix = "content[]."; + final List<FieldDescriptor> fields = new ArrayList<>(); + fields.add(fieldWithPath("content") + .description("list of projects on the page") + .type(JsonFieldType.ARRAY)); + fields.addAll(getProjectResponse(prefix)); + fields.addAll(getPageableFields()); + return responseFields(fields); + } + + public static Snippet getProjectLogsSearchResult() { + final String prefix = "content[]."; + final List<FieldDescriptor> fields = new ArrayList<>(); + fields.add(fieldWithPath("content") + .description("list of projects on the page") + .type(JsonFieldType.ARRAY)); + fields.addAll(getProjectLogResponse(prefix)); + fields.addAll(getPageableFields()); + return responseFields(fields); + } + + public static List<FieldDescriptor> getProjectLogResponse(final String prefix) { + return new NewApiDocs().getProjectLogFields(prefix); + } + public static Snippet getUserSearchResult() { final String prefix = "content[]."; final List<FieldDescriptor> fields = new ArrayList<>(); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/plugin/NewPluginControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/plugin/NewPluginControllerTest.java index 2fefda636c93b71a406a9f0e01fb87d33c41fe8d..7d7ad5c1023a5872cea9b14a65a2d51559d27e36 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/plugin/NewPluginControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/plugin/NewPluginControllerTest.java @@ -1,5 +1,6 @@ package lcsb.mapviewer.web.api.plugin; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import lcsb.mapviewer.model.plugin.Plugin; import lcsb.mapviewer.services.interfaces.IPluginService; @@ -11,6 +12,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; import org.springframework.http.MediaType; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpSession; @@ -19,6 +21,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.RequestBuilder; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -30,6 +34,7 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuild import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @@ -48,23 +53,27 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { private ObjectMapper objectMapper; + private List<String> pluginHashes = new ArrayList<>(); + @Before public void setUp() throws Exception { objectMapper = newApiResponseSerializer.getObjectMapper(); + pluginHashes = new ArrayList<>(); } @After public void tearDown() throws Exception { - Plugin plugin = pluginService.getByHash(PLUGIN_HASH); - if (plugin != null) { - pluginService.delete(plugin); + for (String hash : pluginHashes) { + Plugin plugin = pluginService.getByHash(hash); + if (plugin != null) { + pluginService.delete(plugin); + } } } @Test - public void testGetPlugin() throws Exception { - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + public void testDocsGetPlugin() throws Exception { + Plugin plugin = createAndPersistPlugin(PLUGIN_HASH); final RequestBuilder request = get("/minerva/new_api/plugins/{hash}", plugin.getHash()); @@ -76,11 +85,17 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { .andExpect(status().is2xxSuccessful()); } + private Plugin createAndPersistPlugin(final String hash) { + Plugin plugin = createPlugin(hash); + persistPlugin(plugin); + return plugin; + } + private static Plugin createPlugin(final String hash) { Plugin plugin = new Plugin(); plugin.setHash(hash); - plugin.setName("plugin"); - plugin.setVersion("1.0.0"); + plugin.setName(faker.name().name()); + plugin.setVersion(faker.number().digit() + "." + faker.number().digit() + "." + faker.number().digit()); return plugin; } @@ -93,7 +108,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { } @Test - public void testCreatePlugin() throws Exception { + public void testDocsCreatePlugin() throws Exception { final NewPluginDTO data = createPluginDTO(PLUGIN_HASH); final RequestBuilder request = post("/minerva/new_api/plugins/") @@ -102,6 +117,10 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { final MockHttpServletResponse response = mockMvc.perform(request) .andExpect(status().isCreated()) + .andDo(document("new_api/plugins/create_plugin", + pathParameters(), + NewApiDocs.getAddPluginRequest(), + responseFields(NewApiDocs.getPluginResponse("")))) .andReturn().getResponse(); assertNotNull(response.getHeader("ETag")); @@ -122,8 +141,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { @Test public void testCreatePluginExisting() throws Exception { - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + createAndPersistPlugin(PLUGIN_HASH); final NewPluginDTO data = createPluginDTO(PLUGIN_HASH); @@ -140,8 +158,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + createAndPersistPlugin(PLUGIN_HASH); final NewPluginDTO data = createPluginDTO(PLUGIN_HASH); @@ -155,7 +172,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { .andReturn().getResponse(); assertNotNull(response.getHeader("ETag")); - plugin = pluginService.getByHash(PLUGIN_HASH); + Plugin plugin = pluginService.getByHash(PLUGIN_HASH); assertEquals(data.getVersion(), plugin.getVersion()); } @@ -164,8 +181,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { public void testUpdatePluginWithMissingData() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + createAndPersistPlugin(PLUGIN_HASH); final NewPluginDTO data = createPluginDTO(PLUGIN_HASH); data.setName(null); @@ -183,8 +199,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { public void testUpdatePluginWithOldVersion() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + createAndPersistPlugin(PLUGIN_HASH); final NewPluginDTO data = createPluginDTO(PLUGIN_HASH); @@ -202,8 +217,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { public void testUpdatePluginWithGoodVersion() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + Plugin plugin = createAndPersistPlugin(PLUGIN_HASH); String originalVersion = plugin.getEntityVersion() + ""; @@ -228,10 +242,9 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { private NewPluginDTO createPluginDTO(final String hash) { final NewPluginDTO data = new NewPluginDTO(); - data.setName("my name"); + data.setName(faker.name().name()); data.setHash(hash); - data.setName("starter-kit"); - data.setVersion("0.0.1"); + data.setVersion(faker.number().digit() + "." + faker.number().digit() + "." + faker.number().digit()); data.setUrl(PLUGIN_URL); return data; } @@ -241,8 +254,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { public void testDeletePlugin() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + createAndPersistPlugin(PLUGIN_HASH); final RequestBuilder request = delete("/minerva/new_api/plugins/{pluginId}/", PLUGIN_HASH) .session(session); @@ -267,8 +279,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { @Test public void testDeleteNoAccessPlugin() throws Exception { - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + createAndPersistPlugin(PLUGIN_HASH); final RequestBuilder request = delete("/minerva/new_api/plugins/{pluginId}/", PLUGIN_HASH); @@ -280,8 +291,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { public void testDeletePluginWithGoodVersion() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + Plugin plugin = createAndPersistPlugin(PLUGIN_HASH); final String originalVersion = plugin.getEntityVersion() + ""; @@ -297,8 +307,7 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { public void testDeletePluginWithWrongVersion() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); - Plugin plugin = createPlugin(PLUGIN_HASH); - pluginService.add(plugin); + createAndPersistPlugin(PLUGIN_HASH); final RequestBuilder request = delete("/minerva/new_api/plugins/{pluginId}/", PLUGIN_HASH) .header("If-Match", "-1") @@ -309,10 +318,39 @@ public class NewPluginControllerTest extends ControllerIntegrationTest { } @Test - public void testListPlugins() throws Exception { + public void testDocsListPlugins() throws Exception { + Plugin plugin = createPlugin(PLUGIN_HASH); + plugin.setPublic(true); + persistPlugin(plugin); + + + plugin = createPlugin(faker.hashing().md5()); + plugin.addUrl(PLUGIN_URL); + persistPlugin(plugin); + + plugin = createPlugin(faker.hashing().md5()); + plugin.addUrl(PLUGIN_URL); + persistPlugin(plugin); + final RequestBuilder request = get("/minerva/new_api/plugins/"); - mockMvc.perform(request) - .andExpect(status().isOk()); + String content = mockMvc.perform(request) + .andExpect(status().isOk()) + .andDo(document("new_api/plugins/list_plugins", + pathParameters(), + NewApiDocs.getPluginsSearchResult())) + .andReturn().getResponse().getContentAsString(); + + final Page<Object> page = objectMapper.readValue(content, new TypeReference<Page<Object>>() { + }); + assertEquals(1, page.getTotalElements()); + assertEquals(0, page.getNumber()); + assertEquals(1, page.getNumberOfElements()); + + } + + private void persistPlugin(final Plugin plugin) { + pluginService.add(plugin); + pluginHashes.add(plugin.getHash()); } } diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/NewProjectControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/NewProjectControllerTest.java index 15a2de3f6a369ac1a576d5747c11e1b10a43d76e..75c4b7c2ac308f498843ed909d3eca8898bd6620 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/NewProjectControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/NewProjectControllerTest.java @@ -54,6 +54,8 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuild import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @@ -94,7 +96,7 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { } @Test - public void testGetProject() throws Exception { + public void testDocsGetProject() throws Exception { createEmptyProject(TEST_PROJECT); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -157,7 +159,7 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { } @Test - public void testCreateProject() throws Exception { + public void testDocsCreateProject() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final NewProjectDTO data = createProjectDTO(TEST_PROJECT); @@ -169,6 +171,10 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { final MockHttpServletResponse response = mockMvc.perform(request) .andExpect(status().isCreated()) + .andDo(document("new_api/projects/create_project_from_json", + pathParameters(), + NewApiDocs.getCreateProjectFields(), + responseFields(NewApiDocs.getProjectResponse("")))) .andReturn().getResponse(); assertNotNull(response.getHeader("ETag")); @@ -191,7 +197,7 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { } @Test - public void testUpdateProject() throws Exception { + public void testDocsUpdateProject() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createEmptyProject(TEST_PROJECT); @@ -205,6 +211,10 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { final HttpServletResponse response = mockMvc.perform(request) .andExpect(status().isOk()) + .andDo(document("new_api/projects/update_project", + projectPathParameters(), + NewApiDocs.getUpdateProjectFields(), + responseFields(NewApiDocs.getProjectResponse("")))) .andReturn().getResponse(); assertNotNull(response.getHeader("ETag")); @@ -275,16 +285,16 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { private NewProjectDTO createProjectDTO(final String projectId) { final NewProjectDTO data = new NewProjectDTO(); - data.setName("my name"); - data.setNotifyEmail("minerva@uni.lu"); + data.setName(faker.name().name()); + data.setNotifyEmail(faker.internet().emailAddress()); data.setProjectId(projectId); - data.setSbgnFormat(false); - data.setVersion("0.0.1"); + data.setSbgnFormat(faker.bool().bool()); + data.setVersion(faker.number().randomDigit() + "." + faker.number().randomDigit() + "." + faker.number().randomDigit()); return data; } @Test - public void testDeleteProject() throws Exception { + public void testDocsDeleteProject() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); createEmptyProject(TEST_PROJECT); @@ -293,6 +303,9 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { final String response = mockMvc.perform(request) .andExpect(status().isAccepted()) + .andDo(document("new_api/projects/delete_project", + projectPathParameters(), + responseFields(NewApiDocs.getJobResponse("")))) .andReturn().getResponse() .getContentAsString(); @@ -387,11 +400,23 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { } @Test - public void testListProjects() throws Exception { - final RequestBuilder request = get("/minerva/new_api/projects/"); + public void testDocsListProjects() throws Exception { + final RequestBuilder request = get("/minerva/new_api/projects/?size=10&page=0"); + + String response = mockMvc.perform(request) + .andExpect(status().isOk()) + .andDo(document("new_api/projects/list_projects", + requestParameters(getPageableFilter()), + NewApiDocs.getProjectsSearchResult())) + .andReturn().getResponse().getContentAsString(); + + final Page<Object> page = objectMapper.readValue(response, new TypeReference<Page<Object>>() { + }); + assertEquals(1, page.getTotalElements()); + assertEquals(10, page.getSize()); + assertEquals(0, page.getNumber()); + assertEquals(1, page.getNumberOfElements()); - mockMvc.perform(request) - .andExpect(status().isOk()); } @Test @@ -472,7 +497,7 @@ public class NewProjectControllerTest extends ControllerIntegrationTest { } @Test - public void testGetProjects() throws Exception { + public void testDocsGetProjects() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/new_api/projects/") diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/NewProjectLogEntryControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/NewProjectLogEntryControllerTest.java index b2b1accdce7d6ab13b7a7d78cf40849385b1f43b..6484d8bf34c70d59482209ae3cc058d1ef543193 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/NewProjectLogEntryControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/NewProjectLogEntryControllerTest.java @@ -4,7 +4,9 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import lcsb.mapviewer.services.interfaces.IMinervaJobService; import lcsb.mapviewer.web.ControllerIntegrationTest; +import lcsb.mapviewer.web.api.NewApiDocs; import lcsb.mapviewer.web.api.NewApiResponseSerializer; +import org.apache.commons.collections4.ListUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -16,7 +18,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.RequestBuilder; import static org.junit.Assert.assertEquals; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @@ -42,17 +46,21 @@ public class NewProjectLogEntryControllerTest extends ControllerIntegrationTest } @Test - public void testGetLogsForProject() throws Exception { + public void testDocsGetLogsForProject() throws Exception { createAndPersistProject(TEST_PROJECT); MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get( - "/minerva/new_api/projects/{projectId}/logEntry/?page=1&size=5&level=warning&sort=LEVEL&LEVEL.dir=desc&search=mess", + "/minerva/new_api/projects/{projectId}/logEntry/?page=0&size=5&level=warning&sort=LEVEL&LEVEL.dir=desc&search=mess", TEST_PROJECT).session(session); String response = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) + .andDo(document("new_api/projects/logs/list", + projectPathParameters(), + requestParameters(ListUtils.union(NewApiDocs.getLogsSearchFilter(), getPageableFilter())), + NewApiDocs.getProjectLogsSearchResult())) .andReturn().getResponse().getContentAsString(); Page<Object> result = objectMapper.readValue(response, new TypeReference<Page<Object>>() { }); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/chemicals/NewChemicalControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/chemicals/NewChemicalControllerTest.java index 766934cedf667c70a38941514421c1c8d257bbc8..0217b3908d3c7d349420d7e1a69992ad21d8155d 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/chemicals/NewChemicalControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/chemicals/NewChemicalControllerTest.java @@ -48,7 +48,7 @@ public class NewChemicalControllerTest extends ControllerIntegrationTest { } @Test - public void testSearchChemicalsInProjectUrl() throws Exception { + public void testDocsSearchChemicalsInProjectUrl() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/new_api/projects/{projectId}/chemicals:search?query=stilbene oxide", TEST_PROJECT) @@ -64,7 +64,7 @@ public class NewChemicalControllerTest extends ControllerIntegrationTest { } @Test - public void testSuggestedQueryList() throws Exception { + public void testDocsSuggestedQueryList() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final MiriamData bloodLossDisease = new MiriamData(MiriamType.MESH_2012, "D016063"); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/drugs/NewDrugControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/drugs/NewDrugControllerTest.java index 3ea076e86b8adfa5eeabd0492207a3b04193ab8c..e0552850dbccad19ad6af7dbb9c894875963f823 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/drugs/NewDrugControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/drugs/NewDrugControllerTest.java @@ -29,7 +29,7 @@ public class NewDrugControllerTest extends ControllerIntegrationTest { } @Test - public void testSearchDrugsInProjectUrl() throws Exception { + public void testDocsSearchDrugsInProjectUrl() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); RequestBuilder request = get("/minerva/new_api/projects/{projectId}/drugs:search?query={query}", TEST_PROJECT, "aspirin") @@ -44,7 +44,7 @@ public class NewDrugControllerTest extends ControllerIntegrationTest { } @Test - public void testSuggestedQueryList() throws Exception { + public void testDocsSuggestedQueryList() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get( "/minerva/new_api/projects/{projectId}/drugs/suggestedQueryList", TEST_PROJECT) diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/glyph/NewProjectGlyphControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/glyph/NewProjectGlyphControllerTest.java index 02d8b3f65a392f8d53af1fe8cd5f16f08489bedd..039a1eae8e47990f46d085d2858931f8cfc8e84d 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/glyph/NewProjectGlyphControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/glyph/NewProjectGlyphControllerTest.java @@ -24,6 +24,7 @@ import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.docu import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.multipart; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @@ -49,7 +50,7 @@ public class NewProjectGlyphControllerTest extends ControllerIntegrationTest { } @Test - public void testGetGlyphsForProject() throws Exception { + public void testDocsGetGlyphsForProject() throws Exception { createProjectWithGlyph(TEST_PROJECT); MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -62,6 +63,7 @@ public class NewProjectGlyphControllerTest extends ControllerIntegrationTest { .andExpect(status().is2xxSuccessful()) .andDo(document("new_api/projects/glyphs/list_glyphs", getProjectPathParameters(), + requestParameters(getPageableFilter()), NewApiDocs.getGlyphsSearchResult())) .andReturn().getResponse().getContentAsString(); Page<Object> result = objectMapper.readValue(response, new TypeReference<Page<Object>>() { @@ -70,7 +72,7 @@ public class NewProjectGlyphControllerTest extends ControllerIntegrationTest { } @Test - public void testAddGlyph() throws Exception { + public void testDocsAddGlyph() throws Exception { createProjectWithGlyph(TEST_PROJECT); MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/NewBioEntitiesControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/NewBioEntitiesControllerTest.java index a6e84e78568594686ba38dc6194a7f9d1be9ce98..4064c97fcd315a7e78fe14050d05493a2e8c17dd 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/NewBioEntitiesControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/NewBioEntitiesControllerTest.java @@ -92,7 +92,7 @@ public class NewBioEntitiesControllerTest extends ControllerIntegrationTest { } @Test - public void testSearchProteinAndDocument() throws Exception { + public void testDocsSearchProteinAndDocument() throws Exception { final RequestBuilder request = get( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/:search?query=GSTA&size=20&page=0&perfectMatch=false", TEST_PROJECT, "*"); @@ -111,7 +111,7 @@ public class NewBioEntitiesControllerTest extends ControllerIntegrationTest { } @Test - public void testSearchAnyType() throws Exception { + public void testDocsSearchAnyType() throws Exception { final RequestBuilder request = get( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/:search?", TEST_PROJECT, "*"); @@ -156,7 +156,7 @@ public class NewBioEntitiesControllerTest extends ControllerIntegrationTest { } @Test - public void testSuggestedQueryList() throws Exception { + public void testDocsSuggestedQueryList() throws Exception { final RequestBuilder request = get( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/suggestedQueryList", TEST_PROJECT, "*"); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/element/NewElementControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/element/NewElementControllerTest.java index 42b92cdcfe77ea6cba10ca53dfecf1f47d2f1155..cb4d32ecfa1c2e7d90dce0ddb1edb019b5ffebf7 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/element/NewElementControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/element/NewElementControllerTest.java @@ -465,8 +465,6 @@ public class NewElementControllerTest extends ControllerIntegrationTest { .andReturn().getResponse(); assertNotNull(response.getHeader("ETag")); - logger.debug(response.getContentAsString()); - Map<String, Object> result = objectMapper.readValue(response.getContentAsString(), new TypeReference<Map<String, Object>>() { }); assertNotNull(result.get("sboTerm")); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/elements/NewElementsControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/elements/NewElementsControllerTest.java index 5526277776e7e1bf2e456b5438531d73e1eec33a..dd0f4a993782e48005bbbac3a45f004269a1a746 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/elements/NewElementsControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/elements/NewElementsControllerTest.java @@ -70,7 +70,7 @@ public class NewElementsControllerTest extends ControllerIntegrationTest { } @Test - public void testGetElementById() throws Exception { + public void testDocsGetElementById() throws Exception { MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); Project projectWithGlyph = createProjectWithGlyph(TEST_PROJECT_ID); try { @@ -88,14 +88,12 @@ public class NewElementsControllerTest extends ControllerIntegrationTest { element.getId()) .session(session); - String response = mockMvc.perform(request) + mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) - .andDo(document("new_api/projects/maps/bioEntites/elements/get_by_id", + .andDo(document("new_api/projects/maps/bioEntities/elements/get_by_id", getElementPathParameters(), responseFields(NewApiDocs.getElementResponse("")))) .andReturn().getResponse().getContentAsString(); - - logger.debug(response); } finally { removeProject(projectWithGlyph); } @@ -367,7 +365,7 @@ public class NewElementsControllerTest extends ControllerIntegrationTest { } @Test - public void testExportToCsvAndDocument() throws Exception { + public void testDocsExportToCsvAndDocument() throws Exception { Compartment compartment = null; for (Element element : map.getElements()) { if (element instanceof Compartment) { @@ -395,7 +393,7 @@ public class NewElementsControllerTest extends ControllerIntegrationTest { mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) - .andDo(document("new_api/projects/maps/bioEntites/elements/export_to_csv", + .andDo(document("new_api/projects/maps/bioEntities/elements/export_to_csv", getMapPathParameters(), NewApiDocs.getElementCsvRequest())) .andReturn().getResponse().getContentAsString(); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/reactions/NewReactionsControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/reactions/NewReactionsControllerTest.java index b3750224bc25448fbc32c7ba87f7e6d768987dab..16ef1dc8e3fbc7a7cbbedbcaef70cedb5ff404f2 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/reactions/NewReactionsControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/bioentity/reactions/NewReactionsControllerTest.java @@ -1,23 +1,5 @@ package lcsb.mapviewer.web.api.project.map.bioentity.reactions; -import static org.junit.Assert.assertEquals; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Arrays; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.web.servlet.RequestBuilder; - import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.compartment.Compartment; @@ -31,6 +13,25 @@ import lcsb.mapviewer.services.interfaces.IUserService; import lcsb.mapviewer.web.ControllerIntegrationTest; import lcsb.mapviewer.web.api.NewApiDocs; import lcsb.mapviewer.web.api.NewApiResponseSerializer; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.web.servlet.RequestBuilder; + +import java.util.Arrays; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) public class NewReactionsControllerTest extends ControllerIntegrationTest { @@ -41,8 +42,6 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { @Autowired private NewApiResponseSerializer newApiResponseSerializer; - private User anonymous; - private Project project; private ModelData map; @@ -52,7 +51,7 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { objectMapper = newApiResponseSerializer.getObjectMapper(); project = createAndPersistProject(TEST_PROJECT); map = project.getTopModel().getModelData(); - anonymous = userService.getUserByLogin(Configuration.ANONYMOUS_LOGIN); + User anonymous = userService.getUserByLogin(Configuration.ANONYMOUS_LOGIN); userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId()); } @@ -62,24 +61,22 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { } @Test - public void testGetReactionById() throws Exception { + public void testDocsGetReactionById() throws Exception { RequestBuilder request = get( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/{reactionId}", TEST_PROJECT, map.getId(), map.getReactions().iterator().next().getId()); - String response = mockMvc.perform(request) + mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) - .andDo(document("new_api/projects/maps/bioEntites/reactions/get_by_id", + .andDo(document("new_api/projects/maps/bioEntities/reactions/get_by_id", getReactionPathParameters(), responseFields(NewApiDocs.getReactionResponse("")))) .andReturn().getResponse().getContentAsString(); - logger.debug(response); - } @Test - public void testGetNonexistingReactionById() throws Exception { + public void testGetNotExistingReactionById() throws Exception { RequestBuilder request = get( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/{reactionId}", TEST_PROJECT, map.getId(), 0); @@ -122,8 +119,8 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) @@ -146,8 +143,8 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) @@ -166,14 +163,14 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { "id", "modelId")); - requestBody.setAnnotations(Arrays.asList( + requestBody.setAnnotations(Collections.singletonList( "PUBMED")); RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) @@ -188,123 +185,128 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { @Test public void testExportWithElementTypeToCsv() throws Exception { DownloadCsvRequest requestBody = new DownloadCsvRequest(); - requestBody.setElementTypes(Arrays.asList(new Drug("").getStringType())); + requestBody.setElementTypes(Collections.singletonList(new Drug("").getStringType())); requestBody.setColumns(Arrays.asList( "id", "modelId")); RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) .andReturn().getResponse().getContentAsString(); int lines = content.split("\n").length; - assertEquals("Ther should be no reaction with Drug", 1, lines); + assertEquals("There should be no reaction with Drug", 1, lines); } @Test public void testExportWithElementTypeToCsv2() throws Exception { DownloadCsvRequest requestBody = new DownloadCsvRequest(); - requestBody.setElementTypes(Arrays.asList(new SimpleMolecule("").getStringType())); + requestBody.setElementTypes(Collections.singletonList(new SimpleMolecule("").getStringType())); requestBody.setColumns(Arrays.asList( "id", "modelId")); RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) .andReturn().getResponse().getContentAsString(); int lines = content.split("\n").length; - assertEquals("Ther should be one reaction with Protein", 2, lines); + assertEquals("There should be one reaction with Protein", 2, lines); } @Test public void testExportWithReactionTypeAFToCsv() throws Exception { DownloadCsvRequest requestBody = new DownloadCsvRequest(); - requestBody.setReactionTypes(Arrays.asList("Activity flow")); + requestBody.setReactionTypes(Collections.singletonList("Activity flow")); requestBody.setColumns(Arrays.asList( "id", "modelId")); RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) .andReturn().getResponse().getContentAsString(); int lines = content.split("\n").length; - assertEquals("Ther should be no AF reaction", 1, lines); + assertEquals("There should be no AF reaction", 1, lines); } @Test public void testExportWithReactionTypePDToCsv() throws Exception { DownloadCsvRequest requestBody = new DownloadCsvRequest(); - requestBody.setReactionTypes(Arrays.asList("Process description")); + requestBody.setReactionTypes(Collections.singletonList("Process description")); requestBody.setColumns(Arrays.asList( "id", "modelId")); RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) .andReturn().getResponse().getContentAsString(); int lines = content.split("\n").length; - assertEquals("Ther should be one PD reaction", 2, lines); + assertEquals("There should be one PD reaction", 2, lines); } @Test - public void testExportToCsvAndDocument() throws Exception { + public void testDocsExportToCsvAndDocument() throws Exception { Compartment compartment = null; for (Element element : map.getElements()) { if (element instanceof Compartment) { compartment = (Compartment) element; } - } + assertNotNull(compartment); - DownloadCsvRequest requestBody = new DownloadCsvRequest(); - requestBody.setSubmaps(Arrays.asList(map.getId())); - requestBody.setElementTypes(Arrays.asList(new SimpleMolecule("").getStringType())); - requestBody.setIncludedCompartmentIds(Arrays.asList(compartment.getId())); - requestBody.setReactionTypes(Arrays.asList("Process description")); - requestBody.setColumns(Arrays.asList( - "id", - "modelId")); - requestBody.setAnnotations(Arrays.asList( - "PUBMED")); + DownloadCsvRequest requestBody = createDownloadCsvRequest(compartment); RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) - .andDo(document("new_api/projects/maps/bioEntites/reactions/export_to_csv", + .andDo(document("new_api/projects/maps/bioEntities/reactions/export_to_csv", getMapPathParameters(), NewApiDocs.getReactionCsvRequest())) .andReturn().getResponse().getContentAsString(); int lines = content.split("\n").length; - assertEquals("Ther should be one PD reaction", 2, lines); + assertEquals("There should be one PD reaction", 2, lines); + } + + private DownloadCsvRequest createDownloadCsvRequest(final Compartment compartment) { + DownloadCsvRequest requestBody = new DownloadCsvRequest(); + requestBody.setSubmaps(Collections.singletonList(map.getId())); + requestBody.setElementTypes(Collections.singletonList(new SimpleMolecule("").getStringType())); + requestBody.setIncludedCompartmentIds(Collections.singletonList(compartment.getId())); + requestBody.setReactionTypes(Collections.singletonList("Process description")); + requestBody.setColumns(Arrays.asList( + "id", + "modelId")); + requestBody.setAnnotations(Collections.singletonList( + "PUBMED")); + return requestBody; } @Test @@ -319,8 +321,8 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { RequestBuilder request = post( "/minerva/new_api/projects/{projectId}/models/{mapId}/bioEntities/reactions/:downloadCsv", TEST_PROJECT, "*") - .content(objectMapper.writeValueAsBytes(requestBody)) - .contentType(MediaType.APPLICATION_JSON); + .content(objectMapper.writeValueAsBytes(requestBody)) + .contentType(MediaType.APPLICATION_JSON); String content = mockMvc.perform(request) .andExpect(status().is2xxSuccessful()) @@ -330,7 +332,6 @@ public class NewReactionsControllerTest extends ControllerIntegrationTest { for (String string : lines) { assertEquals(requestBody.getColumns().size(), string.split(",").length); } - logger.debug(content); } } diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/NewLayerControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/NewLayerControllerTest.java index eb645ec0189b8ec14c51a83a7cebc1d8a7a4a1b4..e586f147555560c2198592955b02363c0075f9aa 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/NewLayerControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/NewLayerControllerTest.java @@ -38,6 +38,7 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuild import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @@ -78,7 +79,7 @@ public class NewLayerControllerTest extends ControllerIntegrationTest { } @Test - public void testGetLayer() throws Exception { + public void testDocsGetLayer() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -117,7 +118,7 @@ public class NewLayerControllerTest extends ControllerIntegrationTest { } @Test - public void testCreateLayer() throws Exception { + public void testDocsCreateLayer() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final NewLayerDTO data = createLayerDTO(); @@ -157,7 +158,7 @@ public class NewLayerControllerTest extends ControllerIntegrationTest { } @Test - public void testUpdateLayer() throws Exception { + public void testDocsUpdateLayer() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final NewLayerDTO data = createLayerDTO(); @@ -223,7 +224,7 @@ public class NewLayerControllerTest extends ControllerIntegrationTest { } @Test - public void testDeleteLayer() throws Exception { + public void testDocsDeleteLayer() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = delete("/minerva/new_api/projects/{projectId}/maps/{mapId}/layers/{layerId}", @@ -289,7 +290,7 @@ public class NewLayerControllerTest extends ControllerIntegrationTest { } @Test - public void testListLayers() throws Exception { + public void testDocsListLayers() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/new_api/projects/{projectId}/maps/{mapId}/layers/", TEST_PROJECT, mapId) @@ -298,6 +299,7 @@ public class NewLayerControllerTest extends ControllerIntegrationTest { mockMvc.perform(request) .andDo(document("new_api/projects/maps/layers/list_layers", getMapPathParameters(), + requestParameters(getPageableFilter()), NewApiDocs.getLayersSearchResult())) .andExpect(status().isOk()); } diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/image/NewLayerImageControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/image/NewLayerImageControllerTest.java index 7c860a626d19edeccc960960913cf056f7f53ab9..ca3b51b595cef005d6f514a7c0f087b97d857c33 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/image/NewLayerImageControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/image/NewLayerImageControllerTest.java @@ -40,6 +40,7 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuild import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @@ -83,7 +84,7 @@ public class NewLayerImageControllerTest extends ControllerIntegrationTest { } @Test - public void testGetLayerImage() throws Exception { + public void testDocsGetLayerImage() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -139,7 +140,7 @@ public class NewLayerImageControllerTest extends ControllerIntegrationTest { } @Test - public void testCreateLayerImage() throws Exception { + public void testDocsCreateLayerImage() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final NewImageDTO data = createLayerImageDTO(); @@ -184,7 +185,7 @@ public class NewLayerImageControllerTest extends ControllerIntegrationTest { } @Test - public void testUpdateLayerImage() throws Exception { + public void testDocsUpdateLayerImage() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final NewImageDTO data = createLayerImageDTO(); @@ -250,7 +251,7 @@ public class NewLayerImageControllerTest extends ControllerIntegrationTest { } @Test - public void testDeleteLayerImage() throws Exception { + public void testDocsDeleteLayerImage() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = delete("/minerva/new_api/projects/{projectId}/maps/{mapId}/layers/{layerId}/images/{imageId}", @@ -316,7 +317,7 @@ public class NewLayerImageControllerTest extends ControllerIntegrationTest { } @Test - public void testListLayerImages() throws Exception { + public void testDocsListLayerImages() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/new_api/projects/{projectId}/maps/{mapId}/layers/{layerId}/images/", @@ -324,6 +325,10 @@ public class NewLayerImageControllerTest extends ControllerIntegrationTest { .session(session); mockMvc.perform(request) + .andDo(document("new_api/projects/maps/layers/images/list_images", + getLayerPathParameters(), + requestParameters(getPageableFilter()), + NewApiDocs.getLayerImagesSearchResult())) .andExpect(status().isOk()); } diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/oval/NewLayerOvalControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/oval/NewLayerOvalControllerTest.java index 69d38c1da2c4ffc00438f25f9ec1273a9ecdab94..1f88bbe68ed7565079b26d547c0dafae64817a27 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/oval/NewLayerOvalControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/oval/NewLayerOvalControllerTest.java @@ -158,7 +158,6 @@ public class NewLayerOvalControllerTest extends ControllerIntegrationTest { assertNotNull(response.getHeader("ETag")); final Map<String, Object> result = objectMapper.readValue(response.getContentAsString(), new TypeReference<Map<String, Object>>() { }); - logger.debug(response.getContentAsString()); final Map<LayerOvalProperty, Object> filter = new HashMap<>(); filter.put(LayerOvalProperty.PROJECT_ID, TEST_PROJECT); diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/rect/NewLayerRectControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/rect/NewLayerRectControllerTest.java index f4bafa4d49bac798f607dcd96248c6fc1534765d..ad3cf62e49cfa818d27b59ae89de12733fdf6af2 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/rect/NewLayerRectControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/rect/NewLayerRectControllerTest.java @@ -147,8 +147,6 @@ public class NewLayerRectControllerTest extends ControllerIntegrationTest { final NewRectDTO data = createLayerRectDTO(); - logger.debug(objectMapper.writeValueAsString(data)); - final RequestBuilder request = post("/minerva/new_api/projects/{projectId}/maps/{mapId}/layers/{layerId}/rects/", TEST_PROJECT, mapId, layerId) diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/text/NewLayerTextControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/text/NewLayerTextControllerTest.java index b2fd3561ce3d4ea62fa946e299dc01fc18c97042..0edd6f4687ebd98100da224dead3a5aab451c1e4 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/text/NewLayerTextControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/layer/text/NewLayerTextControllerTest.java @@ -44,6 +44,7 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuild import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @@ -89,7 +90,7 @@ public class NewLayerTextControllerTest extends ControllerIntegrationTest { } @Test - public void testGetLayerText() throws Exception { + public void testDocsGetLayerText() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -154,7 +155,7 @@ public class NewLayerTextControllerTest extends ControllerIntegrationTest { } @Test - public void testCreateLayerText() throws Exception { + public void testDocsCreateLayerText() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final NewTextDTO data = createLayerTextDTO(); @@ -204,7 +205,7 @@ public class NewLayerTextControllerTest extends ControllerIntegrationTest { } @Test - public void testUpdateLayerText() throws Exception { + public void testDocsUpdateLayerText() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final NewTextDTO data = createLayerTextDTO(); @@ -270,7 +271,7 @@ public class NewLayerTextControllerTest extends ControllerIntegrationTest { } @Test - public void testDeleteLayerText() throws Exception { + public void testDocsDeleteLayerText() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = delete("/minerva/new_api/projects/{projectId}/maps/{mapId}/layers/{layerId}/texts/{textId}", @@ -336,7 +337,7 @@ public class NewLayerTextControllerTest extends ControllerIntegrationTest { } @Test - public void testListLayerTexts() throws Exception { + public void testDocsListLayerTexts() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/new_api/projects/{projectId}/maps/{mapId}/layers/{layerId}/texts/", @@ -344,6 +345,10 @@ public class NewLayerTextControllerTest extends ControllerIntegrationTest { .session(session); mockMvc.perform(request) + .andDo(document("new_api/projects/maps/layers/texts/list_texts", + getLayerPathParameters(), + requestParameters(getPageableFilter()), + NewApiDocs.getLayerTextsSearchResult())) .andExpect(status().isOk()); } diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/map/publication/NewPublicationControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/map/publication/NewPublicationControllerTest.java index b13e22184ef24f4aa1fc4f58a66a6bb3634fa76c..2295fe98684cebd43431ec7682b55adc50cb7542 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/map/publication/NewPublicationControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/map/publication/NewPublicationControllerTest.java @@ -13,7 +13,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpSession; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.RequestBuilder; @@ -67,9 +66,8 @@ public class NewPublicationControllerTest extends ControllerIntegrationTest { TEST_PROJECT, mapId) .session(session); - final MockHttpServletResponse response = mockMvc.perform(request) + mockMvc.perform(request) .andExpect(status().isOk()) .andReturn().getResponse(); - logger.debug(response.getContentAsString()); } } diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/overlay/NewOverlayControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/overlay/NewOverlayControllerTest.java index f59fb3bc0be2265a7bb2820049619c9e7a893fbb..0c8297e06c88bc1991975385815926e26a04222b 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/overlay/NewOverlayControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/overlay/NewOverlayControllerTest.java @@ -85,7 +85,7 @@ public class NewOverlayControllerTest extends ControllerIntegrationTest { } @Test - public void testGetBioEntitiesForOverlay() throws Exception { + public void testDocsGetBioEntitiesForOverlay() throws Exception { final String content = createOverlayContentForAllEntities(map); final DataOverlay overlay = createOverlay(project, userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN), content); @@ -172,7 +172,7 @@ public class NewOverlayControllerTest extends ControllerIntegrationTest { @Test - public void testGetOverlay() throws Exception { + public void testDocsGetOverlay() throws Exception { final User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -233,8 +233,6 @@ public class NewOverlayControllerTest extends ControllerIntegrationTest { final Map<String, Object> result = objectMapper.readValue(response.getContentAsString(), new TypeReference<Map<String, Object>>() { }); - logger.debug(response.getContentAsString()); - assertNotNull(dataOverlayService.getDataOverlayById((int) result.get("id"))); } diff --git a/web/src/test/java/lcsb/mapviewer/web/api/project/overlay/entries/NewOverlayEntryTypesControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/project/overlay/entries/NewOverlayEntryTypesControllerTest.java index d10d1abb792e8d757a33f5a39c135502bb261c39..f8b4fad84c7af419b6bf6486daa09cdd5ff1d08e 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/project/overlay/entries/NewOverlayEntryTypesControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/project/overlay/entries/NewOverlayEntryTypesControllerTest.java @@ -172,10 +172,9 @@ public class NewOverlayEntryTypesControllerTest extends ControllerIntegrationTes dataOverlayEntry.getId()) .session(session); - final String content = mockMvc.perform(request) + mockMvc.perform(request) .andExpect(status().isOk()) .andReturn().getResponse().getContentAsString(); - logger.debug(content); } @Test diff --git a/web/src/test/java/lcsb/mapviewer/web/api/user/NewUserControllerTest.java b/web/src/test/java/lcsb/mapviewer/web/api/user/NewUserControllerTest.java index 3c701807eb509af54c1d8da5b38fb7583ff9266b..0f8b88a591522b7d1f828d5900b1182bdc3bd737 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/user/NewUserControllerTest.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/user/NewUserControllerTest.java @@ -47,6 +47,7 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuild 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.pathParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -80,7 +81,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void testGetUserAsAdmin() throws Exception { + public void testDocsGetUserAsAdmin() throws Exception { User user = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -108,17 +109,13 @@ public class NewUserControllerTest extends ControllerIntegrationTest { final MockHttpServletResponse response = mockMvc.perform(request) .andExpect(status().isOk()) - .andDo(document("new_api/users/get_by_id", - getUserPathParameters(), - responseFields(NewApiDocs.getUserResponse("")))) - .andExpect(status().is2xxSuccessful()) .andReturn().getResponse(); assertNotNull(response.getHeader("ETag")); } @Test - public void testGrantPrivilege() throws Exception { + public void testDocsGrantPrivilege() throws Exception { User user = createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -133,6 +130,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { .andExpect(status().isOk()) .andDo(document("new_api/users/grant_privilege", getUserPathParameters(), + NewApiDocs.getGrantUserPrivilegeRequest(), responseFields(NewApiDocs.getUserResponse("")))) .andExpect(status().is2xxSuccessful()); @@ -141,7 +139,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void testRevokePrivilege() throws Exception { + public void testDocsRevokePrivilege() throws Exception { User user = createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD); userService.grantUserPrivilege(user, PrivilegeType.IS_CURATOR); final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); @@ -157,6 +155,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { .andExpect(status().isOk()) .andDo(document("new_api/users/revoke_privilege", getUserPathParameters(), + NewApiDocs.getGrantUserPrivilegeRequest(), responseFields(NewApiDocs.getUserResponse("")))) .andExpect(status().is2xxSuccessful()); @@ -235,7 +234,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void testCreateUser() throws Exception { + public void testDocsCreateUser() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final NewUserDTO data = createUserDTO(TEST_USER_LOGIN); @@ -247,6 +246,10 @@ public class NewUserControllerTest extends ControllerIntegrationTest { final MockHttpServletResponse response = mockMvc.perform(request) .andExpect(status().isCreated()) + .andDo(document("new_api/users/create_user", + NewApiDocs.getAddUserRequest(), + pathParameters(), + responseFields(NewApiDocs.getUserResponse("")))) .andReturn().getResponse(); assertNotNull(response.getHeader("ETag")); @@ -258,9 +261,9 @@ public class NewUserControllerTest extends ControllerIntegrationTest { data.setLogin(login); data.setPassword(TEST_USER_PASSWORD); data.setActive(true); - data.setName("test name"); - data.setEmail("test@test.com"); - data.setSurname("surname"); + data.setName(faker.name().firstName()); + data.setEmail(faker.internet().emailAddress()); + data.setSurname(faker.name().lastName()); data.setConnectedToLdap(false); data.setTermsOfUseConsent(false); return data; @@ -282,7 +285,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void testUpdateUser() throws Exception { + public void testDocsUpdateUser() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); User user = createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD); @@ -296,6 +299,10 @@ public class NewUserControllerTest extends ControllerIntegrationTest { final HttpServletResponse response = mockMvc.perform(request) .andExpect(status().isOk()) + .andDo(document("new_api/users/update_user", + getUserPathParameters(), + NewApiDocs.getAddUserRequest(), + responseFields(NewApiDocs.getUserResponse("")))) .andReturn().getResponse(); assertNotNull(response.getHeader("ETag")); @@ -365,7 +372,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void testDeleteUser() throws Exception { + public void testDocsDeleteUser() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); User user = createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD); @@ -373,7 +380,10 @@ public class NewUserControllerTest extends ControllerIntegrationTest { .session(session); mockMvc.perform(request) - .andExpect(status().isOk()); + .andExpect(status().isOk()) + .andDo(document("new_api/users/delete_user", + getUserPathParameters())); + assertNull(userService.getById(user.getId())); } @@ -450,14 +460,15 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void testGetUsers() throws Exception { + public void testDocsGetUsers() throws Exception { final MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD); final RequestBuilder request = get("/minerva/new_api/users/") .session(session); mockMvc.perform(request) - .andDo(document("new_api/users/get_users", + .andDo(document("new_api/users/list_users", + pathParameters(), NewApiDocs.getUserSearchResult())) .andExpect(status().is2xxSuccessful()) .andReturn().getResponse().getContentAsString(); @@ -539,7 +550,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void resetPassword() throws Exception { + public void testDocsResetPassword() throws Exception { configureServerForResetPasswordRequest(); User user = createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD); user.setEmail("test@test.xyz"); @@ -562,6 +573,8 @@ public class NewUserControllerTest extends ControllerIntegrationTest { .contentType(MediaType.APPLICATION_JSON); mockMvc.perform(resetRequest) + .andDo(document("new_api/users/reset_password", + NewApiDocs.getPasswordResetRequest())) .andExpect(status().is2xxSuccessful()); createSession(TEST_USER_LOGIN, newPassword); @@ -611,7 +624,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void confirmRegistrationOfNewUser() throws Exception { + public void testDocsConfirmRegistrationOfNewUser() throws Exception { User user = createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD); user.setEmail("test@test.xyz"); user.setActive(false); @@ -633,7 +646,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { .content(body); mockMvc.perform(resetRequest) - .andDo(document("user/confirm_email", + .andDo(document("new_api/users/confirm_email", userPathParameters(), requestParameters(parameterWithName("token") .description("token obtained in the registration email")), @@ -724,6 +737,30 @@ public class NewUserControllerTest extends ControllerIntegrationTest { .andExpect(status().isBadRequest()); } + @Test + public void testDocsRegisterNewUser() throws Exception { + configureServerForResetPasswordRequest(); + + configurationService.setConfigurationValue(ConfigurationElementType.ALLOW_AUTO_REGISTER, "true"); + final NewUserDTO data = createUserDTO(TEST_USER_LOGIN); + data.setConnectedToLdap(false); + data.setActive(true); + data.setTermsOfUseConsent(false); + + final RequestBuilder request = post("/minerva/new_api/users/:registerUser") + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(data)); + + mockMvc.perform(request) + .andDo(document("new_api/users/register_user", + NewApiDocs.getRegisterUserRequest(), + responseFields(NewApiDocs.getUserResponse("")))) + .andExpect(status().isOk()); + User user = userService.getUserByLogin(TEST_USER_LOGIN); + assertFalse(user.isConfirmed()); + assertFalse(user.isActive()); + } + @Test public void confirmRegistrationOfNewUserWithInvalidToken() throws Exception { User user = createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD); @@ -776,7 +813,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { } @Test - public void requestResetPassword() throws Exception { + public void testDocsRequestResetPassword() throws Exception { final long count = userService.getPasswordTokenCount(); configureServerForResetPasswordRequest(); @@ -787,7 +824,7 @@ public class NewUserControllerTest extends ControllerIntegrationTest { final RequestBuilder grantRequest = post("/minerva/new_api/users/{login}:requestResetPassword", TEST_USER_LOGIN); mockMvc.perform(grantRequest) - .andDo(document("user/request_reset_password", + .andDo(document("new_api/users/request_reset_password", userPathParameters())) .andExpect(status().is2xxSuccessful()); assertEquals(count + 1, userService.getPasswordTokenCount());