TSK-947: Use Url mappings on rest documentation tests

This commit is contained in:
Benjamin Eckstein 2019-11-18 20:04:17 +01:00 committed by Mustapha Zorgati
parent f848bf4f4e
commit 4049f4d4d7
14 changed files with 82 additions and 63 deletions

View File

@ -13,6 +13,8 @@ import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate Rest Docu for AbstractPagingController.
*/
@ -55,7 +57,7 @@ class AbstractPagingControllerRestDocumentation extends BaseRestDocumentation {
@Test
void commonSummaryResourceFieldsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/classifications?page=2&page-size=5")
.get(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?page=2&page-size=5")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("CommonSummaryResourceFields",

View File

@ -13,6 +13,7 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;
import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest;
/**
@ -33,6 +34,8 @@ public abstract class BaseRestDocumentation {
@Autowired
protected MockMvc mockMvc;
@Autowired RestHelper restHelper;
@BeforeEach
public void setUpMockMvc() {
document("{methodName}",

View File

@ -20,6 +20,8 @@ import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate REST Dokumentation for ClassificationController.
*/
@ -200,7 +202,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getAllClassificationsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/classifications?domain=DOMAIN_B")
.get(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -211,7 +213,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getSpecificClassificationDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009")
.get(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetSpecificClassificationDocTest",
@ -221,7 +223,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
@Test
void classificationSubsetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009")
.get(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("ClassificationSubset",
@ -231,7 +233,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
@Test
void createAndDeleteClassificationDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/api/v1/classifications")
.post(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS))
.contentType("application/hal+json")
.content("{\"key\":\"Key0815casdgdgh\", \"domain\":\"DOMAIN_B\"}")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
@ -245,7 +247,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
String newId = content.substring(content.indexOf("CLI:"), content.indexOf("CLI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/api/v1/classifications/" + newId)
.delete(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, newId))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteClassificationDocTest"));
@ -254,7 +256,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
@Test
void updateClassificationDocTest() throws Exception {
URL url = new URL(
"http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009");
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"));
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -273,7 +275,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
String modifiedTask = new String(originalTask.toString());
this.mockMvc.perform(RestDocumentationRequestBuilders
.put("http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009")
.put(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json")
.content(modifiedTask))

View File

@ -14,6 +14,8 @@ import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Test ClassificationDefinitionControlller.
*/
@ -32,7 +34,7 @@ class ClassificationDefinitionControllerRestDocumentation extends BaseRestDocume
@Test
void exportAllClassificationDefinitions() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/classification-definitions")
.get(restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION))
.accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -44,7 +46,7 @@ class ClassificationDefinitionControllerRestDocumentation extends BaseRestDocume
void importClassificationDefinitions() throws Exception {
String definitionString = "[{\"key\":\"Key0815\", \"domain\":\"DOMAIN_B\"}]";
this.mockMvc.perform(multipart("http://127.0.0.1:" + port + "/api/v1/classification-definitions")
this.mockMvc.perform(multipart(restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION))
.file("file",
definitionString.getBytes())
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))

View File

@ -12,6 +12,8 @@ import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate common REST Documentation.
*
@ -63,7 +65,7 @@ class CommonRestDocumentation extends BaseRestDocumentation {
@Test
void commonFieldsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009")
.get(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("CommonFields",

View File

@ -11,6 +11,8 @@ import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate REST docu for the monitor controller.
*
@ -46,7 +48,7 @@ class MonitorControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getTaskStatusReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/monitor/tasks-status-report")
.get(restHelper.toUrl(Mapping.URL_MONITOR_TASKSSTATUS))
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest",
@ -56,8 +58,7 @@ class MonitorControllerRestDocumentation extends BaseRestDocumentation {
@Test
void tasksWorkbasketReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port
+ "/api/v1/monitor/tasks-workbasket-report?daysInPast=4&states=READY,CLAIMED,COMPLETED")
.get(restHelper.toUrl(Mapping.URL_MONITOR_TASKSWORKBASKET) + "?daysInPast=4&states=READY,CLAIMED,COMPLETED")
.accept("application/hal+json")
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -68,7 +69,7 @@ class MonitorControllerRestDocumentation extends BaseRestDocumentation {
@Test
void tasksClassificationReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/monitor/tasks-classification-report")
.get(restHelper.toUrl(Mapping.URL_MONITOR_TASKSCLASSIFICATION))
.accept("application/hal+json")
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -79,7 +80,7 @@ class MonitorControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getTimestampReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/monitor/timestamp-report")
.get(restHelper.toUrl(Mapping.URL_MONITOR_TIMESTAMP))
.accept("application/hal+json")
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -20,6 +20,8 @@ import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate REST Documentation for the TaskController.
*/
@ -290,7 +292,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getAllTasksDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/tasks?por.type=VNR&por.value=22334455")
.get(restHelper.toUrl(Mapping.URL_TASKS) + "?por.type=VNR&por.value=22334455")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -301,7 +303,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getSpecificTaskDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000")
.get(restHelper.toUrl(Mapping.URL_TASKS_ID, "TKI:100000000000000000000000000000000000"))
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -312,7 +314,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
@Test
void taskSubSetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000")
.get(restHelper.toUrl(Mapping.URL_TASKS_ID, "TKI:100000000000000000000000000000000000"))
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -322,7 +324,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
@Test
void updateTaskDocTest() throws Exception {
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000");
URL url = new URL(restHelper.toUrl(Mapping.URL_TASKS_ID, "TKI:100000000000000000000000000000000000"));
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -340,7 +342,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
String originalTask = content.toString();
this.mockMvc.perform(RestDocumentationRequestBuilders
.put("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000")
.put(restHelper.toUrl(Mapping.URL_TASKS_ID, "TKI:100000000000000000000000000000000000"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json")
.content(originalTask))
@ -354,7 +356,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
void createAndDeleteTaskDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/api/v1/tasks")
.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
@ -370,7 +372,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId)
.delete(restHelper.toUrl(Mapping.URL_TASKS_ID, newId))
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
@ -380,7 +382,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
void claimTaskDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/api/v1/tasks")
.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
@ -394,7 +396,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId + "/claim")
.post(restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, newId))
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content("{}"))
@ -403,7 +405,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
responseFields(taskFieldDescriptors)));
this.mockMvc.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId)
.delete(restHelper.toUrl(Mapping.URL_TASKS_ID, newId))
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
@ -412,7 +414,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
@Test
void completeTaskDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/api/v1/tasks")
.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
@ -426,7 +428,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId + "/complete")
.post(restHelper.toUrl(Mapping.URL_TASKS_ID_COMPLETE, newId))
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content("{}"))
@ -435,7 +437,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
responseFields(taskFieldDescriptors)));
this.mockMvc.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId)
.delete(restHelper.toUrl(Mapping.URL_TASKS_ID, newId))
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
@ -444,7 +446,7 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
@Test
void transferTaskDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/api/v1/tasks")
.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
@ -459,15 +461,15 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId
+ "/transfer/WBI:100000000000000000000000000000000001")
.post(restHelper.toUrl(Mapping.URL_TASKS_ID_TRANSFER_WORKBASKETID, newId,
"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 + "/api/v1/tasks/" + newId)
.delete(restHelper.toUrl(Mapping.URL_TASKS_ID, newId))
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent());
}

