TSK-552 Added rest documentation in taskana-rest-spring-example
This commit is contained in:
parent
8d376131cf
commit
51d53525da
|
@ -15,7 +15,7 @@
|
|||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.0.0.RELEASE</version>
|
||||
<version>2.0.2.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
|
@ -74,6 +74,13 @@
|
|||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-test</artifactId>
|
||||
|
@ -85,7 +92,13 @@
|
|||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.restdocs</groupId>
|
||||
<artifactId>spring-restdocs-mockmvc</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -93,6 +106,69 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<!-- Required for generation of REST documentation -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
<include>**/*Documentation.java</include>
|
||||
</includes>
|
||||
<!-- Travis build workaround to prevent error that VM is closed due to an error. -->
|
||||
<argLine>-Xms1024m -Xmx2048m</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-docs</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>process-asciidoc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<backend>html</backend>
|
||||
<doctype>book</doctype>
|
||||
<attributes>
|
||||
<snippets>target/generated-snippets</snippets>
|
||||
<docinfo>shared</docinfo>
|
||||
</attributes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>
|
||||
${project.build.outputDirectory}/static/docs
|
||||
</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>
|
||||
${project.build.directory}/generated-docs
|
||||
</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/js</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,64 @@
|
|||
<!-- Sourcecode at https://stackoverflow.com/questions/34481638/how-to-use-tocify-with-asciidoctor-for-a-dynamic-toc -->
|
||||
|
||||
<script src="./jquery-1.11.3.min.js"></script>
|
||||
<script src="./jquery-ui.min.js"></script>
|
||||
<script src="./jquery.tocify.min.js"></script>
|
||||
|
||||
<style>
|
||||
.tocify-header {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.tocify-subheader {
|
||||
font-style: normal;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.tocify ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.tocify-focus {
|
||||
color: #7a2518;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.tocify-focus > a {
|
||||
color: #7a2518;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#toc").append("<div id='generated-toc'></div>");
|
||||
$("#generated-toc").tocify({
|
||||
extendPage: true,
|
||||
context: "#content",
|
||||
highlightOnScroll: true,
|
||||
hideEffect: "slideUp",
|
||||
hashGenerator: function(text, element) {
|
||||
return $(element).attr("id");
|
||||
},
|
||||
smoothScroll: false,
|
||||
theme: "none",
|
||||
selectors: $( "#content" ).has( "h1" ).size() > 0 ? "h1,h2,h3,h4,h5" : "h2,h3,h4,h5",
|
||||
ignoreSelector: ".discrete"
|
||||
});
|
||||
|
||||
var handleTocOnResize = function() {
|
||||
if ($(document).width() < 768) {
|
||||
$("#generated-toc").hide();
|
||||
$(".sectlevel0").show();
|
||||
$(".sectlevel1").show();
|
||||
}
|
||||
else {
|
||||
$("#generated-toc").show();
|
||||
$(".sectlevel0").hide();
|
||||
$(".sectlevel1").hide();
|
||||
}
|
||||
}
|
||||
|
||||
$(window).resize(handleTocOnResize);
|
||||
handleTocOnResize();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,661 @@
|
|||
= Taskana RESTful API Documentation
|
||||
taskana.pro;
|
||||
:doctype: book
|
||||
:icons: font
|
||||
:source-highlighter: highlightjs
|
||||
:toc: left
|
||||
:toclevels: 4
|
||||
:sectlinks:
|
||||
|
||||
= Overview
|
||||
|
||||
[big]#*This Documentation is still under development and probably incomplete and/or flawed in certain areas.*#
|
||||
|
||||
== HTTP verbs
|
||||
|
||||
The Taskana RESTful API tries to adhere as closely as possible to standard HTTP and REST conventions in its
|
||||
use of HTTP verbs.
|
||||
|
||||
|===
|
||||
| Verb | Usage
|
||||
|
||||
| `GET`
|
||||
| Used to retrieve a resource
|
||||
|
||||
| `POST`
|
||||
| Used to create a new resource
|
||||
|
||||
| `PUT`
|
||||
| Used to update a resource
|
||||
|
||||
| `DELTE`
|
||||
| Used to delete a existing resource
|
||||
|===
|
||||
|
||||
== HTTP status codes
|
||||
|
||||
The Taskana RESTful API tries to adhere as closely as possible to standard HTTP and REST conventions in its
|
||||
use of HTTP status codes.
|
||||
|
||||
|===
|
||||
| Status code | Usage
|
||||
|
||||
| `200 OK`
|
||||
| The request completed successfully.
|
||||
|
||||
| `201 Created`
|
||||
| The request completed successfully und create the new resource.
|
||||
|
||||
| `204 No Content`
|
||||
| The request completed successfully and there is no content to send in the response payload.
|
||||
|
||||
| `400 Bad Request`
|
||||
| The request was not performed because of a client error like a invalid parameter.
|
||||
|
||||
| `401 Unauthorized`
|
||||
| The request has not been applied because it lacks valid authentication credentials for the target resource.
|
||||
|
||||
| `403 FORBIDDEN`
|
||||
| The current user <user> has no read permission for <Resource Type> <Resource>.
|
||||
|
||||
| `404 Not Found`
|
||||
| The requested resource did not exist.
|
||||
|
||||
| `405 Method not allowed`
|
||||
| The method used in this request is can not be used on this resource.
|
||||
|
||||
| `406` Not acceptable
|
||||
| Wrong content-type in request header.
|
||||
|
||||
| `409 Conflict`
|
||||
| The resource could not be updatet or created because of a conflict with an existing one.
|
||||
|
||||
| `415 Unsupported Media Type`
|
||||
| The content of the request can't be understood due to being in an unsupported media-type.
|
||||
|===
|
||||
|
||||
== Common Fields
|
||||
|
||||
Taskana uses Spring HATEOAS to achive the best possible REST-conformity. +
|
||||
In HATEOAS every response contains a map named *_links* in which the links for navigation are included. +
|
||||
If a resource has embedded resources these are found in a map named *_embedded*.
|
||||
|
||||
=== Response Fields common to all Resources
|
||||
|
||||
Every Resource contains at least the link to itself.
|
||||
|
||||
include::../../../{snippets}/CommonFields/response-fields.adoc[]
|
||||
|
||||
=== Response Fields common to all Summary Resources
|
||||
|
||||
Summary Resources contain embedded resources and can be requested in a <<paged-request, paged format>>.
|
||||
|
||||
include::../../../{snippets}/CommonSummaryResourceFields/response-fields.adoc[]
|
||||
|
||||
== Classifications-Resource
|
||||
|
||||
This resource provides the entry point with classifications.
|
||||
|
||||
=== Get a list of all classifications
|
||||
|
||||
A `GET` request is used to retrieve a classification summary.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetAllClassificationsDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetAllClassificationsDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetAllClassificationsDocTest/response-fields.adoc[]
|
||||
|
||||
=== Filter and sort options
|
||||
|
||||
The list generated in the response can be filtered using following parameters in the uri: +
|
||||
name | name-like | key | category | domain | type | custom-{1...8}-like +
|
||||
|
||||
It can also be sorted by using this set of parameters: +
|
||||
sortBy = {category | domain | key | name } | order={desc | asc }
|
||||
|
||||
=== Get a single classification
|
||||
|
||||
A `GET` request is used to retrieve a classification.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetSpecificClassificationDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetSpecificClassificationDocTest/http-response.adoc[]
|
||||
|
||||
[[classification]]
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetSpecificClassificationDocTest/response-fields.adoc[]
|
||||
|
||||
=== Update a Classification
|
||||
|
||||
A `PUT` request is used to update a classification.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/UpdateClassificationDocTest/http-request.adoc[]
|
||||
|
||||
==== Request Structure
|
||||
|
||||
The request-body is essentially the same as for getting a single classification. +
|
||||
Therefore for the request fields you can refer to the structure of the <<classification, single classification>>.
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/UpdateClassificationDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
The response-body is essentially the same as for getting a single classification. +
|
||||
Therefore for the response fields you can refer to the structure of the <<classification, single classification>>.
|
||||
|
||||
=== Create a new Classification
|
||||
|
||||
A `POST` request is used to create a new classification.
|
||||
|
||||
==== Example Request
|
||||
|
||||
This minimal example shows only the required fields to create a new classification. The <<create-classification-request-structure, request structure>> shows all possible fields for creating a classification.
|
||||
|
||||
include::../../../{snippets}/CreateClassificationDocTest/http-request.adoc[]
|
||||
|
||||
[[create-classification-request-structure]]
|
||||
==== Request Structure
|
||||
|
||||
include::../../../{snippets}/CreateClassificationDocTest/request-fields.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/CreateClassificationDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
The response-body is essentially the same as for getting a single classification. +
|
||||
Therefore for the response fields you can refer to the structure of the <<classification, single classification>>.
|
||||
|
||||
=== Delete a classification
|
||||
|
||||
A `DELETE` request is used to delete a classification.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/DeleteClassificationDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/DeleteClassificationDocTest/http-response.adoc[]
|
||||
|
||||
== Workbaskets-Resource
|
||||
|
||||
=== Get a list of all workbaskets
|
||||
|
||||
A `GET` request is used to retrieve a workbasket summary.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketsDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketsDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketsDocTest/response-fields.adoc[]
|
||||
|
||||
=== Filter and sort options
|
||||
|
||||
The list generated in the response can be filtered using following parameters in the uri: +
|
||||
name | name-like | key | key-like | owner | owner-like | description-like | domain | +
|
||||
type={GROUP | PERSONAL | TOPIC | CLEARANCE} | +
|
||||
required-permission={READ|OPEN|APPEND|TRANSFER|DISTRIBUTE|CUSTOM_1...12} +
|
||||
|
||||
It can also be sorted by using this set of parameters: +
|
||||
sortBy = {key | name | owner | type } | order={desc | asc }
|
||||
|
||||
=== Get a single workbasket
|
||||
|
||||
A `GET` request is used to retrieve a workbasket.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetSpecificWorkbasketDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetSpecificWorkbasketDocTest/http-response.adoc[]
|
||||
|
||||
[[workbasket]]
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetSpecificWorkbasketDocTest/response-fields.adoc[]
|
||||
|
||||
=== Update a workbasket
|
||||
|
||||
A `PUT` request is used to update a workbasket
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/UpdateWorkbasketDocTest/http-request.adoc[]
|
||||
|
||||
==== Request Structure
|
||||
|
||||
The request-body is essentially the same as for getting a single classification. +
|
||||
Therefore for the request fields you can refer to the structure of the <<workbasket, single workbasket>>.
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/UpdateWorkbasketDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
The response-body is essentially the same as for getting a single classification. +
|
||||
Therefore for the response fields you can refer to the structure of the <<workbasket, single workbasket>>.
|
||||
|
||||
|
||||
=== Remove a workbasket as distribution-target
|
||||
|
||||
A `DELETE` request is used to remove a workbasket as a distribution-taregt.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/RemoveWorkbasketAsDistributionTargetDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/RemoveWorkbasketAsDistributionTargetDocTest/http-response.adoc[]
|
||||
|
||||
=== Get all Access-Items for a workbasket
|
||||
|
||||
A `GET` request is used to get a list of all accessitems of a workbasket.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketAccessItemsDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketAccessItemsDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketAccessItemsDocTest/response-fields.adoc[]
|
||||
|
||||
=== Get all distribution-targets for a workbasket
|
||||
|
||||
A `GET` request is used to get a list of the distribution-targets of a workbasket.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketDistributionTargets/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketDistributionTargets/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasketDistributionTargets/response-fields.adoc[]
|
||||
|
||||
=== Create a new Workbasket
|
||||
|
||||
A `POST` request is used to create a new workbasket.
|
||||
|
||||
==== Example Request
|
||||
|
||||
This minimal example shows only the required fields to create a new workbasket. The <<create-workbasket-request-structure, request structure>> shows all possible fields for creating a workbasket.
|
||||
|
||||
include::../../../{snippets}/CreateWorkbasketDocTest/http-request.adoc[]
|
||||
|
||||
[[create-workbasket-request-structure]]
|
||||
==== Request Structure
|
||||
|
||||
include::../../../{snippets}/CreateWorkbasketDocTest/request-fields.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/CreateWorkbasketDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
The response-body is essentially the same as for getting a single classification. +
|
||||
Therefore for the response fields you can refer to the structure of the <<classification, single classification>>.
|
||||
|
||||
=== Delete a classification
|
||||
|
||||
A `DELETE` request is used to delete a classification.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/DeleteClassificationDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/DeleteClassificationDocTest/http-response.adoc[]
|
||||
|
||||
== Tasks-Resource
|
||||
|
||||
=== Get a list of all tasks
|
||||
|
||||
A `GET` request is used to retrieve a task summary.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetAllTasksDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetAllTasksDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetAllTasksDocTest/response-fields.adoc[]
|
||||
|
||||
=== Filter and sort options
|
||||
|
||||
The list generated in the response can be filtered using following parameters in the uri: +
|
||||
name | priority | state | classification.key | workbasket-id | {workbasket-key , domain} | +
|
||||
owner | por.company | por.system | por.instance | por.type | por.value +
|
||||
|
||||
It can also be sorted by using this set of parameters: +
|
||||
sortBy = { classification.key | por.type | por.value | state | name| due | planned | priority } | order={ desc | asc }
|
||||
|
||||
=== Get a single task
|
||||
|
||||
A `GET` request is used to retrieve a task.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetSpecificTaskDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetSpecificTaskDocTest/http-response.adoc[]
|
||||
|
||||
[[task]]
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetSpecificTaskDocTest/response-fields.adoc[]
|
||||
|
||||
=== Update a task
|
||||
|
||||
A `PUT` request is used to update a task.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/UpdateTaskDocTest/http-request.adoc[]
|
||||
|
||||
==== Request Structure
|
||||
|
||||
include::../../../{snippets}/UpdateTaskDocTest/request-fields.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/UpdateTaskDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/UpdateTaskDocTest/response-fields.adoc[]
|
||||
|
||||
=== Claim a task
|
||||
|
||||
A `POST` request is used to claim a task
|
||||
|
||||
==== Example Request
|
||||
|
||||
Note the empty request-body in the example.
|
||||
|
||||
include::../../../{snippets}/ClaimTaskDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/ClaimTaskDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
The response-body is essentially the same as for getting a single task. +
|
||||
Therefore for the response fields you can refer to the <<task, single task>>.
|
||||
|
||||
=== Complete a task
|
||||
|
||||
A `POST` request is used to complete a task
|
||||
|
||||
==== Example Request
|
||||
|
||||
Note the empty request-body in the example.
|
||||
|
||||
include::../../../{snippets}/CompleteTaskDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/CompleteTaskDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
The response-body is essentially the same as for getting a single task. +
|
||||
Therefore for the response fields you can refer to the <<task, single task>>.
|
||||
|
||||
=== Create a new task
|
||||
|
||||
A `POST` request is used to create a new task.
|
||||
|
||||
==== Example Request
|
||||
|
||||
This minimal example shows only the required fields to create a new task. The <<create-task-request-structure, request structure>> shows all possible fields for creating a task.
|
||||
|
||||
include::../../../{snippets}/CreateTaskDocTest/http-request.adoc[]
|
||||
|
||||
[[create-task-request-structure, request structure]]
|
||||
==== Request Structure
|
||||
|
||||
include::../../../{snippets}/CreateTaskDocTest/request-fields.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/CreateTaskDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
The response-body is essentially the same as for getting a single task. +
|
||||
Therefore for the response fields you can refer to the <<task, single task>>.
|
||||
|
||||
=== Delete a task
|
||||
|
||||
A `DELETE` request is used to delete a task.
|
||||
|
||||
==== Example request
|
||||
|
||||
include::../../../{snippets}/DeleteTaskDocTest/http-request.adoc[]
|
||||
|
||||
==== Example response
|
||||
|
||||
include::../../../{snippets}/DeleteTaskDocTest/http-response.adoc[]
|
||||
|
||||
=== Transfer a task to another workbasket
|
||||
|
||||
A `POST` request is used to transfer a task from one to another workbasket.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/TransferTaskDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/TransferTaskDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
The response-body is essentially the same as for getting a single task. +
|
||||
Therefore for the response fields you can refer to the <<task, single task>>.
|
||||
|
||||
[[paged-request]]
|
||||
== Example for a paged request (using the AbstractPagingController)
|
||||
|
||||
Summary Resources can be requested in a paged format.
|
||||
|
||||
=== Example request
|
||||
|
||||
include::../../../{snippets}/CommonSummaryResourceFields/http-request.adoc[]
|
||||
|
||||
=== Example response
|
||||
|
||||
include::../../../{snippets}/CommonSummaryResourceFields/response-body.adoc[]
|
||||
|
||||
== Classificationdefinition-Resource
|
||||
|
||||
[[classification-definitions]]
|
||||
=== Get all classification definitions
|
||||
|
||||
A `GET` request is used to get all classification definitions.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetAllClassificationdefinitionsDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetAllClassificationdefinitionsDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetAllClassificationdefinitionsDocTest/response-fields.adoc[]
|
||||
|
||||
=== Import new classification-definitions
|
||||
|
||||
A `POST` request is used to import new classification-definitions.
|
||||
|
||||
==== Example Request
|
||||
|
||||
This minimal example shows only the required fields to import a single new classification-definition. The <<classification, classification structure>> shows all possible fields for importing (and therefore creating) new classification-definitions.
|
||||
|
||||
include::../../../{snippets}/ImportClassificationdefinitions/http-request.adoc[]
|
||||
|
||||
==== Request Structure
|
||||
|
||||
include::../../../{snippets}/ImportClassificationdefinitions/request-fields.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/ImportClassificationdefinitions/http-response.adoc[]
|
||||
|
||||
== Workbasketdefinition-Resource
|
||||
|
||||
=== Get all workbasket definitions
|
||||
|
||||
A `GET` request is used to get all workbasket definitions.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasktdefinitionsDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasktdefinitionsDocTest/http-response.adoc[]
|
||||
|
||||
[[workbasket-definitions]]
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetAllWorkbasktdefinitionsDocTest/response-fields.adoc[]
|
||||
|
||||
=== Import new workbasket-definitions
|
||||
|
||||
A `POST` request is used to import new workbasket-definitions.
|
||||
|
||||
==== Example Request
|
||||
|
||||
This minimal example shows only the required fields to import a single new workbasket-definition. The <<workbasket, workbasket structure>> shows all possible fields for importing (and therefore creating) new workbasket-definitions.
|
||||
|
||||
include::../../../{snippets}/ImportWorkbasketdefinitions/http-request.adoc[]
|
||||
|
||||
==== Request Structure
|
||||
|
||||
include::../../../{snippets}/ImportWorkbasketdefinitions/request-fields.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/ImportWorkbasketdefinitions/http-response.adoc[]
|
||||
|
||||
== Monitor-Resource
|
||||
|
||||
=== Get a task status report
|
||||
|
||||
A `GET` request is used to get a task status report.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetTaskStatusReportDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetTaskStatusReportDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetTaskStatusReportDocTest/response-fields.adoc[]
|
||||
|
||||
=== Get a count of tasks sorted by state
|
||||
|
||||
A `GET` request is used to get the number of tasks sorted by state.
|
||||
|
||||
==== Example Request
|
||||
|
||||
include::../../../{snippets}/GetCountByStateDocTest/http-request.adoc[]
|
||||
|
||||
==== Example Response
|
||||
|
||||
include::../../../{snippets}/GetCountByStateDocTest/http-response.adoc[]
|
||||
|
||||
==== Response Structure
|
||||
|
||||
include::../../../{snippets}/GetCountByStateDocTest/response-fields.adoc[]
|
||||
|
||||
== Other Resources (using the TaskanaEngineController)
|
||||
|
||||
[[resource-subsets]]
|
||||
== Resource-Subsets
|
||||
|
||||
These subsets of the full resources are used in the Summary-Resources. +
|
||||
Due to a bug with arrays in Spring-Restdocs the snippets used here are not actually generated using the Summary-Resource but by documenting the corresponding subset of an individual Classification Resource. +
|
||||
Further information at <https://github.com/spring-projects/spring-restdocs/issues/473>
|
||||
|
||||
[[classification-subset]]
|
||||
=== Classification-Subset
|
||||
|
||||
Subset of the <<classification, Classification Resource>>
|
||||
|
||||
include::../../../{snippets}/ClassificationSubset/response-fields.adoc[]
|
||||
|
||||
[[workbasket-subset]]
|
||||
=== Workbasket-Subset
|
||||
|
||||
Subset of the <<workbasket, Workbasket Resource>>
|
||||
|
||||
include::../../../{snippets}/WorkbasketSubset/response-fields.adoc[]
|
||||
|
||||
[[task-subset]]
|
||||
=== Task-Subset
|
||||
|
||||
Subset of the <<task, Task Resource>>
|
||||
|
||||
include::../../../{snippets}/TaskSubset/response-fields.adoc[]
|
||||
|
||||
== Embedded Resources
|
||||
|
||||
Due to a workaround for the same bug as for the <<resource-subsets, Resource-Subsets>> all fields are prefixed with "_embedded.<resource-label>[].".
|
||||
|
||||
[[access-item]]
|
||||
=== Access Items
|
||||
|
||||
The access items hold information about the permissions to the workbaskets.
|
||||
|
||||
include::../../../{snippets}/AccessItemsDocTest/response-fields.adoc[]
|
|
@ -37,11 +37,13 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
|
||||
http.csrf()
|
||||
.disable()
|
||||
.authenticationProvider(jaasAuthProvider())
|
||||
.authorizeRequests()
|
||||
.antMatchers(HttpMethod.GET, "/docs/**")
|
||||
.permitAll()
|
||||
.antMatchers(HttpMethod.GET, "/**")
|
||||
.authenticated()
|
||||
.and()
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class AbstractPagingControllerRestDocumentation {
|
||||
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private HashMap<String, String> pagingFieldDescriptionsMap = new HashMap<String, String>();
|
||||
|
||||
private FieldDescriptor[] pagingFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
pagingFieldDescriptionsMap.put("page", "Contains metainfo if there are multiple pages, else it is null");
|
||||
pagingFieldDescriptionsMap.put("page.size", "Number of items per page");
|
||||
pagingFieldDescriptionsMap.put("page.totalElements", "Total number of items");
|
||||
pagingFieldDescriptionsMap.put("page.totalPages", "Number of pages");
|
||||
pagingFieldDescriptionsMap.put("page.number", "Current page number");
|
||||
pagingFieldDescriptionsMap.put("_links.allClassifications.href", "Link to the main Summary-Resourc");
|
||||
pagingFieldDescriptionsMap.put("_links.first.href", "Link to first page");
|
||||
pagingFieldDescriptionsMap.put("_links.last.href", "Link to last page");
|
||||
pagingFieldDescriptionsMap.put("_links.prev.href", "Link to previous page");
|
||||
pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page");
|
||||
|
||||
pagingFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("_embedded.classificationSummaryResourceList").ignored(),
|
||||
fieldWithPath("_links").ignored(),
|
||||
fieldWithPath("_links.self").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page").description(pagingFieldDescriptionsMap.get("page")),
|
||||
fieldWithPath("page.size").description(pagingFieldDescriptionsMap.get("page.size")),
|
||||
fieldWithPath("page.totalElements").description(pagingFieldDescriptionsMap.get("page.totalElements")),
|
||||
fieldWithPath("page.totalPages").description(pagingFieldDescriptionsMap.get("page.totalPages")),
|
||||
fieldWithPath("page.number").description(pagingFieldDescriptionsMap.get("page.number")),
|
||||
fieldWithPath("_links.allClassifications.href").description(pagingFieldDescriptionsMap.get("_links.allClassifications.href")),
|
||||
fieldWithPath("_links.first.href").description(pagingFieldDescriptionsMap.get("_links.first.href")),
|
||||
fieldWithPath("_links.last.href").description(pagingFieldDescriptionsMap.get("_links.last.href")),
|
||||
fieldWithPath("_links.prev.href").description(pagingFieldDescriptionsMap.get("_links.prev.href")),
|
||||
fieldWithPath("_links.next.href").description(pagingFieldDescriptionsMap.get("_links.next.href"))
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commonSummaryResourceFieldsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications?page=2&page-size=5")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("CommonSummaryResourceFields",
|
||||
responseFields(pagingFieldDescriptors)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class ClassificationControllerRestDocumentation {
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private HashMap<String, String> classificationFieldDescriptionsMap = new HashMap<String, String>();
|
||||
|
||||
private FieldDescriptor[] allClassificationsFieldDescriptors;
|
||||
private FieldDescriptor[] classificationFieldDescriptors;
|
||||
private FieldDescriptor[] classificationSubsetFieldDescriptors;
|
||||
private FieldDescriptor[] createClassificationFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
classificationFieldDescriptionsMap.put("classificationId", "Unique Id");
|
||||
classificationFieldDescriptionsMap.put("key", "The key of the classification. This is typically an externally known code or abbreviation of the classification");
|
||||
classificationFieldDescriptionsMap.put("parentId", "The parent classification. Empty string (\"\") if this is a root classification.");
|
||||
classificationFieldDescriptionsMap.put("category", "The category of the classification (MANUAL, EXTERNAL, AUTOMATIC, PROCESS)");
|
||||
classificationFieldDescriptionsMap.put("type", "The type of classification (TASK, DOCUMENT)");
|
||||
classificationFieldDescriptionsMap.put("domain", "The domain for which this classification is specified");
|
||||
classificationFieldDescriptionsMap.put("isValidInDomain", "True, if this classification to objects in this domain");
|
||||
classificationFieldDescriptionsMap.put("created", "The creation timestamp of the classification in the system");
|
||||
classificationFieldDescriptionsMap.put("modified", "The timestamp of the last modification date");
|
||||
classificationFieldDescriptionsMap.put("name", "The name of the classification");
|
||||
classificationFieldDescriptionsMap.put("description", "The description of the classification");
|
||||
classificationFieldDescriptionsMap.put("priority", "The priority of the classification");
|
||||
classificationFieldDescriptionsMap.put("serviceLevel", "The service level of the classification. This is stated according to ISO 8601");
|
||||
classificationFieldDescriptionsMap.put("applicationEntryPoint", "The logical name of the entry point, the task list application should redirect to work on a task of this classification");
|
||||
classificationFieldDescriptionsMap.put("custom1", "A custom property with name \"1\"");
|
||||
classificationFieldDescriptionsMap.put("custom2", "A custom property with name \"2\"");
|
||||
classificationFieldDescriptionsMap.put("custom3", "A custom property with name \"3\"");
|
||||
classificationFieldDescriptionsMap.put("custom4", "A custom property with name \"4\"");
|
||||
classificationFieldDescriptionsMap.put("custom5", "A custom property with name \"5\"");
|
||||
classificationFieldDescriptionsMap.put("custom6", "A custom property with name \"6\"");
|
||||
classificationFieldDescriptionsMap.put("custom7", "A custom property with name \"7\"");
|
||||
classificationFieldDescriptionsMap.put("custom8", "A custom property with name \"8\"");
|
||||
classificationFieldDescriptionsMap.put("validInDomain", "");
|
||||
classificationFieldDescriptionsMap.put("_links.getAllClassifications.href", "Link to all classifications");
|
||||
classificationFieldDescriptionsMap.put("_links.getAllClassifications.templated", "");
|
||||
|
||||
allClassificationsFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("_embedded.classificationSummaryResourceList").description("An Array of <<classification-subset, Classification-Subsets>>"),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page").ignored()
|
||||
};
|
||||
|
||||
classificationFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("classificationId").description(classificationFieldDescriptionsMap.get("classificationId")),
|
||||
fieldWithPath("key").description(classificationFieldDescriptionsMap.get("key")),
|
||||
fieldWithPath("parentId").description(classificationFieldDescriptionsMap.get("parentId")),
|
||||
fieldWithPath("category").description(classificationFieldDescriptionsMap.get("category")),
|
||||
fieldWithPath("type").description(classificationFieldDescriptionsMap.get("type")),
|
||||
fieldWithPath("domain").description(classificationFieldDescriptionsMap.get("domain")),
|
||||
fieldWithPath("isValidInDomain").description(classificationFieldDescriptionsMap.get("isValidInDomain")),
|
||||
fieldWithPath("created").description(classificationFieldDescriptionsMap.get("created")),
|
||||
fieldWithPath("modified").description(classificationFieldDescriptionsMap.get("modified")),
|
||||
fieldWithPath("name").description(classificationFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("description").description(classificationFieldDescriptionsMap.get("description")),
|
||||
fieldWithPath("priority").description(classificationFieldDescriptionsMap.get("priority")),
|
||||
fieldWithPath("serviceLevel").description(classificationFieldDescriptionsMap.get("serviceLevel")),
|
||||
fieldWithPath("applicationEntryPoint").description(classificationFieldDescriptionsMap.get("applicationEntryPoint")),
|
||||
fieldWithPath("custom1").description(classificationFieldDescriptionsMap.get("custom1")),
|
||||
fieldWithPath("custom2").description(classificationFieldDescriptionsMap.get("custom2")),
|
||||
fieldWithPath("custom3").description(classificationFieldDescriptionsMap.get("custom3")),
|
||||
fieldWithPath("custom4").description(classificationFieldDescriptionsMap.get("custom4")),
|
||||
fieldWithPath("custom5").description(classificationFieldDescriptionsMap.get("custom5")),
|
||||
fieldWithPath("custom6").description(classificationFieldDescriptionsMap.get("custom6")),
|
||||
fieldWithPath("custom7").description(classificationFieldDescriptionsMap.get("custom7")),
|
||||
fieldWithPath("custom8").description(classificationFieldDescriptionsMap.get("custom8")),
|
||||
fieldWithPath("validInDomain").description(classificationFieldDescriptionsMap.get("validInDomain")),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
classificationSubsetFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("classificationId").description(classificationFieldDescriptionsMap.get("classificationId")),
|
||||
fieldWithPath("key").description(classificationFieldDescriptionsMap.get("key")),
|
||||
fieldWithPath("parentId").description(classificationFieldDescriptionsMap.get("parentId")),
|
||||
fieldWithPath("category").description(classificationFieldDescriptionsMap.get("category")),
|
||||
fieldWithPath("type").description(classificationFieldDescriptionsMap.get("type")),
|
||||
fieldWithPath("domain").description(classificationFieldDescriptionsMap.get("domain")),
|
||||
fieldWithPath("isValidInDomain").ignored(),
|
||||
fieldWithPath("created").ignored(),
|
||||
fieldWithPath("modified").ignored(),
|
||||
fieldWithPath("name").description(classificationFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("description").ignored(),
|
||||
fieldWithPath("priority").description(classificationFieldDescriptionsMap.get("priority")),
|
||||
fieldWithPath("serviceLevel").ignored(),
|
||||
fieldWithPath("applicationEntryPoint").ignored(),
|
||||
fieldWithPath("custom1").ignored(),
|
||||
fieldWithPath("custom2").ignored(),
|
||||
fieldWithPath("custom3").ignored(),
|
||||
fieldWithPath("custom4").ignored(),
|
||||
fieldWithPath("custom5").ignored(),
|
||||
fieldWithPath("custom6").ignored(),
|
||||
fieldWithPath("custom7").ignored(),
|
||||
fieldWithPath("custom8").ignored(),
|
||||
fieldWithPath("validInDomain").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
createClassificationFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("category").type("String").description("The category of the classification (MANUAL, EXTERNAL, AUTOMATIC, PROCESS)").optional(),
|
||||
fieldWithPath("domain").description("The domain for which this classification is specified"),
|
||||
fieldWithPath("key").description("The key of the classification. This is typically an externally known code or abbreviation of the classification"),
|
||||
fieldWithPath("name").type("String").description("The name of the classification").optional(),
|
||||
fieldWithPath("type").type("String").description("The type of classification (TASK, DOCUMENT)").optional(),
|
||||
fieldWithPath("parentId").type("String").description(classificationFieldDescriptionsMap.get("parentId")).optional(),
|
||||
fieldWithPath("isValidInDomain").type("Boolean").description(classificationFieldDescriptionsMap.get("isValidInDomain")).optional(),
|
||||
fieldWithPath("created").type("String").description(classificationFieldDescriptionsMap.get("created")).optional(),
|
||||
fieldWithPath("modified").type("String").description(classificationFieldDescriptionsMap.get("modified")).optional(),
|
||||
fieldWithPath("description").type("String").description(classificationFieldDescriptionsMap.get("description")).optional(),
|
||||
fieldWithPath("priority").type("Number").description(classificationFieldDescriptionsMap.get("priority")).optional(),
|
||||
fieldWithPath("serviceLevel").type("String").description(classificationFieldDescriptionsMap.get("serviceLevel")).optional(),
|
||||
fieldWithPath("applicationEntryPoint").type("String").description(classificationFieldDescriptionsMap.get("applicationEntryPoint")).optional(),
|
||||
fieldWithPath("custom1").type("String").description(classificationFieldDescriptionsMap.get("custom1")).optional(),
|
||||
fieldWithPath("custom2").type("String").description(classificationFieldDescriptionsMap.get("custom2")).optional(),
|
||||
fieldWithPath("custom3").type("String").description(classificationFieldDescriptionsMap.get("custom3")).optional(),
|
||||
fieldWithPath("custom4").type("String").description(classificationFieldDescriptionsMap.get("custom4")).optional(),
|
||||
fieldWithPath("custom5").type("String").description(classificationFieldDescriptionsMap.get("custom5")).optional(),
|
||||
fieldWithPath("custom6").type("String").description(classificationFieldDescriptionsMap.get("custom6")).optional(),
|
||||
fieldWithPath("custom7").type("String").description(classificationFieldDescriptionsMap.get("custom7")).optional(),
|
||||
fieldWithPath("custom8").type("String").description(classificationFieldDescriptionsMap.get("custom8")).optional(),
|
||||
fieldWithPath("validInDomain").type("Boolean").description(classificationFieldDescriptionsMap.get("validInDomain")).optional(),
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllClassificationsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications?domain=DOMAIN_B")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllClassificationsDocTest",
|
||||
responseFields(allClassificationsFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSpecificClassificationDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetSpecificClassificationDocTest",
|
||||
responseFields(classificationFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classificationSubsetDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("ClassificationSubset",
|
||||
responseFields(classificationSubsetFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createAndDeleteClassificationDocTest() throws Exception {
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/classifications")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"key\":\"Key0815casdgdgh\", \"domain\":\"DOMAIN_B\"}")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated())
|
||||
.andDo(MockMvcRestDocumentation.document("CreateClassificationDocTest",
|
||||
requestFields(createClassificationFieldDescriptors),
|
||||
responseFields(classificationFieldDescriptors)))
|
||||
.andReturn();
|
||||
|
||||
String newId = result.getResponse().getContentAsString().substring(21, 61);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/classifications/" + newId)
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteClassificationDocTest"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateClassificationDocTest() throws Exception {
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String originalTask = content.toString();
|
||||
String modifiedTask = new String(originalTask.toString());
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.put("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.contentType("application/json")
|
||||
.content(modifiedTask))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("UpdateClassificationDocTest",
|
||||
requestFields(classificationFieldDescriptors),
|
||||
responseFields(classificationFieldDescriptors)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
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.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class ClassificationDefinitionControllerRestDocumentation {
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private FieldDescriptor[] classificationdefinitionsFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
classificationdefinitionsFieldDescriptors = new FieldDescriptor[] {
|
||||
subsectionWithPath("[]").description("An array of <<classification, classifications>>")
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllClassificationdefinitions() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classificationdefinitions")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllClassificationdefinitionsDocTest",
|
||||
responseFields(classificationdefinitionsFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importClassificationdefinition() throws Exception {
|
||||
String definitionString = "[{\"key\":\"Key0815\", \"domain\":\"DOMAIN_B\"}]";
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/classificationdefinitions/import")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.contentType("application/json")
|
||||
.content(definitionString))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("ImportClassificationdefinitions",
|
||||
requestFields(subsectionWithPath("[]").description("An array of <<classification-definitions, classifications>>"))));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class CommonRestDocumentation {
|
||||
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private HashMap<String, String> selfLinkFieldDescriptionsMap = new HashMap<String, String>();
|
||||
|
||||
private FieldDescriptor[] selfLinkFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
selfLinkFieldDescriptionsMap.put("_links", "Links section");
|
||||
selfLinkFieldDescriptionsMap.put("_links.self", "Link to self");
|
||||
selfLinkFieldDescriptionsMap.put("_links.self.href", "Link to instance");
|
||||
|
||||
selfLinkFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("classificationId").ignored(),
|
||||
fieldWithPath("key").ignored(),
|
||||
fieldWithPath("parentId").ignored(),
|
||||
fieldWithPath("category").ignored(),
|
||||
fieldWithPath("type").ignored(),
|
||||
fieldWithPath("domain").ignored(),
|
||||
fieldWithPath("isValidInDomain").ignored(),
|
||||
fieldWithPath("created").ignored(),
|
||||
fieldWithPath("modified").ignored(),
|
||||
fieldWithPath("name").ignored(),
|
||||
fieldWithPath("description").ignored(),
|
||||
fieldWithPath("priority").ignored(),
|
||||
fieldWithPath("serviceLevel").ignored(),
|
||||
fieldWithPath("applicationEntryPoint").ignored(),
|
||||
fieldWithPath("custom1").ignored(),
|
||||
fieldWithPath("custom2").ignored(),
|
||||
fieldWithPath("custom3").ignored(),
|
||||
fieldWithPath("custom4").ignored(),
|
||||
fieldWithPath("custom5").ignored(),
|
||||
fieldWithPath("custom6").ignored(),
|
||||
fieldWithPath("custom7").ignored(),
|
||||
fieldWithPath("custom8").ignored(),
|
||||
fieldWithPath("validInDomain").ignored(),
|
||||
fieldWithPath("_links").description(selfLinkFieldDescriptionsMap.get("_links")),
|
||||
fieldWithPath("_links.self").description(selfLinkFieldDescriptionsMap.get("_links.self")),
|
||||
fieldWithPath("_links.self.href").description(selfLinkFieldDescriptionsMap.get("_links.self.href"))
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commonFieldsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("CommonFields",
|
||||
responseFields(selfLinkFieldDescriptors)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
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.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class MonitorControllerRestDocumentation {
|
||||
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private FieldDescriptor[] taskStatusReportFieldDescriptors;
|
||||
private FieldDescriptor[] countByStateFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
taskStatusReportFieldDescriptors = new FieldDescriptor[] {
|
||||
fieldWithPath("meta").description("Object holding metainfo on the report"),
|
||||
fieldWithPath("meta.name").description("Name of the report"),
|
||||
fieldWithPath("meta.date").description("Date of the report creation"),
|
||||
fieldWithPath("meta.header").description("Column-headers of the report"),
|
||||
fieldWithPath("meta.rowDesc").description("Descriptions for the rows the report"),
|
||||
fieldWithPath("meta.totalDesc").description("Description for the report itself"),
|
||||
subsectionWithPath("rows").description("Object holding the rows of the report.\n"
|
||||
+ "For the exact structure please check the example response above"),
|
||||
fieldWithPath("sumRow").description("Object holding the sums in the columns over all rows"),
|
||||
subsectionWithPath("sumRow.cells").description("Contains the accumulated numbers over all columns defined in meta.header.\n"
|
||||
+ "For the exact structure please check the example response above"),
|
||||
fieldWithPath("sumRow.total").description("Total number of tasks"),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
countByStateFieldDescriptors = new FieldDescriptor[] {
|
||||
fieldWithPath("[]..state").description("The state the tasks are in"),
|
||||
fieldWithPath("[]..counter").description("Number of tasks in the corresponding state")
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTaskStatusReport() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/monitor/taskStatusReport")
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest",
|
||||
responseFields(taskStatusReportFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCountByState() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/monitor/countByState?states=READY,CLAIMED,COMPLETED")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetCountByStateDocTest",
|
||||
responseFields(countByStateFieldDescriptors)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,452 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class TaskControllerRestDocumentation {
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private HashMap<String, String> taskFieldDescriptionsMap = new HashMap<String, String>();
|
||||
|
||||
private FieldDescriptor[] allTasksFieldDescriptors;
|
||||
private FieldDescriptor[] taskFieldDescriptors;
|
||||
private FieldDescriptor[] taskSubsetFieldDescriptors;
|
||||
private FieldDescriptor[] createTaskFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
taskFieldDescriptionsMap.put("taskId", "Unique ID");
|
||||
taskFieldDescriptionsMap.put("created", "The creation timestamp of the task in the system.");
|
||||
taskFieldDescriptionsMap.put("claimed", "The timestamp of the last claim-operation on the task");
|
||||
taskFieldDescriptionsMap.put("completed", "The timestamp of the completion of the task");
|
||||
taskFieldDescriptionsMap.put("modified", "Timestamp of the last modification of the task");
|
||||
taskFieldDescriptionsMap.put("planned", "Planned start of the task. The actual completion of the task should be between PLANNED and DUE.");
|
||||
taskFieldDescriptionsMap.put("due", "Timestamp when the task is due. The actual completion of the task should be between PLANNED and DUE.");
|
||||
taskFieldDescriptionsMap.put("name", "The name of the task");
|
||||
taskFieldDescriptionsMap.put("creator", "");
|
||||
taskFieldDescriptionsMap.put("description", "The description of the task");
|
||||
taskFieldDescriptionsMap.put("note", "note");
|
||||
taskFieldDescriptionsMap.put("priority", "The priority of the task");
|
||||
taskFieldDescriptionsMap.put("state", "he state of the task. See (...)");
|
||||
taskFieldDescriptionsMap.put("classificationSummaryResource", "The <<classification-subset, Classification>> of the task");
|
||||
taskFieldDescriptionsMap.put("workbasketSummaryResource", "The <<workbasket-subset, Workbasket>> of the task");
|
||||
taskFieldDescriptionsMap.put("businessProcessId", "");
|
||||
taskFieldDescriptionsMap.put("parentBusinessProcessId", "");
|
||||
taskFieldDescriptionsMap.put("owner", "The owner of the tasks. The owner is set upon claiming of the task.");
|
||||
taskFieldDescriptionsMap.put("primaryObjRef.id", "");
|
||||
taskFieldDescriptionsMap.put("primaryObjRef.company", "The company referenced primary object belongs to.");
|
||||
taskFieldDescriptionsMap.put("primaryObjRef.system", "The (kind of) system, the object resides in (e.g. SAP, MySystem A, ...) ");
|
||||
taskFieldDescriptionsMap.put("primaryObjRef.systemInstance", "The instance of the system, the object resides in.");
|
||||
taskFieldDescriptionsMap.put("primaryObjRef.type", "The type of the reference (contract, claim, policy, customer, ...)");
|
||||
taskFieldDescriptionsMap.put("primaryObjRef.value", "The value of the primary object reference");
|
||||
taskFieldDescriptionsMap.put("customAttributes", "A container for all additional information on the task in JSON representation");
|
||||
taskFieldDescriptionsMap.put("attachments", "");
|
||||
taskFieldDescriptionsMap.put("custom1", "A custom property with name \"1\"");
|
||||
taskFieldDescriptionsMap.put("custom2", "A custom property with name \"2\"");
|
||||
taskFieldDescriptionsMap.put("custom3", "A custom property with name \"3\"");
|
||||
taskFieldDescriptionsMap.put("custom4", "A custom property with name \"4\"");
|
||||
taskFieldDescriptionsMap.put("custom5", "A custom property with name \"5\"");
|
||||
taskFieldDescriptionsMap.put("custom6", "A custom property with name \"6\"");
|
||||
taskFieldDescriptionsMap.put("custom7", "A custom property with name \"7\"");
|
||||
taskFieldDescriptionsMap.put("custom8", "A custom property with name \"8\"");
|
||||
taskFieldDescriptionsMap.put("custom9", "A custom property with name \"9\"");
|
||||
taskFieldDescriptionsMap.put("custom10", "A custom property with name \"10\"");
|
||||
taskFieldDescriptionsMap.put("custom11", "A custom property with name \"11\"");
|
||||
taskFieldDescriptionsMap.put("custom12", "A custom property with name \"12\"");
|
||||
taskFieldDescriptionsMap.put("custom13", "A custom property with name \"13\"");
|
||||
taskFieldDescriptionsMap.put("custom14", "A custom property with name \"14\"");
|
||||
taskFieldDescriptionsMap.put("custom15", "A custom property with name \"15\"");
|
||||
taskFieldDescriptionsMap.put("custom16", "A custom property with name \"16\"");
|
||||
taskFieldDescriptionsMap.put("read", "Indicator if the task has been read");
|
||||
taskFieldDescriptionsMap.put("transferred", "Indicator if the task has been transferred");
|
||||
|
||||
allTasksFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("_embedded.tasks").description("An Array of <<task-subset, Task-Subsets>>"),
|
||||
fieldWithPath("_links").ignored(),
|
||||
fieldWithPath("_links.self").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page").ignored()
|
||||
};
|
||||
|
||||
taskFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")),
|
||||
fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")),
|
||||
fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String"),
|
||||
fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"),
|
||||
fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"),
|
||||
fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"),
|
||||
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
|
||||
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
|
||||
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")),
|
||||
fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"),
|
||||
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
|
||||
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
|
||||
subsectionWithPath("classificationSummaryResource").description(taskFieldDescriptionsMap.get("classificationSummaryResource")),
|
||||
subsectionWithPath("workbasketSummaryResource").description(taskFieldDescriptionsMap.get("workbasketSummaryResource")),
|
||||
fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")),
|
||||
fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
|
||||
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"),
|
||||
fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String"),
|
||||
fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
|
||||
fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
|
||||
fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
|
||||
fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
|
||||
fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")),
|
||||
fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")),
|
||||
fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")),
|
||||
fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String"),
|
||||
fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String"),
|
||||
fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String"),
|
||||
fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String"),
|
||||
fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String"),
|
||||
fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String"),
|
||||
fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String"),
|
||||
fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String"),
|
||||
fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String"),
|
||||
fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String"),
|
||||
fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String"),
|
||||
fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String"),
|
||||
fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String"),
|
||||
fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String"),
|
||||
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String"),
|
||||
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String"),
|
||||
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")),
|
||||
fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
taskSubsetFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")),
|
||||
fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")),
|
||||
fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")),
|
||||
fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"),
|
||||
fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"),
|
||||
fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"),
|
||||
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
|
||||
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
|
||||
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")),
|
||||
fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"),
|
||||
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
|
||||
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
|
||||
subsectionWithPath("classificationSummaryResource").description(taskFieldDescriptionsMap.get("classificationSummaryResource")),
|
||||
subsectionWithPath("workbasketSummaryResource").description(taskFieldDescriptionsMap.get("workbasketSummaryResource")),
|
||||
fieldWithPath("businessProcessId").ignored(),
|
||||
fieldWithPath("parentBusinessProcessId").ignored(),
|
||||
fieldWithPath("owner").ignored(),
|
||||
fieldWithPath("primaryObjRef.id").ignored(),
|
||||
fieldWithPath("primaryObjRef.company").ignored(),
|
||||
fieldWithPath("primaryObjRef.system").ignored(),
|
||||
fieldWithPath("primaryObjRef.systemInstance").ignored(),
|
||||
fieldWithPath("primaryObjRef.type").ignored(),
|
||||
fieldWithPath("primaryObjRef.value").ignored(),
|
||||
fieldWithPath("customAttributes").ignored(),
|
||||
fieldWithPath("attachments").ignored(),
|
||||
fieldWithPath("custom1").ignored(),
|
||||
fieldWithPath("custom2").ignored(),
|
||||
fieldWithPath("custom3").ignored(),
|
||||
fieldWithPath("custom4").ignored(),
|
||||
fieldWithPath("custom5").ignored(),
|
||||
fieldWithPath("custom6").ignored(),
|
||||
fieldWithPath("custom7").ignored(),
|
||||
fieldWithPath("custom8").ignored(),
|
||||
fieldWithPath("custom9").ignored(),
|
||||
fieldWithPath("custom10").ignored(),
|
||||
fieldWithPath("custom11").ignored(),
|
||||
fieldWithPath("custom12").ignored(),
|
||||
fieldWithPath("custom13").ignored(),
|
||||
fieldWithPath("custom14").ignored(),
|
||||
fieldWithPath("custom15").ignored(),
|
||||
fieldWithPath("custom16").ignored(),
|
||||
fieldWithPath("read").ignored(),
|
||||
fieldWithPath("transferred").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
createTaskFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("classificationSummaryResource").description("The new classificationSummaryResource for the task"),
|
||||
subsectionWithPath("workbasketSummaryResource").description("The new workbasketSummaryResource for the task"),
|
||||
fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
|
||||
fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
|
||||
fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
|
||||
fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
|
||||
fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")),
|
||||
fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")).type("String").optional(),
|
||||
fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String").optional(),
|
||||
fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String").optional(),
|
||||
fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String").optional(),
|
||||
fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String").optional(),
|
||||
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String").optional(),
|
||||
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")).type("String").optional(),
|
||||
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")).type("String").optional(),
|
||||
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")).type("String").optional(),
|
||||
fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note").type("String").optional(),
|
||||
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")).type("String").optional(),
|
||||
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")).type("String").optional(),
|
||||
fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")).type("String").optional(),
|
||||
fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")).type("String").optional(),
|
||||
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String").optional(),
|
||||
fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String").optional(),
|
||||
fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")).type("Object").optional(),
|
||||
fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")).type("Array").optional(),
|
||||
fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String").optional(),
|
||||
fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String").optional(),
|
||||
fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String").optional(),
|
||||
fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String").optional(),
|
||||
fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String").optional(),
|
||||
fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String").optional(),
|
||||
fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String").optional(),
|
||||
fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String").optional(),
|
||||
fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String").optional(),
|
||||
fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String").optional(),
|
||||
fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String").optional(),
|
||||
fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String").optional(),
|
||||
fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String").optional(),
|
||||
fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String").optional(),
|
||||
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String").optional(),
|
||||
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String").optional(),
|
||||
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")).type("Boolean").optional(),
|
||||
fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")).type("Boolean").optional()
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllTasksDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/tasks?por.type=VNR&por.value=22334455")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllTasksDocTest",
|
||||
responseFields(allTasksFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSpecificTaskDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetSpecificTaskDocTest",
|
||||
responseFields(taskFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void taskSubSetDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("TaskSubset",
|
||||
responseFields(taskSubsetFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateTaskDocTest() throws Exception{
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String originalTask = content.toString();
|
||||
String modifiedTask = new String(originalTask.toString());
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.put("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.contentType("application/json")
|
||||
.content(modifiedTask))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("UpdateTaskDocTest",
|
||||
requestFields(taskFieldDescriptors),
|
||||
responseFields(taskFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createAndDeleteTaskDocTest() throws Exception {
|
||||
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," +
|
||||
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," +
|
||||
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated())
|
||||
.andDo(MockMvcRestDocumentation.document("CreateTaskDocTest",
|
||||
requestFields(createTaskFieldDescriptors),
|
||||
responseFields(taskFieldDescriptors)))
|
||||
.andReturn();
|
||||
|
||||
String newId = result.getResponse().getContentAsString().substring(11, 51);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void claimTaskDocTest() throws Exception {
|
||||
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," +
|
||||
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," +
|
||||
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated())
|
||||
.andDo(MockMvcRestDocumentation.document("temp"))
|
||||
.andReturn();
|
||||
|
||||
String newId = result.getResponse().getContentAsString().substring(11, 51);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/claim")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.content("{}"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("ClaimTaskDocTest",
|
||||
responseFields(taskFieldDescriptors)));
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completeTaskDocTest() throws Exception {
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," +
|
||||
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," +
|
||||
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated())
|
||||
.andDo(MockMvcRestDocumentation.document("temp"))
|
||||
.andReturn();
|
||||
|
||||
String newId = result.getResponse().getContentAsString().substring(11, 51);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/complete")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.content("{}"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("CompleteTaskDocTest",
|
||||
responseFields(taskFieldDescriptors)));
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transferTaskDocTest() throws Exception {
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," +
|
||||
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," +
|
||||
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated())
|
||||
.andDo(MockMvcRestDocumentation.document("TransferTaskDocTest",
|
||||
responseFields(taskFieldDescriptors)))
|
||||
.andReturn();
|
||||
|
||||
String newId = result.getResponse().getContentAsString().substring(11, 51);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/transfer/WBI:100000000000000000000000000000000001")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("TransferTaskDocTest",
|
||||
responseFields(taskFieldDescriptors)));
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class TaskanaEngineControllerRestDocumentation {
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private FieldDescriptor[] allDomainsFieldDescriptors;
|
||||
private FieldDescriptor[] allClassificationCategoriesFieldDescriptors;
|
||||
private FieldDescriptor[] allClassificationTypesFieldDescriptors;
|
||||
private FieldDescriptor[] currentUserInfoFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
allDomainsFieldDescriptors = new FieldDescriptor[] {
|
||||
fieldWithPath("[]").description("An array with the domain-names as strings")
|
||||
};
|
||||
|
||||
allClassificationCategoriesFieldDescriptors = new FieldDescriptor[] {
|
||||
fieldWithPath("[]").description("An array with the classification-categories as strings")
|
||||
};
|
||||
|
||||
allClassificationTypesFieldDescriptors = new FieldDescriptor[] {
|
||||
fieldWithPath("[]").description("An array with the classification-types as strings")
|
||||
};
|
||||
|
||||
currentUserInfoFieldDescriptors = new FieldDescriptor[] {
|
||||
fieldWithPath("userId").description("Id of the current user"),
|
||||
fieldWithPath("groupIds").description("An array with the groups the current user is part of as strings"),
|
||||
fieldWithPath("roles").description("An array with the roles the current user is granted")
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllDomainsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/domains")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllDomainsDocTest",
|
||||
responseFields(allDomainsFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllClassificationCategoriesDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classification-categories")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllClassificationCategoriesDocTest",
|
||||
responseFields(allClassificationCategoriesFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllClassificationTypesDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classification-types")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllClassificationTypesDocTest",
|
||||
responseFields(allClassificationTypesFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentUserInfo() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/current-user-info")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetCurrentUserInfoDocTest",
|
||||
responseFields(currentUserInfoFieldDescriptors)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,361 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class WorkbasketControllerRestDocumentation {
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
// HashMaps to store the field descriptions centrally for multiple uses
|
||||
private HashMap<String, String> workbasketFieldDescriptionsMap = new HashMap<String, String>();
|
||||
private HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<String, String>();
|
||||
|
||||
private FieldDescriptor[] allWorkbasketsFieldDescriptors;
|
||||
private FieldDescriptor[] workbasketFieldDescriptors;
|
||||
private FieldDescriptor[] workbasketSubsetFieldDescriptors;
|
||||
private FieldDescriptor[] allWorkbasketAccessItemsFieldDescriptors;
|
||||
private FieldDescriptor[] accessItemFieldDescriptors;
|
||||
private FieldDescriptor[] allDistributionTargetsFieldDescriptors;
|
||||
private FieldDescriptor[] createWorkbasketFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
workbasketFieldDescriptionsMap.put("workbasketId", "Unique ID");
|
||||
workbasketFieldDescriptionsMap.put("key", "");
|
||||
workbasketFieldDescriptionsMap.put("name", "The name of the workbasket");
|
||||
workbasketFieldDescriptionsMap.put("domain", "");
|
||||
workbasketFieldDescriptionsMap.put("type", "");
|
||||
workbasketFieldDescriptionsMap.put("description", "The description of the workbasket");
|
||||
workbasketFieldDescriptionsMap.put("owner", "The owner of the workbasket. The owner is responsible for the on-time completion of all tasks in the workbasket.");
|
||||
workbasketFieldDescriptionsMap.put("orgLevel1", "The first Org Level (the top one)\nThe Org Level is an association with an org hierarchie level in the organization. The values are used for monitoring and statistical purposes and should reflect the responsibility of the tasks in the workbasket.");
|
||||
workbasketFieldDescriptionsMap.put("orgLevel2", "The second Org Level");
|
||||
workbasketFieldDescriptionsMap.put("orgLevel3", "The third Org Level");
|
||||
workbasketFieldDescriptionsMap.put("orgLevel4", "The fourth Org Level (the lowest one).");
|
||||
workbasketFieldDescriptionsMap.put("created", "The creation timestamp of the workbasket in the system.");
|
||||
workbasketFieldDescriptionsMap.put("modified", "Timestamp of the last modification of the workbasket");
|
||||
workbasketFieldDescriptionsMap.put("custom1", "A custom property with name \"1\"");
|
||||
workbasketFieldDescriptionsMap.put("custom2", "A custom property with name \"2\"");
|
||||
workbasketFieldDescriptionsMap.put("custom3", "A custom property with name \"3\"");
|
||||
workbasketFieldDescriptionsMap.put("custom4", "A custom property with name \"4\"");
|
||||
workbasketFieldDescriptionsMap.put("_links.distributionTargets.href", "The Distribution-Targets of the workbasket");
|
||||
workbasketFieldDescriptionsMap.put("_links.removeDistributionTargets.href", "Link to remove all distribution-targets from the workbasket");
|
||||
workbasketFieldDescriptionsMap.put("_links.accessItems.href", "The Access-Items of the workbasket");
|
||||
workbasketFieldDescriptionsMap.put("_links.allWorkbaskets.href", "Link to all workbaskets");
|
||||
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketId", "The workbasket");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId", "The access id, this ACL entry refers to. This could be either a userid or a full qualified group id (both lower case)");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessName", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead", "The permission to read the information about the workbasket");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen", "The permission to view the content (the tasks) of a workbasket");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permAppend", "The permission to add tasks to the workbasket (required for creation and tranferring of tasks)");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer", "The permission to transfer tasks (out of the current workbasket)");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute", "The permission to distribute tasks from the workbasket");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom1", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom2", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom3", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom4", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom5", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom6", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom7", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom8", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom9", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom10", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom11", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom12", "");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems._links.workbasket.href", "Link to the workbasket");
|
||||
|
||||
allWorkbasketsFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("_embedded.workbaskets").description("An Array of <<workbasket-subset, Workbasket-Subsets>>"),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page").ignored()
|
||||
};
|
||||
|
||||
workbasketFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("workbasketId").description(workbasketFieldDescriptionsMap.get("workbasketId")),
|
||||
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
|
||||
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
|
||||
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
|
||||
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")),
|
||||
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")),
|
||||
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
|
||||
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
|
||||
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
|
||||
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
|
||||
fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created")),
|
||||
fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified")),
|
||||
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")),
|
||||
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")),
|
||||
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")),
|
||||
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")),
|
||||
fieldWithPath("_links.distributionTargets.href").description(workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")),
|
||||
fieldWithPath("_links.removeDistributionTargets.href").description(workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")),
|
||||
fieldWithPath("_links.accessItems.href").description(workbasketFieldDescriptionsMap.get("_links.accessItems.href")),
|
||||
fieldWithPath("_links.allWorkbaskets.href").description(workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
workbasketSubsetFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("workbasketId").description(workbasketFieldDescriptionsMap.get("workbasketId")),
|
||||
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
|
||||
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
|
||||
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
|
||||
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")),
|
||||
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")),
|
||||
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
|
||||
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
|
||||
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
|
||||
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
|
||||
fieldWithPath("created").ignored(),
|
||||
fieldWithPath("modified").ignored(),
|
||||
fieldWithPath("custom1").ignored(),
|
||||
fieldWithPath("custom2").ignored(),
|
||||
fieldWithPath("custom3").ignored(),
|
||||
fieldWithPath("custom4").ignored(),
|
||||
fieldWithPath("_links.distributionTargets.href").ignored(),
|
||||
fieldWithPath("_links.removeDistributionTargets.href").ignored(),
|
||||
fieldWithPath("_links.accessItems.href").ignored(),
|
||||
fieldWithPath("_links.allWorkbaskets.href").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
accessItemFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
fieldWithPath("_embedded.accessItems[].accessItemId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")),
|
||||
fieldWithPath("_embedded.accessItems[].workbasketId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")),
|
||||
fieldWithPath("_embedded.accessItems[].accessId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")),
|
||||
fieldWithPath("_embedded.accessItems[].accessName").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")),
|
||||
fieldWithPath("_embedded.accessItems[].permRead").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")),
|
||||
fieldWithPath("_embedded.accessItems[].permOpen").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")),
|
||||
fieldWithPath("_embedded.accessItems[].permAppend").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")),
|
||||
fieldWithPath("_embedded.accessItems[].permTransfer").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")),
|
||||
fieldWithPath("_embedded.accessItems[].permDistribute").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom1").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom2").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom3").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom4").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom5").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom6").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom7").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom8").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom9").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom10").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom11").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")),
|
||||
fieldWithPath("_embedded.accessItems[].permCustom12").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")),
|
||||
fieldWithPath("_embedded.accessItems[]._links.workbasket.href").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems._links.workbasket.href")),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("_links.workbasket.href").ignored()
|
||||
};
|
||||
|
||||
allWorkbasketAccessItemsFieldDescriptors = new FieldDescriptor[] {
|
||||
subsectionWithPath("_embedded.accessItems").description("An array of <<access-item, Access Items>>"),
|
||||
fieldWithPath("_links.workbasket.href").description("Link to the workbasket"),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
allDistributionTargetsFieldDescriptors = new FieldDescriptor[] {
|
||||
subsectionWithPath("_embedded.distributionTargets").description("An array of <<workbasket-subset, workbasket subsets>>"),
|
||||
fieldWithPath("_links.workbasket.href").description("Link to the workbasket"),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
createWorkbasketFieldDescriptors = new FieldDescriptor[] {
|
||||
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
|
||||
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
|
||||
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
|
||||
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")).type("String").optional(),
|
||||
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")).type("String").optional(),
|
||||
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")).type("String").optional(),
|
||||
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")).type("String").optional(),
|
||||
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")).type("String").optional(),
|
||||
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")).type("String").optional(),
|
||||
fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created")).type("String").optional(),
|
||||
fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified")).type("String").optional(),
|
||||
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")).type("String").optional(),
|
||||
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")).type("String").optional(),
|
||||
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")).type("String").optional(),
|
||||
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")).type("String").optional(),
|
||||
fieldWithPath("_links.distributionTargets.href").description(workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")).type("String").optional(),
|
||||
fieldWithPath("_links.removeDistributionTargets.href").description(workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")).type("String").optional(),
|
||||
fieldWithPath("_links.accessItems.href").description(workbasketFieldDescriptionsMap.get("_links.accessItems.href")).type("String").optional(),
|
||||
fieldWithPath("_links.allWorkbaskets.href").description(workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")).type("String").optional()
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllWorkbasketsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets?type=PERSONAL")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketsDocTest",
|
||||
responseFields(allWorkbasketsFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSpecificWorkbasketDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetSpecificWorkbasketDocTest",
|
||||
responseFields(workbasketFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllWorkbasketAccessItemsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketAccessItemsDocTest",
|
||||
responseFields(allWorkbasketAccessItemsFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void workbasketSubsetDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("WorkbasketSubset",
|
||||
responseFields(workbasketSubsetFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeWorkbasketAsDistributionTargetDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port + "/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAsDistributionTargetDocTest"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllWorkbasketDistributionTargets() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketDistributionTargets",
|
||||
responseFields(allDistributionTargetsFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createAndDeleteWorkbasketDocTest() throws Exception {
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders.post("http://127.0.0.1:" + port + "/v1/workbaskets")
|
||||
.contentType("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.content("{\"key\" : \"asdasdasd\", \"name\" : \"Gruppenpostkorb KSC\", \"domain\" : \"DOMAIN_A\", \"type\" : \"GROUP\", \"created\" : \"2018-02-01T11:00:00Z\",\r\n" +
|
||||
" \"modified\" : \"2018-02-01T11:00:00Z\"}"))
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated())
|
||||
.andDo(MockMvcRestDocumentation.document("CreateWorkbasketDocTest",
|
||||
requestFields(createWorkbasketFieldDescriptors),
|
||||
responseFields(workbasketFieldDescriptors)))
|
||||
.andReturn();
|
||||
|
||||
String newId = result.getResponse().getContentAsString().substring(17, 57);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port + "/v1/workbaskets/" + newId)
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteWorkbasketDocTest"));
|
||||
}
|
||||
|
||||
@Test public void updateWorkbasketDocTest() throws Exception {
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String originalWorkbasket = content.toString();
|
||||
String modifiedWorkbasket = new String(originalWorkbasket.toString());
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.put("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.contentType("application/json")
|
||||
.content(modifiedWorkbasket))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("UpdateWorkbasketDocTest",
|
||||
requestFields(workbasketFieldDescriptors),
|
||||
responseFields(workbasketFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessItemDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("AccessItemsDocTest",
|
||||
responseFields(accessItemFieldDescriptors)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package pro.taskana.doc.api;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
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.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class WorkbasketDefinitionControllerRestDocumentation {
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private FieldDescriptor[] workbasketdefinitionsFieldDescriptors;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
document("{methodName}",
|
||||
preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity())
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint())
|
||||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
|
||||
workbasketdefinitionsFieldDescriptors = new FieldDescriptor[] {
|
||||
subsectionWithPath("[]").description("An array of <<workbasket, workbaskets>>")
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllWorkbasketDefinitions() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/workbasketdefinitions")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasktdefinitionsDocTest",
|
||||
responseFields(workbasketdefinitionsFieldDescriptors)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importWorkbasketdefinition() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/workbasketdefinitions/import")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.contentType("application/json")
|
||||
.content("["
|
||||
+ "{"
|
||||
+ "\"distributionTargets\":[], "
|
||||
+ "\"authorizations\":[], "
|
||||
+ "\"workbasketResource\":"
|
||||
+ "{\"name\":\"ich\", \"key\":\"neuerKeyXy\", \"domain\":\"DOMAIN_A\", \"type\":\"GROUP\","
|
||||
+ "\"created\":\"2018-02-01T11:00:00Z\", \"modified\":\"2018-02-01T11:00:00Z\", \"workbasketId\":\"gibtsNed\"}"
|
||||
+ "}"
|
||||
+ "]"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("ImportWorkbasketdefinitions",
|
||||
requestFields(subsectionWithPath("[]").description("An array of <<workbasket, workbaskets>>"))));
|
||||
}
|
||||
}
|
|
@ -33,8 +33,7 @@ import pro.taskana.ldap.LdapCacheTestImpl;
|
|||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
@Import(RestConfiguration.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
public class AccessIdValidationControllerTest {
|
||||
|
||||
@LocalServerPort
|
||||
|
|
|
@ -40,8 +40,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
@Import(RestConfiguration.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
public class ClassificationControllerIntTest {
|
||||
|
||||
String server = "http://127.0.0.1:";
|
||||
|
|
|
@ -43,8 +43,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import pro.taskana.rest.resource.TaskSummaryResource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
@Import(RestConfiguration.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
public class TaskControllerIntTest {
|
||||
|
||||
@LocalServerPort
|
||||
|
|
|
@ -32,8 +32,7 @@ import pro.taskana.TaskanaRole;
|
|||
import pro.taskana.rest.resource.TaskanaUserInfoResource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
@Import(RestConfiguration.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
public class TaskanaEngineControllerIntTest {
|
||||
|
||||
@LocalServerPort
|
||||
|
|
|
@ -40,8 +40,7 @@ import pro.taskana.rest.resource.DistributionTargetResource;
|
|||
import pro.taskana.rest.resource.WorkbasketSummaryResource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
@Import(RestConfiguration.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
public class WorkbasketControllerIntTest {
|
||||
|
||||
String url = "http://127.0.0.1:";
|
||||
|
|
Loading…
Reference in New Issue