View File

@ -10,6 +10,8 @@ import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate REST Docu for the TaskanaEngineController.
*
@ -46,7 +48,7 @@ class TaskanaEngineControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getAllDomainsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/domains")
.get(restHelper.toUrl(Mapping.URL_DOMAIN))
.accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -57,7 +59,7 @@ class TaskanaEngineControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getAllClassificationCategoriesDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/classification-categories")
.get(restHelper.toUrl(Mapping.URL_CLASSIFICATIONCATEGORIES))
.accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -68,7 +70,7 @@ class TaskanaEngineControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getAllClassificationTypesDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/classification-types")
.get(restHelper.toUrl(Mapping.URL_CLASSIFICATIONTYPES))
.accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -79,7 +81,7 @@ class TaskanaEngineControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getCurrentUserInfo() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/current-user-info")
.get(restHelper.toUrl(Mapping.URL_CURRENTUSER))
.accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -90,7 +92,7 @@ class TaskanaEngineControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getHistoryProviderIsEnabled() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/history-provider-enabled")
.get(restHelper.toUrl(Mapping.URL_HISTORYENABLED))
.accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -13,6 +13,8 @@ import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate REST Docu for the WorkbasketAccessItemController.
*/
@ -109,8 +111,8 @@ class WorkbasketAccessItemControllerRestDocumentation extends BaseRestDocumentat
void getWorkbasketAccessItemsDocTest() throws Exception {
this.mockMvc
.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port
+ "/api/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&access-ids=user_2_2")
.get(restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS)
+ "?sort-by=workbasket-key&order=asc&access-ids=user_2_2")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -123,7 +125,7 @@ class WorkbasketAccessItemControllerRestDocumentation extends BaseRestDocumentat
void removeWorkbasketAccessItemsDocTest() throws Exception {
this.mockMvc
.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/api/v1/workbasket-access-items/?access-id=user_2_2")
.delete(restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + "?access-id=user_2_2")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest"));

View File

@ -19,6 +19,8 @@ import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate REST Documentatioon for the WorkbasketController.
*/
@ -274,7 +276,7 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getAllWorkbasketsDocTest() throws Exception {
this.mockMvc.perform(
RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/api/v1/workbaskets?type=PERSONAL")
RestDocumentationRequestBuilders.get(restHelper.toUrl(Mapping.URL_WORKBASKET) + "?type=PERSONAL")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -285,7 +287,7 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getSpecificWorkbasketDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
"http://127.0.0.1:" + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000001")
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000001"))
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -295,8 +297,8 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getAllWorkbasketAccessItemsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
+ "/api/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID_ACCESSITEMS, "WBI:100000000000000000000000000000000001"))
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -307,7 +309,7 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void workbasketSubsetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
"http://127.0.0.1:" + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000001")
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000001"))
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -317,8 +319,8 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void removeWorkbasketAsDistributionTargetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port
+ "/api/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007")
this.mockMvc.perform(RestDocumentationRequestBuilders.delete(
restHelper.toUrl(Mapping.URL_WORKBASKET_DISTRIBUTION_ID, "WBI:100000000000000000000000000000000007"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAsDistributionTargetDocTest"));
@ -326,8 +328,8 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void getAllWorkbasketDistributionTargets() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
+ "/api/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets")
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID_DISTRIBUTION, "WBI:100000000000000000000000000000000002"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketDistributionTargets",
@ -336,7 +338,7 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void createWorkbasketDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.post("http://127.0.0.1:" + port + "/api/v1/workbaskets")
this.mockMvc.perform(RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_WORKBASKET))
.contentType("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content(
@ -352,7 +354,7 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void updateWorkbasketDocTest() throws Exception {
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000002");
URL url = new URL(restHelper.toUrl(Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000002"));
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
@ -371,7 +373,7 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
String modifiedWorkbasket = new String(originalWorkbasket.toString());
this.mockMvc.perform(RestDocumentationRequestBuilders.put(
"http://127.0.0.1:" + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000002")
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000002"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json")
.content(modifiedWorkbasket))
@ -384,7 +386,7 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void markWorkbasketForDeletionDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.delete(
"http://127.0.0.1:" + port + "/api/v1/workbaskets/" + "WBI:100000000000000000000000000000000005")
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000005"))
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isAccepted())
.andDo(MockMvcRestDocumentation.document("MarkWorkbasketForDeletionDocTest"));
@ -392,8 +394,8 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
@Test
void accessItemDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
+ "/api/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID_ACCESSITEMS, "WBI:100000000000000000000000000000000001"))
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -14,6 +14,8 @@ import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping;
/**
* Generate Rest Documentation for Workbasket Definitions.
*/
@ -32,7 +34,7 @@ class WorkbasketDefinitionControllerRestDocumentation extends BaseRestDocumentat
@Test
void exportAllWorkbasketDefinitions() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/api/v1/workbasket-definitions")
.get(restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS))
.accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -50,7 +52,7 @@ class WorkbasketDefinitionControllerRestDocumentation extends BaseRestDocumentat
+ "}"
+ "]";
this.mockMvc.perform(multipart("http://127.0.0.1:" + port + "/api/v1/workbasket-definitions")
this.mockMvc.perform(multipart(restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS))
.file("file",
definitionString.getBytes())
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))

View File

@ -136,7 +136,7 @@ class AsyncUpdateJobIntTest {
RestTemplate admTemplate = RestHelper.getRestTemplate();
ResponseEntity<TaskResource> taskResponse = admTemplate.exchange(
restHelper.toUrl(Mapping.URL_TASKS_ID,taskId),
restHelper.toUrl(Mapping.URL_TASKS_ID, taskId),
HttpMethod.GET,
new HttpEntity<>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskResource.class));

View File

@ -8,8 +8,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.util.UriComponentsBuilder;
import pro.taskana.TaskanaSpringBootTest;
/**
* Test Mapping and Linkbuilder.
*/

View File

@ -352,8 +352,7 @@ class TaskControllerIntTest {
restHelper.toUrl(Mapping.URL_TASKS_ID, taskIdOfCreatedTask),
HttpMethod.DELETE,
new HttpEntity<>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(Void.class)
);
ParameterizedTypeReference.forType(Void.class));
assertEquals(HttpStatus.NO_CONTENT, responseDeleted.getStatusCode());
}