TSK-881: Refactored REST-Api
This commit is contained in:
parent
1d41e99f9d
commit
352d0d67cd
|
@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -49,7 +50,7 @@ public class CompleteTaskAccTest extends AbstractAccTest {
|
|||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
assertEquals(TaskState.CLAIMED,
|
||||
taskService.getTask("TKI:000000000000000000000000000000000001").getState());
|
||||
taskService.getTask("TKI:000000000000000000000000000000000001").getState());
|
||||
|
||||
Task completedTask = taskService.completeTask("TKI:000000000000000000000000000000000001");
|
||||
assertNotNull(completedTask);
|
||||
|
@ -209,8 +210,8 @@ public class CompleteTaskAccTest extends AbstractAccTest {
|
|||
assertNotNull(createdTask);
|
||||
assertEquals(createdTask.getOwner(), "other_user");
|
||||
|
||||
waitAMillisecond();
|
||||
Instant beforeForceClaim = Instant.now();
|
||||
waitAMillisecond();
|
||||
Task taskAfterClaim = taskService.forceClaim(createdTask.getId());
|
||||
|
||||
assertEquals(CurrentUserContext.getUserid(), taskAfterClaim.getOwner());
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
/**
|
||||
* Generate Rest Docu for AbstractPagingController.
|
||||
* Generate Rest Docu for AbstractPagingController.
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
|
@ -77,7 +77,7 @@ public class AbstractPagingControllerRestDocumentation {
|
|||
pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page");
|
||||
|
||||
pagingFieldDescriptors = new FieldDescriptor[] {
|
||||
subsectionWithPath("_embedded.classificationSummaryResourceList").ignored(),
|
||||
subsectionWithPath("classifications").ignored(),
|
||||
fieldWithPath("_links").ignored(),
|
||||
fieldWithPath("_links.self").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
|
@ -96,7 +96,7 @@ public class AbstractPagingControllerRestDocumentation {
|
|||
@Test
|
||||
public void commonSummaryResourceFieldsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications?page=2&page-size=5")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/classifications?page=2&page-size=5")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("CommonSummaryResourceFields",
|
||||
|
|
|
@ -38,9 +38,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
/**
|
||||
* Generate REST Dokumentation for ClassificationController.
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
|
@ -113,7 +113,7 @@ public class ClassificationControllerRestDocumentation {
|
|||
|
||||
allClassificationsFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("_embedded.classificationSummaryResourceList")
|
||||
subsectionWithPath("classifications")
|
||||
.description("An Array of <<classification-subset, Classification-Subsets>>"),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page").ignored()
|
||||
|
@ -243,7 +243,7 @@ public class ClassificationControllerRestDocumentation {
|
|||
@Test
|
||||
public void getAllClassificationsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications?domain=DOMAIN_B")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/classifications?domain=DOMAIN_B")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -254,7 +254,7 @@ public class ClassificationControllerRestDocumentation {
|
|||
@Test
|
||||
public void getSpecificClassificationDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetSpecificClassificationDocTest",
|
||||
|
@ -264,7 +264,7 @@ public class ClassificationControllerRestDocumentation {
|
|||
@Test
|
||||
public void classificationSubsetDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("ClassificationSubset",
|
||||
|
@ -274,7 +274,7 @@ public class ClassificationControllerRestDocumentation {
|
|||
@Test
|
||||
public void createAndDeleteClassificationDocTest() throws Exception {
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/classifications")
|
||||
.post("http://127.0.0.1:" + port + "/api/v1/classifications")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"key\":\"Key0815casdgdgh\", \"domain\":\"DOMAIN_B\"}")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
|
@ -288,7 +288,7 @@ public class ClassificationControllerRestDocumentation {
|
|||
String newId = content.substring(content.indexOf("CLI:"), content.indexOf("CLI:") + 40);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/classifications/" + newId)
|
||||
.delete("http://127.0.0.1:" + port + "/api/v1/classifications/" + newId)
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteClassificationDocTest"));
|
||||
|
@ -296,7 +296,8 @@ public class ClassificationControllerRestDocumentation {
|
|||
|
||||
@Test
|
||||
public void updateClassificationDocTest() throws Exception {
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009");
|
||||
URL url = new URL(
|
||||
"http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -315,7 +316,7 @@ public class ClassificationControllerRestDocumentation {
|
|||
String modifiedTask = new String(originalTask.toString());
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.put("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.put("http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.contentType("application/json")
|
||||
.content(modifiedTask))
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ClassificationDefinitionControllerRestDocumentation {
|
|||
@Test
|
||||
public void exportAllClassificationDefinitions() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classification-definitions")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/classification-definitions")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -86,13 +86,12 @@ public class ClassificationDefinitionControllerRestDocumentation {
|
|||
public void importClassificationDefinitions() throws Exception {
|
||||
String definitionString = "[{\"key\":\"Key0815\", \"domain\":\"DOMAIN_B\"}]";
|
||||
|
||||
this.mockMvc.perform(multipart("http://127.0.0.1:" + port + "/v1/classification-definitions")
|
||||
this.mockMvc.perform(multipart("http://127.0.0.1:" + port + "/api/v1/classification-definitions")
|
||||
.file("file",
|
||||
definitionString.getBytes())
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(document("ImportClassificationDefinitions", requestParts(
|
||||
partWithName("file").description("The file to upload"))
|
||||
));
|
||||
partWithName("file").description("The file to upload"))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class CommonRestDocumentation {
|
|||
@Test
|
||||
public void commonFieldsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("CommonFields",
|
||||
|
|
|
@ -84,7 +84,7 @@ public class MonitorControllerRestDocumentation {
|
|||
@Test
|
||||
public void getTaskStatusReport() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/monitor/tasks-status-report")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/monitor/tasks-status-report")
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest",
|
||||
|
@ -95,7 +95,7 @@ public class MonitorControllerRestDocumentation {
|
|||
public void tasksWorkbasketReport() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port
|
||||
+ "/v1/monitor/tasks-workbasket-report?daysInPast=4&states=READY,CLAIMED,COMPLETED")
|
||||
+ "/api/v1/monitor/tasks-workbasket-report?daysInPast=4&states=READY,CLAIMED,COMPLETED")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -106,7 +106,7 @@ public class MonitorControllerRestDocumentation {
|
|||
@Test
|
||||
public void tasksClassificationReport() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/monitor/tasks-classification-report")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/monitor/tasks-classification-report")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -117,7 +117,7 @@ public class MonitorControllerRestDocumentation {
|
|||
@Test
|
||||
public void getTimestampReport() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/monitor/timestamp-report")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/monitor/timestamp-report")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
|
|
@ -136,7 +136,7 @@ public class TaskControllerRestDocumentation {
|
|||
|
||||
allTasksFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("_embedded.tasks").description("An Array of <<task-subset, Task-Subsets>>"),
|
||||
subsectionWithPath("tasks").description("An Array of <<task-subset, Task-Subsets>>"),
|
||||
fieldWithPath("_links").ignored(),
|
||||
fieldWithPath("_links.self").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
|
@ -333,7 +333,7 @@ public class TaskControllerRestDocumentation {
|
|||
@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")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/tasks?por.type=VNR&por.value=22334455")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -344,7 +344,7 @@ public class TaskControllerRestDocumentation {
|
|||
@Test
|
||||
public void getSpecificTaskDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -355,7 +355,7 @@ public class TaskControllerRestDocumentation {
|
|||
@Test
|
||||
public void taskSubSetDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -365,7 +365,7 @@ public class TaskControllerRestDocumentation {
|
|||
|
||||
@Test
|
||||
public void updateTaskDocTest() throws Exception {
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000");
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -383,7 +383,7 @@ public class TaskControllerRestDocumentation {
|
|||
String originalTask = content.toString();
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.put("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.put("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.contentType("application/json")
|
||||
.content(originalTask))
|
||||
|
@ -397,7 +397,7 @@ public class TaskControllerRestDocumentation {
|
|||
public void createAndDeleteTaskDocTest() throws Exception {
|
||||
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks")
|
||||
.post("http://127.0.0.1:" + port + "/api/v1/tasks")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
|
@ -413,7 +413,7 @@ public class TaskControllerRestDocumentation {
|
|||
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
|
||||
.delete("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId)
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
|
||||
|
@ -423,7 +423,7 @@ public class TaskControllerRestDocumentation {
|
|||
public void claimTaskDocTest() throws Exception {
|
||||
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks")
|
||||
.post("http://127.0.0.1:" + port + "/api/v1/tasks")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
|
@ -437,7 +437,7 @@ public class TaskControllerRestDocumentation {
|
|||
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/claim")
|
||||
.post("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId + "/claim")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.content("{}"))
|
||||
|
@ -446,7 +446,7 @@ public class TaskControllerRestDocumentation {
|
|||
responseFields(taskFieldDescriptors)));
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
|
||||
.delete("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId)
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
|
||||
|
@ -455,7 +455,7 @@ public class TaskControllerRestDocumentation {
|
|||
@Test
|
||||
public void completeTaskDocTest() throws Exception {
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks")
|
||||
.post("http://127.0.0.1:" + port + "/api/v1/tasks")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
|
@ -469,7 +469,7 @@ public class TaskControllerRestDocumentation {
|
|||
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/complete")
|
||||
.post("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId + "/complete")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.content("{}"))
|
||||
|
@ -478,7 +478,7 @@ public class TaskControllerRestDocumentation {
|
|||
responseFields(taskFieldDescriptors)));
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
|
||||
.delete("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId)
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
|
||||
|
@ -487,7 +487,7 @@ public class TaskControllerRestDocumentation {
|
|||
@Test
|
||||
public void transferTaskDocTest() throws Exception {
|
||||
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks")
|
||||
.post("http://127.0.0.1:" + port + "/api/v1/tasks")
|
||||
.contentType("application/hal+json")
|
||||
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
|
@ -502,7 +502,7 @@ public class TaskControllerRestDocumentation {
|
|||
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.post("http://127.0.0.1:" + port + "/v1/tasks/" + newId
|
||||
.post("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId
|
||||
+ "/transfer/WBI:100000000000000000000000000000000001")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -510,7 +510,7 @@ public class TaskControllerRestDocumentation {
|
|||
responseFields(taskFieldDescriptors)));
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
|
||||
.delete("http://127.0.0.1:" + port + "/api/v1/tasks/" + newId)
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent());
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class TaskanaEngineControllerRestDocumentation {
|
|||
@Test
|
||||
public void getAllDomainsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/domains")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/domains")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -100,7 +100,7 @@ public class TaskanaEngineControllerRestDocumentation {
|
|||
@Test
|
||||
public void getAllClassificationCategoriesDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classification-categories")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/classification-categories")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -111,7 +111,7 @@ public class TaskanaEngineControllerRestDocumentation {
|
|||
@Test
|
||||
public void getAllClassificationTypesDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/classification-types")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/classification-types")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -122,7 +122,7 @@ public class TaskanaEngineControllerRestDocumentation {
|
|||
@Test
|
||||
public void getCurrentUserInfo() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/current-user-info")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/current-user-info")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -133,7 +133,7 @@ public class TaskanaEngineControllerRestDocumentation {
|
|||
@Test
|
||||
public void getHistoryProviderIsEnabled() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/history-provider-enabled")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/history-provider-enabled")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
|
|
@ -65,82 +65,82 @@ public class WorkbasketAccessItemControllerRestDocumentation {
|
|||
.withRequestDefaults(prettyPrint()))
|
||||
.build();
|
||||
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketId", "The workbasket id");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.accessItemId", "Unique ID");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.workbasketId", "The workbasket id");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.accessId",
|
||||
"The access id. This could be either a userid or a full qualified group id");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessName", "The name");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketKey", "The workbasket key");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.accessName", "The name");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.workbasketKey", "The workbasket key");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permRead",
|
||||
"The permission to read the information about the workbasket");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permOpen",
|
||||
"The permission to view the content (the tasks) of a workbasket");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permAppend",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permAppend",
|
||||
"The permission to add tasks to the workbasket (required for creation and tranferring of tasks)");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permTransfer",
|
||||
"The permission to transfer tasks (out of the current workbasket)");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute",
|
||||
accessItemFieldDescriptionsMap.put("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("accessItems.permCustom1", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom2", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom3", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom4", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom5", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom6", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom7", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom8", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom9", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom10", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom11", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom12", "");
|
||||
accessItemFieldDescriptionsMap.put("_links.self.href", "Link to self");
|
||||
accessItemFieldDescriptionsMap.put("page", "Number of page");
|
||||
|
||||
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[].workbasketKey")
|
||||
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")),
|
||||
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("accessItems[].accessItemId")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.accessItemId")),
|
||||
fieldWithPath("accessItems[].workbasketId")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.workbasketId")),
|
||||
fieldWithPath("accessItems[].accessId")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.accessId")),
|
||||
fieldWithPath("accessItems[].accessName")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.accessName")),
|
||||
fieldWithPath("accessItems[].workbasketKey")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.workbasketKey")),
|
||||
fieldWithPath("accessItems[].permRead")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permRead")),
|
||||
fieldWithPath("accessItems[].permOpen")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permOpen")),
|
||||
fieldWithPath("accessItems[].permAppend")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permAppend")),
|
||||
fieldWithPath("accessItems[].permTransfer")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permTransfer")),
|
||||
fieldWithPath("accessItems[].permDistribute")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permDistribute")),
|
||||
fieldWithPath("accessItems[].permCustom1")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom1")),
|
||||
fieldWithPath("accessItems[].permCustom2")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom2")),
|
||||
fieldWithPath("accessItems[].permCustom3")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom3")),
|
||||
fieldWithPath("accessItems[].permCustom4")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom4")),
|
||||
fieldWithPath("accessItems[].permCustom5")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom5")),
|
||||
fieldWithPath("accessItems[].permCustom6")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom6")),
|
||||
fieldWithPath("accessItems[].permCustom7")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom7")),
|
||||
fieldWithPath("accessItems[].permCustom8")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom8")),
|
||||
fieldWithPath("accessItems[].permCustom9")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom9")),
|
||||
fieldWithPath("accessItems[].permCustom10")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom10")),
|
||||
fieldWithPath("accessItems[].permCustom11")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom11")),
|
||||
fieldWithPath("accessItems[].permCustom12")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
|
||||
fieldWithPath("_links.self.href").description(accessItemFieldDescriptionsMap.get("_links.self.href")),
|
||||
fieldWithPath("page").description(accessItemFieldDescriptionsMap.get("page"))
|
||||
};
|
||||
|
@ -151,7 +151,7 @@ public class WorkbasketAccessItemControllerRestDocumentation {
|
|||
this.mockMvc
|
||||
.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port
|
||||
+ "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&access-ids=user_1_1")
|
||||
+ "/api/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&access-ids=user_1_1")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -163,7 +163,7 @@ public class WorkbasketAccessItemControllerRestDocumentation {
|
|||
public void removeWorkbasketAccessItemsDocTest() throws Exception {
|
||||
this.mockMvc
|
||||
.perform(RestDocumentationRequestBuilders
|
||||
.delete("http://127.0.0.1:" + port + "/v1/workbasket-access-items/?access-id=user_1_1")
|
||||
.delete("http://127.0.0.1:" + port + "/api/v1/workbasket-access-items/?access-id=user_1_1")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest"));
|
||||
|
|
|
@ -108,39 +108,39 @@ public class WorkbasketControllerRestDocumentation {
|
|||
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.workbasketKey", "The workbasket key");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.accessItemId", "Unique ID");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.workbasketId", "The workbasket");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.workbasketKey", "The workbasket key");
|
||||
accessItemFieldDescriptionsMap.put("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",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.accessName", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permRead",
|
||||
"The permission to read the information about the workbasket");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permOpen",
|
||||
"The permission to view the content (the tasks) of a workbasket");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permAppend",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permAppend",
|
||||
"The permission to add tasks to the workbasket (required for creation and transferring of tasks)");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer",
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permTransfer",
|
||||
"The permission to transfer tasks (out of the current workbasket)");
|
||||
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute",
|
||||
accessItemFieldDescriptionsMap.put("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");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom1", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom2", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom3", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom4", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom5", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom6", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom7", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom8", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom9", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom10", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom11", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom12", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems._links.workbasket.href", "Link to the workbasket");
|
||||
|
||||
allWorkbasketsFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("_embedded.workbaskets").description(
|
||||
subsectionWithPath("workbaskets").description(
|
||||
"An Array of <<workbasket-subset, Workbasket-Subsets>>"),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page").ignored()
|
||||
|
@ -203,62 +203,62 @@ public class WorkbasketControllerRestDocumentation {
|
|||
};
|
||||
|
||||
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[].workbasketKey").description(
|
||||
accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")),
|
||||
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("accessItems[].accessItemId").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.accessItemId")),
|
||||
fieldWithPath("accessItems[].workbasketId").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.workbasketId")),
|
||||
fieldWithPath("accessItems[].workbasketKey").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.workbasketKey")),
|
||||
fieldWithPath("accessItems[].accessId").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.accessId")),
|
||||
fieldWithPath("accessItems[].accessName").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.accessName")),
|
||||
fieldWithPath("accessItems[].permRead").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permRead")),
|
||||
fieldWithPath("accessItems[].permOpen").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permOpen")),
|
||||
fieldWithPath("accessItems[].permAppend").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permAppend")),
|
||||
fieldWithPath("accessItems[].permTransfer").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permTransfer")),
|
||||
fieldWithPath("accessItems[].permDistribute").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permDistribute")),
|
||||
fieldWithPath("accessItems[].permCustom1").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom1")),
|
||||
fieldWithPath("accessItems[].permCustom2").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom2")),
|
||||
fieldWithPath("accessItems[].permCustom3").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom3")),
|
||||
fieldWithPath("accessItems[].permCustom4").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom4")),
|
||||
fieldWithPath("accessItems[].permCustom5").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom5")),
|
||||
fieldWithPath("accessItems[].permCustom6").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom6")),
|
||||
fieldWithPath("accessItems[].permCustom7").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom7")),
|
||||
fieldWithPath("accessItems[].permCustom8").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom8")),
|
||||
fieldWithPath("accessItems[].permCustom9").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom9")),
|
||||
fieldWithPath("accessItems[].permCustom10").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom10")),
|
||||
fieldWithPath("accessItems[].permCustom11").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom11")),
|
||||
fieldWithPath("accessItems[].permCustom12").description(
|
||||
accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("_links.workbasket.href").ignored()
|
||||
};
|
||||
|
||||
allWorkbasketAccessItemsFieldDescriptors = new FieldDescriptor[] {
|
||||
subsectionWithPath("_embedded.accessItems").description("An array of <<access-item, Access Items>>"),
|
||||
subsectionWithPath("accessItems").description("An array of <<access-item, Access Items>>"),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("_links.workbasket.href").ignored()
|
||||
};
|
||||
|
||||
allDistributionTargetsFieldDescriptors = new FieldDescriptor[] {
|
||||
subsectionWithPath("_embedded.distributionTargets").description(
|
||||
subsectionWithPath("distributionTargets").description(
|
||||
"An array of <<workbasket-subset, workbasket subsets>>"),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("_links.workbasket.href").ignored()
|
||||
|
@ -317,7 +317,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
@Test
|
||||
public void getAllWorkbasketsDocTest() throws Exception {
|
||||
this.mockMvc.perform(
|
||||
RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets?type=PERSONAL")
|
||||
RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/api/v1/workbaskets?type=PERSONAL")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -328,7 +328,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
@Test
|
||||
public void getSpecificWorkbasketDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
|
||||
"http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001")
|
||||
"http://127.0.0.1:" + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000001")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -339,7 +339,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
@Test
|
||||
public void getAllWorkbasketAccessItemsDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
|
||||
+ "/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
|
||||
+ "/api/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -350,7 +350,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
@Test
|
||||
public void workbasketSubsetDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
|
||||
"http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001")
|
||||
"http://127.0.0.1:" + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000001")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -361,7 +361,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
@Test
|
||||
public void removeWorkbasketAsDistributionTargetDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port
|
||||
+ "/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007")
|
||||
+ "/api/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAsDistributionTargetDocTest"));
|
||||
|
@ -370,7 +370,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
@Test
|
||||
public void getAllWorkbasketDistributionTargets() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
|
||||
+ "/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets")
|
||||
+ "/api/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketDistributionTargets",
|
||||
|
@ -379,7 +379,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
|
||||
@Test
|
||||
public void createWorkbasketDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.post("http://127.0.0.1:" + port + "/v1/workbaskets")
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.post("http://127.0.0.1:" + port + "/api/v1/workbaskets")
|
||||
.contentType("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.content(
|
||||
|
@ -395,7 +395,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
|
||||
@Test
|
||||
public void updateWorkbasketDocTest() throws Exception {
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002");
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000002");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
|
||||
|
@ -414,7 +414,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
String modifiedWorkbasket = new String(originalWorkbasket.toString());
|
||||
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.put(
|
||||
"http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002")
|
||||
"http://127.0.0.1:" + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000002")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
|
||||
.contentType("application/json")
|
||||
.content(modifiedWorkbasket))
|
||||
|
@ -427,7 +427,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
@Test
|
||||
public void markWorkbasketForDeletionDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.delete(
|
||||
"http://127.0.0.1:" + port + "/v1/workbaskets/" + "WBI:100000000000000000000000000000000005")
|
||||
"http://127.0.0.1:" + port + "/api/v1/workbaskets/" + "WBI:100000000000000000000000000000000005")
|
||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||
.andExpect(MockMvcResultMatchers.status().isAccepted())
|
||||
.andDo(MockMvcRestDocumentation.document("MarkWorkbasketForDeletionDocTest"));
|
||||
|
@ -436,7 +436,7 @@ public class WorkbasketControllerRestDocumentation {
|
|||
@Test
|
||||
public void accessItemDocTest() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
|
||||
+ "/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
|
||||
+ "/api/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
|
|
@ -34,7 +34,6 @@ import pro.taskana.rest.RestConfiguration;
|
|||
|
||||
/**
|
||||
* Generate Rest Documentation for Workbasket Definitions.
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
|
@ -75,7 +74,7 @@ public class WorkbasketDefinitionControllerRestDocumentation {
|
|||
@Test
|
||||
public void exportAllWorkbasketDefinitions() throws Exception {
|
||||
this.mockMvc.perform(RestDocumentationRequestBuilders
|
||||
.get("http://127.0.0.1:" + port + "/v1/workbasket-definitions")
|
||||
.get("http://127.0.0.1:" + port + "/api/v1/workbasket-definitions")
|
||||
.accept("application/json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
@ -93,11 +92,11 @@ public class WorkbasketDefinitionControllerRestDocumentation {
|
|||
+ "}"
|
||||
+ "]";
|
||||
|
||||
this.mockMvc.perform(multipart("http://127.0.0.1:" + port + "/v1/workbasket-definitions")
|
||||
this.mockMvc.perform(multipart("http://127.0.0.1:" + port + "/api/v1/workbasket-definitions")
|
||||
.file("file",
|
||||
definitionString.getBytes())
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||
.andDo(document("ImportWorkbasketDefinitions", requestParts(
|
||||
partWithName("file").description("The file to upload"))));
|
||||
}
|
||||
|
|
|
@ -92,12 +92,10 @@ public class AsyncUpdateJobIntTest {
|
|||
String updatedClassification;
|
||||
|
||||
ResponseEntity<ClassificationResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000003",
|
||||
"http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000003",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<ClassificationResource>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
ClassificationResource classification = response.getBody();
|
||||
|
@ -109,7 +107,7 @@ public class AsyncUpdateJobIntTest {
|
|||
|
||||
updatedClassification = mapper.writeValueAsString(classification);
|
||||
|
||||
URL url = new URL(server + port + "/v1/classifications/CLI:100000000000000000000000000000000003");
|
||||
URL url = new URL(server + port + "/api/v1/classifications/CLI:100000000000000000000000000000000003");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("PUT");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -131,12 +129,10 @@ public class AsyncUpdateJobIntTest {
|
|||
|
||||
// verify the classification modified timestamp is after 'before'
|
||||
ResponseEntity<ClassificationResource> repeatedResponse = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000003",
|
||||
"http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000003",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<ClassificationResource>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
|
||||
ClassificationResource modifiedClassificationResource = repeatedResponse.getBody();
|
||||
Classification modifiedClassification = classificationResourceAssembler.toModel(modifiedClassificationResource);
|
||||
|
@ -178,12 +174,10 @@ public class AsyncUpdateJobIntTest {
|
|||
HttpEntity<String> admRequest = new HttpEntity<String>(admHeaders);
|
||||
|
||||
ResponseEntity<TaskResource> taskResponse = admTemplate.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks/" + taskId,
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks/" + taskId,
|
||||
HttpMethod.GET,
|
||||
admRequest,
|
||||
new ParameterizedTypeReference<TaskResource>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
|
||||
TaskResource taskResource = taskResponse.getBody();
|
||||
Task task = taskResourceAssembler.toModel(taskResource);
|
||||
|
|
|
@ -53,9 +53,8 @@ public class AccessIdValidationControllerIntTest {
|
|||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<List<AccessIdResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/access-ids?search-for=ali", HttpMethod.GET, request,
|
||||
"http://127.0.0.1:" + port + "/api/v1/access-ids?search-for=ali", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<List<AccessIdResource>>() {
|
||||
|
||||
});
|
||||
List<AccessIdResource> body = response.getBody();
|
||||
assertNotNull(body);
|
||||
|
@ -75,10 +74,8 @@ public class AccessIdValidationControllerIntTest {
|
|||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
try {
|
||||
template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/access-ids?search-for=al", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<List<AccessIdResource>>() {
|
||||
|
||||
});
|
||||
"http://127.0.0.1:" + port + "/api/v1/access-ids?search-for=al", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
|
||||
assertTrue(e.getResponseBodyAsString().contains("Minimum searchFor length ="));
|
||||
|
@ -100,7 +97,7 @@ public class AccessIdValidationControllerIntTest {
|
|||
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
|
||||
return template;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.springframework.boot.web.server.LocalServerPort;
|
|||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
@ -41,21 +40,22 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||
import pro.taskana.rest.resource.TaskResource;
|
||||
import pro.taskana.rest.resource.TaskResourceAssembler;
|
||||
|
||||
/**
|
||||
* Test ClassificationController.
|
||||
* @author bbr
|
||||
*
|
||||
* @author bbr
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = {"devMode=true"})
|
||||
public class ClassificationControllerIntTest {
|
||||
|
||||
@Autowired
|
||||
@Autowired
|
||||
private TaskResourceAssembler taskResourceAssembler;
|
||||
|
||||
@Autowired
|
||||
|
@ -77,59 +77,51 @@ public class ClassificationControllerIntTest {
|
|||
|
||||
@Test
|
||||
public void testGetAllClassifications() {
|
||||
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange(
|
||||
server + port + "/v1/classifications", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() {
|
||||
|
||||
});
|
||||
ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
|
||||
server + port + "/api/v1/classifications", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllClassificationsFilterByCustomAttribute() {
|
||||
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange(
|
||||
server + port + "/v1/classifications?domain=DOMAIN_A&custom-1-like=RVNR", HttpMethod.GET,
|
||||
ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
|
||||
server + port + "/api/v1/classifications?domain=DOMAIN_A&custom-1-like=RVNR", HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertEquals(13, response.getBody().getContent().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllClassificationsKeepingFilters() {
|
||||
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange(
|
||||
server + port + "/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc", HttpMethod.GET,
|
||||
ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
|
||||
server + port + "/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc", HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertTrue(response.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getHref()
|
||||
.endsWith("/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc"));
|
||||
.endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc"));
|
||||
assertEquals(17, response.getBody().getContent().size());
|
||||
assertEquals("A12", response.getBody().getContent().iterator().next().key);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSecondPageSortedByKey() {
|
||||
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange(
|
||||
server + port + "/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5",
|
||||
ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
|
||||
server + port + "/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertEquals(5, response.getBody().getContent().size());
|
||||
assertEquals("L1050", response.getBody().getContent().iterator().next().key);
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertTrue(response.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getHref()
|
||||
.endsWith("/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5"));
|
||||
.endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5"));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_NEXT));
|
||||
|
@ -139,7 +131,7 @@ public class ClassificationControllerIntTest {
|
|||
@Test
|
||||
public void testCreateClassification() throws IOException {
|
||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||
URL url = new URL(server + port + "/v1/classifications");
|
||||
URL url = new URL(server + port + "/api/v1/classifications");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -153,7 +145,7 @@ public class ClassificationControllerIntTest {
|
|||
con.disconnect();
|
||||
|
||||
newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS_2\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||
url = new URL(server + port + "/v1/classifications");
|
||||
url = new URL(server + port + "/api/v1/classifications");
|
||||
con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -170,7 +162,7 @@ public class ClassificationControllerIntTest {
|
|||
@Test
|
||||
public void testCreateClassificationWithParentId() throws IOException {
|
||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P1\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\"}";
|
||||
URL url = new URL(server + port + "/v1/classifications");
|
||||
URL url = new URL(server + port + "/api/v1/classifications");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -187,7 +179,7 @@ public class ClassificationControllerIntTest {
|
|||
@Test
|
||||
public void testCreateClassificationWithParentKey() throws IOException {
|
||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
||||
URL url = new URL(server + port + "/v1/classifications");
|
||||
URL url = new URL(server + port + "/api/v1/classifications");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -206,7 +198,7 @@ public class ClassificationControllerIntTest {
|
|||
throws IOException {
|
||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
||||
|
||||
URL url = new URL(server + port + "/v1/classifications");
|
||||
URL url = new URL(server + port + "/api/v1/classifications");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -219,12 +211,10 @@ public class ClassificationControllerIntTest {
|
|||
assertEquals(201, con.getResponseCode());
|
||||
con.disconnect();
|
||||
|
||||
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange(
|
||||
server + port + "/v1/classifications", HttpMethod.GET,
|
||||
ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
|
||||
server + port + "/api/v1/classifications", HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
boolean foundClassificationCreated = false;
|
||||
for (ClassificationSummaryResource classification : response.getBody().getContent()) {
|
||||
|
@ -240,7 +230,7 @@ public class ClassificationControllerIntTest {
|
|||
@Test
|
||||
public void testReturn400IfCreateClassificationWithIncompatibleParentIdAndKey() throws IOException {
|
||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P3\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\",\"parentKey\":\"T2000\"}";
|
||||
URL url = new URL(server + port + "/v1/classifications");
|
||||
URL url = new URL(server + port + "/api/v1/classifications");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -257,7 +247,7 @@ public class ClassificationControllerIntTest {
|
|||
@Test
|
||||
public void testCreateClassificationWithClassificationIdReturnsError400() throws IOException {
|
||||
String newClassification = "{\"classificationId\":\"someId\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/classifications");
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/classifications");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -278,12 +268,10 @@ public class ClassificationControllerIntTest {
|
|||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<ClassificationSummaryResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000009",
|
||||
"http://127.0.0.1:" + port + "/api/v1/classifications/CLI:100000000000000000000000000000000009",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<ClassificationSummaryResource>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
|
||||
assertEquals("Zustimmungserklärung", response.getBody().name);
|
||||
}
|
||||
|
||||
|
@ -295,21 +283,17 @@ public class ClassificationControllerIntTest {
|
|||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
|
||||
ResponseEntity<ClassificationSummaryResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classifications/CLI:200000000000000000000000000000000004",
|
||||
"http://127.0.0.1:" + port + "/api/v1/classifications/CLI:200000000000000000000000000000000004",
|
||||
HttpMethod.DELETE,
|
||||
request,
|
||||
new ParameterizedTypeReference<ClassificationSummaryResource>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
|
||||
response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classifications/CLI:200000000000000000000000000000000004",
|
||||
"http://127.0.0.1:" + port + "/api/v1/classifications/CLI:200000000000000000000000000000000004",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<ClassificationSummaryResource>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
|
||||
}
|
||||
|
||||
private void verifyTaskIsModifiedAfter(String taskId, Instant before)
|
||||
|
@ -321,12 +305,10 @@ public class ClassificationControllerIntTest {
|
|||
HttpEntity<String> admRequest = new HttpEntity<String>(admHeaders);
|
||||
|
||||
ResponseEntity<TaskResource> taskResponse = admTemplate.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks/" + taskId,
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks/" + taskId,
|
||||
HttpMethod.GET,
|
||||
admRequest,
|
||||
new ParameterizedTypeReference<TaskResource>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
|
||||
TaskResource taskResource = taskResponse.getBody();
|
||||
Task task = taskResourceAssembler.toModel(taskResource);
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.springframework.boot.web.server.LocalServerPort;
|
|||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
@ -49,6 +48,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ import pro.taskana.rest.resource.ClassificationSummaryResource;
|
|||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
|
||||
"devMode=true" })
|
||||
"devMode=true"})
|
||||
public class ClassificationDefinitionControllerIntTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class);
|
||||
|
@ -88,9 +88,8 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
@Test
|
||||
public void testExportClassifications() {
|
||||
ResponseEntity<ClassificationResource[]> response = template.exchange(
|
||||
server + port + "/v1/classification-definitions?domain=DOMAIN_B",
|
||||
HttpMethod.GET, request, new ParameterizedTypeReference<ClassificationResource[]>() {
|
||||
});
|
||||
server + port + "/api/v1/classification-definitions?domain=DOMAIN_B",
|
||||
HttpMethod.GET, request, ParameterizedTypeReference.forType(ClassificationResource[].class));
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
assertTrue(response.getBody().length >= 5);
|
||||
assertTrue(response.getBody().length <= 7);
|
||||
|
@ -100,9 +99,8 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
@Test
|
||||
public void testExportClassificationsFromWrongDomain() {
|
||||
ResponseEntity<ClassificationResource[]> response = template.exchange(
|
||||
server + port + "/v1/classification-definitions?domain=ADdfe",
|
||||
HttpMethod.GET, request, new ParameterizedTypeReference<ClassificationResource[]>() {
|
||||
});
|
||||
server + port + "/api/v1/classification-definitions?domain=ADdfe",
|
||||
HttpMethod.GET, request, ParameterizedTypeReference.forType(ClassificationResource[].class));
|
||||
assertEquals(0, response.getBody().length);
|
||||
}
|
||||
|
||||
|
@ -136,8 +134,8 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
List<String> clList = new ArrayList<>();
|
||||
clList.add(objMapper.writeValueAsString(classification));
|
||||
|
||||
ResponseEntity<String> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -205,8 +203,8 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
clList.add(c1);
|
||||
clList.add(c2);
|
||||
|
||||
ResponseEntity<String> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -235,15 +233,15 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
List<String> clList = new ArrayList<>();
|
||||
clList.add(objMapper.writeValueAsString(existingClassification));
|
||||
|
||||
ResponseEntity<String> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
|
||||
existingClassification.setName("second new Name");
|
||||
clList = new ArrayList<>();
|
||||
clList.add(objMapper.writeValueAsString(existingClassification));
|
||||
|
||||
response = importRequest(clList);
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
|
||||
ClassificationSummaryResource testClassification = this.getClassificationWithKeyAndDomain("L110107",
|
||||
"DOMAIN_A");
|
||||
|
@ -262,8 +260,8 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
clList.add(objMapper.writeValueAsString(existingClassification));
|
||||
clList.add(objMapper.writeValueAsString(newClassification));
|
||||
|
||||
ResponseEntity<String> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
|
||||
ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("L11010", "DOMAIN_A");
|
||||
ClassificationSummaryResource testNewCl = getClassificationWithKeyAndDomain("newClass", "DOMAIN_A");
|
||||
|
@ -301,8 +299,8 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
clList.add(c22);
|
||||
clList.add(c1);
|
||||
|
||||
ResponseEntity<String> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
|
||||
ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A");
|
||||
ClassificationSummaryResource childCl = getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A");
|
||||
|
@ -332,8 +330,8 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
clList.add(parent);
|
||||
clList.add(child);
|
||||
|
||||
ResponseEntity<String> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
|
||||
ClassificationSummaryResource rightParentCl = getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_A");
|
||||
ClassificationSummaryResource wrongParentCl = getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_B");
|
||||
|
@ -364,8 +362,8 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
clList.add(withNewParent);
|
||||
clList.add(withoutParent);
|
||||
|
||||
ResponseEntity<String> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
Thread.sleep(10);
|
||||
LOGGER.debug("Wait 10 ms to give the system a chance to update");
|
||||
|
||||
|
@ -413,17 +411,15 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classifications?key=" + key + "&domain=" + domain,
|
||||
ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/api/v1/classifications?key=" + key + "&domain=" + domain,
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
return response.getBody().getContent().toArray(new ClassificationSummaryResource[1])[0];
|
||||
}
|
||||
|
||||
private ResponseEntity<String> importRequest(List<String> clList) throws IOException {
|
||||
private ResponseEntity<Void> importRequest(List<String> clList) throws IOException {
|
||||
LOGGER.debug("Start Import");
|
||||
File tmpFile = File.createTempFile("test", ".tmp");
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmpFile), StandardCharsets.UTF_8);
|
||||
|
@ -435,10 +431,10 @@ public class ClassificationDefinitionControllerIntTest {
|
|||
body.add("file", new FileSystemResource(tmpFile));
|
||||
|
||||
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
|
||||
String serverUrl = server + port + "/v1/classification-definitions";
|
||||
String serverUrl = server + port + "/api/v1/classification-definitions";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return restTemplate.postForEntity(serverUrl, requestEntity, String.class);
|
||||
return restTemplate.postForEntity(serverUrl, requestEntity, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
@ -36,16 +35,15 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
|
|||
import ch.qos.logback.classic.spi.LoggingEvent;
|
||||
import ch.qos.logback.core.Appender;
|
||||
import pro.taskana.ldap.LdapCacheTestImpl;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
|
||||
/**
|
||||
* Test general Exception Handling.
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
|
||||
"devMode=true"})
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||
properties = {
|
||||
"devMode=true"})
|
||||
public class GenenalExceptionHandlingTest {
|
||||
|
||||
String server = "http://127.0.0.1:";
|
||||
|
@ -69,8 +67,8 @@ public class GenenalExceptionHandlingTest {
|
|||
logger.addAppender(mockAppender);
|
||||
}
|
||||
|
||||
//Always have this teardown otherwise we can stuff up our expectations. Besides, it's
|
||||
//good coding practise
|
||||
// Always have this teardown otherwise we can stuff up our expectations. Besides, it's
|
||||
// good coding practise
|
||||
@After
|
||||
public void teardown() {
|
||||
final Logger logger = (Logger) LoggerFactory.getLogger(TaskanaRestExceptionHandler.class);
|
||||
|
@ -83,10 +81,8 @@ public class GenenalExceptionHandlingTest {
|
|||
|
||||
AccessIdController.setLdapCache(new LdapCacheTestImpl());
|
||||
template.exchange(
|
||||
server + port + "/v1/access-ids?search-for=al", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<List<AccessIdResource>>() {
|
||||
|
||||
});
|
||||
server + port + "/api/v1/access-ids?search-for=al", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
} catch (Exception ex) {
|
||||
verify(mockAppender).doAppend(captorLoggingEvent.capture());
|
||||
assertTrue(
|
||||
|
@ -98,10 +94,8 @@ public class GenenalExceptionHandlingTest {
|
|||
public void testDeleteNonExisitingClassificationExceptionIsLogged() {
|
||||
try {
|
||||
template.exchange(
|
||||
server + port + "/v1/classifications/non-existing-id", HttpMethod.DELETE, request,
|
||||
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() {
|
||||
|
||||
});
|
||||
server + port + "/api/v1/classifications/non-existing-id", HttpMethod.DELETE, request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
} catch (Exception ex) {
|
||||
verify(mockAppender).doAppend(captorLoggingEvent.capture());
|
||||
assertTrue(captorLoggingEvent.getValue()
|
||||
|
@ -125,7 +119,7 @@ public class GenenalExceptionHandlingTest {
|
|||
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
|||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
@ -48,7 +47,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
|
||||
import pro.taskana.exceptions.SystemException;
|
||||
import pro.taskana.rest.resource.TaskResource;
|
||||
import pro.taskana.rest.resource.TaskSummaryResource;
|
||||
import pro.taskana.rest.resource.TaskSummaryListResource;
|
||||
import pro.taskana.sampledata.SampleDataGenerator;
|
||||
|
||||
/**
|
||||
|
@ -84,11 +83,9 @@ public class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertEquals(25, response.getBody().getContent().size());
|
||||
}
|
||||
|
@ -99,12 +96,10 @@ public class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); // teamlead_1
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks?workbasket-id=WBI:100000000000000000000000000000000001",
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks?workbasket-id=WBI:100000000000000000000000000000000001",
|
||||
HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertEquals(22, response.getBody().getContent().size());
|
||||
}
|
||||
|
@ -115,12 +110,10 @@ public class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks?workbasket-key=USER_1_2&domain=DOMAIN_A",
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks?workbasket-key=USER_1_2&domain=DOMAIN_A",
|
||||
HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertEquals(20, response.getBody().getContent().size());
|
||||
}
|
||||
|
@ -132,12 +125,10 @@ public class TaskControllerIntTest {
|
|||
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
try {
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks?workbasket-key=USER_1_2",
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks?workbasket-key=USER_1_2",
|
||||
HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
fail();
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
|
||||
|
@ -150,11 +141,9 @@ public class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // Role Admin
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertEquals(73, response.getBody().getContent().size());
|
||||
}
|
||||
|
@ -165,17 +154,15 @@ public class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc",
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc",
|
||||
HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertTrue(response.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getHref()
|
||||
.endsWith("/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc"));
|
||||
.endsWith("/api/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -186,11 +173,9 @@ public class TaskControllerIntTest {
|
|||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
try {
|
||||
template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks?invalid=VNR",
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks?invalid=VNR",
|
||||
HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
fail();
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
|
||||
|
@ -204,14 +189,12 @@ public class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // Role Admin
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port
|
||||
+ "/v1/tasks?state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5",
|
||||
+ "/api/v1/tasks?state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertEquals(1, response.getBody().getContent().size());
|
||||
assertTrue(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=14"));
|
||||
assertEquals("TKI:100000000000000000000000000000000000",
|
||||
|
@ -220,7 +203,7 @@ public class TaskControllerIntTest {
|
|||
assertTrue(response.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getHref()
|
||||
.endsWith("/v1/tasks?state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5"));
|
||||
.endsWith("/api/v1/tasks?state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5"));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
||||
|
@ -235,20 +218,16 @@ public class TaskControllerIntTest {
|
|||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks?sort-by=due&order=desc", HttpMethod.GET,
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks?sort-by=due&order=desc", HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertEquals(25, response.getBody().getContent().size());
|
||||
|
||||
response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/tasks?sort-by=due&order=desc&page=5&page-size=5", HttpMethod.GET,
|
||||
"http://127.0.0.1:" + port + "/api/v1/tasks?sort-by=due&order=desc&page=5&page-size=5", HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertEquals(5, response.getBody().getContent().size());
|
||||
assertTrue(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=5"));
|
||||
assertEquals("TKI:000000000000000000000000000000000023",
|
||||
|
@ -257,7 +236,7 @@ public class TaskControllerIntTest {
|
|||
assertTrue(response.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getHref()
|
||||
.endsWith("/v1/tasks?sort-by=due&order=desc&page=5&page-size=5"));
|
||||
.endsWith("/api/v1/tasks?sort-by=due&order=desc&page=5&page-size=5"));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
||||
|
@ -271,14 +250,12 @@ public class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange(
|
||||
ResponseEntity<TaskSummaryListResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port
|
||||
+ "/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&page=2&page-size=5",
|
||||
+ "/api/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&page=2&page-size=5",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
|
||||
|
||||
});
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertEquals(1, response.getBody().getContent().size());
|
||||
assertEquals("TKI:000000000000000000000000000000000013",
|
||||
response.getBody().getContent().iterator().next().getTaskId());
|
||||
|
@ -287,7 +264,7 @@ public class TaskControllerIntTest {
|
|||
.getLink(Link.REL_SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&page=2&page-size=5"));
|
||||
"/api/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&page=2&page-size=5"));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
||||
|
@ -295,7 +272,7 @@ public class TaskControllerIntTest {
|
|||
|
||||
@Test
|
||||
public void testGetTaskWithAttachments() throws IOException {
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks/TKI:000000000000000000000000000000000002");
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:000000000000000000000000000000000002");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
|
||||
|
@ -321,7 +298,7 @@ public class TaskControllerIntTest {
|
|||
|
||||
@Test
|
||||
public void testGetAndUpdateTask() throws IOException {
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000");
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -350,7 +327,7 @@ public class TaskControllerIntTest {
|
|||
assertEquals(200, con.getResponseCode());
|
||||
con.disconnect();
|
||||
|
||||
url = new URL("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000");
|
||||
url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks/TKI:100000000000000000000000000000000000");
|
||||
con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
|
@ -382,7 +359,7 @@ public class TaskControllerIntTest {
|
|||
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
|
||||
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks");
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setDoOutput(true);
|
||||
|
@ -412,7 +389,7 @@ public class TaskControllerIntTest {
|
|||
assertTrue(taskIdOfCreatedTask.startsWith("TKI:"));
|
||||
|
||||
// delete task again to clean test data
|
||||
url = new URL("http://127.0.0.1:" + port + "/v1/tasks/" + taskIdOfCreatedTask);
|
||||
url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks/" + taskIdOfCreatedTask);
|
||||
con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("DELETE");
|
||||
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); // admin
|
||||
|
@ -426,7 +403,7 @@ public class TaskControllerIntTest {
|
|||
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
|
||||
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks");
|
||||
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setDoOutput(true);
|
||||
|
@ -439,12 +416,11 @@ public class TaskControllerIntTest {
|
|||
assertEquals(400, con.getResponseCode());
|
||||
con.disconnect();
|
||||
|
||||
taskToCreateJson =
|
||||
"{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"},"
|
||||
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
|
||||
taskToCreateJson = "{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"},"
|
||||
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
|
||||
|
||||
url = new URL("http://127.0.0.1:" + port + "/v1/tasks");
|
||||
url = new URL("http://127.0.0.1:" + port + "/api/v1/tasks");
|
||||
con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setDoOutput(true);
|
||||
|
@ -474,7 +450,7 @@ public class TaskControllerIntTest {
|
|||
// converter.setSupportedMediaTypes(ImmutableList.of(MediaTypes.HAL_JSON));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
|
||||
return template;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ import pro.taskana.rest.resource.TaskanaUserInfoResource;
|
|||
|
||||
/**
|
||||
* Test TaskanaEngineController.
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = {"devMode=true"})
|
||||
public class TaskanaEngineControllerIntTest {
|
||||
|
||||
@LocalServerPort
|
||||
|
@ -48,9 +48,8 @@ public class TaskanaEngineControllerIntTest {
|
|||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<List<String>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/domains", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<List<String>>() {
|
||||
});
|
||||
"http://127.0.0.1:" + port + "/api/v1/domains", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
assertTrue(response.getBody().contains("DOMAIN_A"));
|
||||
}
|
||||
|
||||
|
@ -61,9 +60,8 @@ public class TaskanaEngineControllerIntTest {
|
|||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<List<String>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classification-types", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<List<String>>() {
|
||||
});
|
||||
"http://127.0.0.1:" + port + "/api/v1/classification-types", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
assertTrue(response.getBody().contains("TASK"));
|
||||
assertTrue(response.getBody().contains("DOCUMENT"));
|
||||
assertFalse(response.getBody().contains("UNKNOWN"));
|
||||
|
@ -76,9 +74,8 @@ public class TaskanaEngineControllerIntTest {
|
|||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<List<String>> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classification-categories/?type=TASK", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<List<String>>() {
|
||||
});
|
||||
"http://127.0.0.1:" + port + "/api/v1/classification-categories/?type=TASK", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
assertTrue(response.getBody().contains("MANUAL"));
|
||||
assertTrue(response.getBody().contains("EXTERNAL"));
|
||||
assertTrue(response.getBody().contains("AUTOMATIC"));
|
||||
|
@ -93,9 +90,8 @@ public class TaskanaEngineControllerIntTest {
|
|||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<TaskanaUserInfoResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/current-user-info", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<TaskanaUserInfoResource>() {
|
||||
});
|
||||
"http://127.0.0.1:" + port + "/api/v1/current-user-info", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(TaskanaUserInfoResource.class));
|
||||
assertEquals("teamlead_1", response.getBody().getUserId());
|
||||
assertTrue(response.getBody().getGroupIds().contains("businessadmin"));
|
||||
assertTrue(response.getBody().getRoles().contains(TaskanaRole.BUSINESS_ADMIN));
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
@ -34,11 +33,11 @@ import org.springframework.web.client.RestTemplate;
|
|||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemPaginatedListResource;
|
||||
|
||||
/**
|
||||
* Test WorkbasketAccessItemController.
|
||||
*
|
||||
*/
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@RunWith(SpringRunner.class)
|
||||
|
@ -61,20 +60,18 @@ public class WorkbasketAccessItemControllerIntTest {
|
|||
|
||||
@Test
|
||||
public void testGetAllWorkbasketAccessItems() {
|
||||
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = template.exchange(
|
||||
url + port + "/v1/workbasket-access-items", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() {
|
||||
});
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response = template.exchange(
|
||||
url + port + "/api/v1/workbasket-access-items", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWorkbasketAccessItemsKeepingFilters() {
|
||||
String parameters = "/v1/workbasket-access-items?sort-by=workbasket-key&order=asc&page=1&page-size=9&access-ids=user_1_1";
|
||||
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = template.exchange(
|
||||
String parameters = "/api/v1/workbasket-access-items?sort-by=workbasket-key&order=asc&page=1&page-size=9&access-ids=user_1_1";
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response = template.exchange(
|
||||
url + port + parameters, HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() {
|
||||
});
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertTrue(response.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
|
@ -87,10 +84,9 @@ public class WorkbasketAccessItemControllerIntTest {
|
|||
try {
|
||||
template.exchange(
|
||||
url + port
|
||||
+ "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1",
|
||||
+ "/api/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1",
|
||||
HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() {
|
||||
});
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
fail();
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
|
||||
|
@ -100,11 +96,10 @@ public class WorkbasketAccessItemControllerIntTest {
|
|||
|
||||
@Test
|
||||
public void testGetSecondPageSortedByWorkbasketKey() {
|
||||
String parameters = "/v1/workbasket-access-items?sort-by=workbasket-key&order=asc&page=2&page-size=9&access-ids=user_1_1";
|
||||
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = template.exchange(
|
||||
String parameters = "/api/v1/workbasket-access-items?sort-by=workbasket-key&order=asc&page=2&page-size=9&access-ids=user_1_1";
|
||||
ResponseEntity<WorkbasketAccessItemPaginatedListResource> response = template.exchange(
|
||||
url + port + parameters, HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() {
|
||||
});
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemPaginatedListResource.class));
|
||||
assertEquals(1, response.getBody().getContent().size());
|
||||
assertEquals("user_1_1", response.getBody().getContent().iterator().next().accessId);
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
|
@ -123,23 +118,21 @@ public class WorkbasketAccessItemControllerIntTest {
|
|||
@Test
|
||||
public void testRemoveWorkbasketAccessItemsOfUser() {
|
||||
|
||||
String parameters = "/v1/workbasket-access-items/?access-id=user_1_1";
|
||||
String parameters = "/api/v1/workbasket-access-items/?access-id=user_1_1";
|
||||
ResponseEntity<Void> response = template.exchange(
|
||||
url + port + parameters, HttpMethod.DELETE, request,
|
||||
new ParameterizedTypeReference<Void>() {
|
||||
});
|
||||
ParameterizedTypeReference.forType(Void.class));
|
||||
assertNull(response.getBody());
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() {
|
||||
String parameters = "/v1/workbasket-access-items?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
|
||||
String parameters = "/api/v1/workbasket-access-items?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
|
||||
try {
|
||||
ResponseEntity<Void> response = template.exchange(
|
||||
url + port + parameters, HttpMethod.DELETE, request,
|
||||
new ParameterizedTypeReference<Void>() {
|
||||
});
|
||||
ParameterizedTypeReference.forType(Void.class));
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
|
||||
}
|
||||
|
@ -159,7 +152,7 @@ public class WorkbasketAccessItemControllerIntTest {
|
|||
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
|||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.Resources;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
@ -35,12 +33,12 @@ import org.springframework.web.client.RestTemplate;
|
|||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import pro.taskana.rest.resource.DistributionTargetListResource;
|
||||
import pro.taskana.rest.resource.DistributionTargetResource;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryResource;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryListResource;
|
||||
|
||||
/**
|
||||
* Test WorkbasketController.
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
|
@ -63,30 +61,27 @@ public class WorkbasketControllerIntTest {
|
|||
|
||||
@Test
|
||||
public void testGetAllWorkbaskets() {
|
||||
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange(
|
||||
url + port + "/v1/workbaskets", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
|
||||
});
|
||||
ResponseEntity<WorkbasketSummaryListResource> response = template.exchange(
|
||||
url + port + "/api/v1/workbaskets", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllWorkbasketsBusinessAdminHasOpenPermission() {
|
||||
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange(
|
||||
url + port + "/v1/workbaskets?required-permission=OPEN", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
|
||||
});
|
||||
ResponseEntity<WorkbasketSummaryListResource> response = template.exchange(
|
||||
url + port + "/api/v1/workbaskets?required-permission=OPEN", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertEquals(3, response.getBody().getContent().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllWorkbasketsKeepingFilters() {
|
||||
String parameters = "/v1/workbaskets?type=PERSONAL&sort-by=key&order=desc";
|
||||
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange(
|
||||
String parameters = "/api/v1/workbaskets?type=PERSONAL&sort-by=key&order=desc";
|
||||
ResponseEntity<WorkbasketSummaryListResource> response = template.exchange(
|
||||
url + port + parameters, HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
|
||||
});
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
assertTrue(response.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
|
@ -98,9 +93,8 @@ public class WorkbasketControllerIntTest {
|
|||
public void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||
try {
|
||||
template.exchange(
|
||||
url + port + "/v1/workbaskets?invalid=PERSONAL", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
|
||||
});
|
||||
url + port + "/api/v1/workbaskets?invalid=PERSONAL", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
fail();
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
|
||||
|
@ -111,11 +105,10 @@ public class WorkbasketControllerIntTest {
|
|||
@Test
|
||||
public void testGetSecondPageSortedByKey() {
|
||||
|
||||
String parameters = "/v1/workbaskets?sort-by=key&order=desc&page=2&page-size=5";
|
||||
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange(
|
||||
String parameters = "/api/v1/workbaskets?sort-by=key&order=desc&page=2&page-size=5";
|
||||
ResponseEntity<WorkbasketSummaryListResource> response = template.exchange(
|
||||
url + port + parameters, HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
|
||||
});
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
assertEquals(5, response.getBody().getContent().size());
|
||||
assertEquals("USER_1_1", response.getBody().getContent().iterator().next().getKey());
|
||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||
|
@ -131,17 +124,16 @@ public class WorkbasketControllerIntTest {
|
|||
|
||||
@Test
|
||||
public void testRemoveWorkbasketAsDistributionTarget() {
|
||||
String parameters = "/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007";
|
||||
String parameters = "/api/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007";
|
||||
ResponseEntity<?> response = template.exchange(
|
||||
url + port + parameters, HttpMethod.DELETE, request,
|
||||
Void.class);
|
||||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||
|
||||
ResponseEntity<Resources<DistributionTargetResource>> response2 = template.exchange(
|
||||
url + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets",
|
||||
ResponseEntity<DistributionTargetListResource> response2 = template.exchange(
|
||||
url + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets",
|
||||
HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<Resources<DistributionTargetResource>>() {
|
||||
});
|
||||
ParameterizedTypeReference.forType(DistributionTargetListResource.class));
|
||||
assertEquals(HttpStatus.OK, response2.getStatusCode());
|
||||
Iterator<DistributionTargetResource> iterator = response2.getBody().getContent().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import pro.taskana.rest.resource.WorkbasketDefinitionResource;
|
||||
|
||||
/**
|
||||
* Integration tests for WorkbasketDefinitionController.
|
||||
*/
|
||||
|
@ -70,9 +71,8 @@ public class WorkbasketDefinitionControllerIntTest {
|
|||
@Test
|
||||
public void testExportWorkbasketFromDomain() {
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange(
|
||||
server + port + "/v1/workbasket-definitions?domain=DOMAIN_A", HttpMethod.GET, request,
|
||||
server + port + "/api/v1/workbasket-definitions?domain=DOMAIN_A", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {
|
||||
|
||||
});
|
||||
assertNotNull(response.getBody());
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
|
@ -97,31 +97,27 @@ public class WorkbasketDefinitionControllerIntTest {
|
|||
@Test
|
||||
public void testExportWorkbasketsFromWrongDomain() {
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange(
|
||||
server + port + "/v1/workbasket-definitions?domain=wrongDomain",
|
||||
HttpMethod.GET, request, new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {
|
||||
|
||||
});
|
||||
server + port + "/api/v1/workbasket-definitions?domain=wrongDomain",
|
||||
HttpMethod.GET, request, ParameterizedTypeReference.forType(List.class));
|
||||
assertEquals(0, response.getBody().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportWorkbasket() throws IOException {
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange(
|
||||
server + port + "/v1/workbasket-definitions?domain=DOMAIN_A",
|
||||
HttpMethod.GET, request, new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {
|
||||
|
||||
});
|
||||
server + port + "/api/v1/workbasket-definitions?domain=DOMAIN_A",
|
||||
HttpMethod.GET, request, ParameterizedTypeReference.forType(List.class));
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(objMapper.writeValueAsString(response.getBody().get(0)));
|
||||
ResponseEntity<String> responseImport = importRequest(list);
|
||||
assertEquals(HttpStatus.OK, responseImport.getStatusCode());
|
||||
ResponseEntity<Void> responseImport = importRequest(list);
|
||||
assertEquals(HttpStatus.NO_CONTENT, responseImport.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailOnImportDuplicates() throws IOException {
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange(
|
||||
server + port + "/v1/workbasket-definitions?domain=DOMAIN_A",
|
||||
server + port + "/api/v1/workbasket-definitions?domain=DOMAIN_A",
|
||||
HttpMethod.GET, request, new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {
|
||||
|
||||
});
|
||||
|
@ -141,9 +137,8 @@ public class WorkbasketDefinitionControllerIntTest {
|
|||
public void testNoErrorWhenImportWithSameIdButDifferentKeyAndDomain()
|
||||
throws IOException {
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange(
|
||||
server + port + "/v1/workbasket-definitions?domain=DOMAIN_A",
|
||||
server + port + "/api/v1/workbasket-definitions?domain=DOMAIN_A",
|
||||
HttpMethod.GET, request, new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {
|
||||
|
||||
});
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
|
@ -151,11 +146,11 @@ public class WorkbasketDefinitionControllerIntTest {
|
|||
list.add(objMapper.writeValueAsString(wbDef));
|
||||
wbDef.getWorkbasket().setKey("new Key for this WB");
|
||||
list.add(objMapper.writeValueAsString(wbDef));
|
||||
ResponseEntity<String> responseImport = importRequest(list);
|
||||
assertEquals(HttpStatus.OK, responseImport.getStatusCode());
|
||||
ResponseEntity<Void> responseImport = importRequest(list);
|
||||
assertEquals(HttpStatus.NO_CONTENT, responseImport.getStatusCode());
|
||||
}
|
||||
|
||||
private ResponseEntity<String> importRequest(List<String> clList) throws IOException {
|
||||
private ResponseEntity<Void> importRequest(List<String> clList) throws IOException {
|
||||
File tmpFile = File.createTempFile("test", ".tmp");
|
||||
FileWriter writer = new FileWriter(tmpFile);
|
||||
writer.write(clList.toString());
|
||||
|
@ -166,10 +161,10 @@ public class WorkbasketDefinitionControllerIntTest {
|
|||
body.add("file", new FileSystemResource(tmpFile));
|
||||
|
||||
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
|
||||
String serverUrl = server + port + "/v1/workbasket-definitions";
|
||||
String serverUrl = server + port + "/api/v1/workbasket-definitions";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return restTemplate.postForEntity(serverUrl, requestEntity, String.class);
|
||||
return restTemplate.postForEntity(serverUrl, requestEntity, Void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,6 +181,6 @@ public class WorkbasketDefinitionControllerIntTest {
|
|||
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/haljson,*/*"));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
return new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import pro.taskana.rest.resource.TaskanaUserInfoResource;
|
||||
|
||||
/**
|
||||
* This test class is configured to run with postgres DB if you want to run it with h2 it is needed.
|
||||
* to change data source configuration at project-defaults.yml.
|
||||
* This test class is configured to run with postgres DB if you want to run it with h2 it is needed. to change data
|
||||
* source configuration at project-defaults.yml.
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class TaskanaWildflyTest {
|
||||
|
@ -43,7 +43,8 @@ public class TaskanaWildflyTest {
|
|||
File[] files = Maven.resolver()
|
||||
.loadPomFromFile("pom.xml")
|
||||
.importRuntimeDependencies()
|
||||
.resolve().withTransitivity()
|
||||
.resolve()
|
||||
.withTransitivity()
|
||||
.asFile();
|
||||
|
||||
return ShrinkWrap.create(WebArchive.class, "taskana.war")
|
||||
|
@ -61,10 +62,8 @@ public class TaskanaWildflyTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<TaskanaUserInfoResource> response = getRestTemplate().exchange(
|
||||
"http://127.0.0.1:" + "8090" + "/v1/current-user-info", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<TaskanaUserInfoResource>() {
|
||||
|
||||
});
|
||||
"http://127.0.0.1:" + "8090" + "/api/v1/current-user-info", HttpMethod.GET, request,
|
||||
ParameterizedTypeReference.forType(TaskanaUserInfoResource.class));
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
|
||||
}
|
||||
|
@ -77,7 +76,7 @@ public class TaskanaWildflyTest {
|
|||
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/json"));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -8,7 +7,6 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -27,7 +25,7 @@ import pro.taskana.rest.resource.AccessIdResource;
|
|||
*/
|
||||
@RestController
|
||||
@EnableHypermediaSupport(type = HypermediaType.HAL)
|
||||
@RequestMapping(path = "/v1/access-ids", produces = "application/hal+json")
|
||||
@RequestMapping(path = "/api/v1/access-ids", produces = "application/hal+json")
|
||||
public class AccessIdController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AccessIdController.class);
|
||||
|
@ -49,23 +47,22 @@ public class AccessIdController {
|
|||
ResponseEntity<List<AccessIdResource>> response;
|
||||
if (ldapClient.useLdap()) {
|
||||
List<AccessIdResource> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor);
|
||||
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK);
|
||||
response = ResponseEntity.ok(accessIdUsers);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
|
||||
}
|
||||
|
||||
return response;
|
||||
} else if (ldapCache != null) {
|
||||
response = new ResponseEntity<>(
|
||||
ldapCache.findMatchingAccessId(searchFor, ldapClient.getMaxNumberOfReturnedAccessIds()),
|
||||
HttpStatus.OK);
|
||||
response = ResponseEntity.ok(
|
||||
ldapCache.findMatchingAccessId(searchFor, ldapClient.getMaxNumberOfReturnedAccessIds()));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
|
||||
}
|
||||
|
||||
return response;
|
||||
} else {
|
||||
response = new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND);
|
||||
response = ResponseEntity.notFound().build();
|
||||
LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
@ -85,7 +82,7 @@ public class AccessIdController {
|
|||
if (ldapClient.useLdap()) {
|
||||
accessIdUsers = ldapClient.searchUsersAndGroups(accessId);
|
||||
accessIdUsers.addAll(ldapClient.searchGroupsofUsersIsMember(accessId));
|
||||
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK);
|
||||
response = ResponseEntity.ok(accessIdUsers);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
|
||||
}
|
||||
|
@ -93,14 +90,14 @@ public class AccessIdController {
|
|||
return response;
|
||||
} else if (ldapCache != null) {
|
||||
accessIdUsers = ldapCache.findGroupsOfUser(accessId, ldapClient.getMaxNumberOfReturnedAccessIds());
|
||||
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK);
|
||||
response = ResponseEntity.ok(accessIdUsers);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
|
||||
}
|
||||
|
||||
return response;
|
||||
} else {
|
||||
response = new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND);
|
||||
response = ResponseEntity.notFound().build();
|
||||
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.List;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
|
@ -36,7 +35,7 @@ import pro.taskana.exceptions.InvalidArgumentException;
|
|||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResourceAssembler;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +43,7 @@ import pro.taskana.rest.resource.ClassificationSummaryResourceAssembler;
|
|||
*/
|
||||
@RestController
|
||||
@EnableHypermediaSupport(type = HypermediaType.HAL)
|
||||
@RequestMapping(path = "/v1/classifications", produces = "application/hal+json")
|
||||
@RequestMapping(path = "/api/v1/classifications", produces = "application/hal+json")
|
||||
public class ClassificationController extends AbstractPagingController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class);
|
||||
|
@ -100,7 +99,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
|
||||
@GetMapping
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<PagedResources<ClassificationSummaryResource>> getClassifications(
|
||||
public ResponseEntity<ClassificationSummaryListResource> getClassifications(
|
||||
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getClassifications(params= {})", params);
|
||||
|
@ -113,14 +112,12 @@ public class ClassificationController extends AbstractPagingController {
|
|||
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata);
|
||||
|
||||
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = new ResponseEntity<>(
|
||||
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity.ok(
|
||||
classificationSummaryResourceAssembler.toResources(
|
||||
classificationSummaries,
|
||||
pageMetadata),
|
||||
HttpStatus.OK);
|
||||
pageMetadata));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getClassifications(), returning {}",
|
||||
new ResponseEntity<>(response, HttpStatus.OK));
|
||||
LOGGER.debug("Exit from getClassifications(), returning {}", response);
|
||||
}
|
||||
|
||||
return response;
|
||||
|
@ -135,11 +132,10 @@ public class ClassificationController extends AbstractPagingController {
|
|||
}
|
||||
|
||||
Classification classification = classificationService.getClassification(classificationId);
|
||||
ResponseEntity<ClassificationResource> response = new ResponseEntity<>(
|
||||
classificationResourceAssembler.toResource(classification), HttpStatus.OK);
|
||||
ResponseEntity<ClassificationResource> response = ResponseEntity.ok(
|
||||
classificationResourceAssembler.toResource(classification));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getClassification(), returning {}",
|
||||
ResponseEntity.status(HttpStatus.OK).body(classificationResourceAssembler.toResource(classification)));
|
||||
LOGGER.debug("Exit from getClassification(), returning {}", response);
|
||||
}
|
||||
|
||||
return response;
|
||||
|
@ -157,8 +153,8 @@ public class ClassificationController extends AbstractPagingController {
|
|||
Classification classification = classificationResourceAssembler.toModel(resource);
|
||||
classification = classificationService.createClassification(classification);
|
||||
|
||||
ResponseEntity<ClassificationResource> response = new ResponseEntity<>(
|
||||
classificationResourceAssembler.toResource(classification), HttpStatus.CREATED);
|
||||
ResponseEntity<ClassificationResource> response = ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(classificationResourceAssembler.toResource(classification));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createClassification(), returning {}", response);
|
||||
}
|
||||
|
@ -181,7 +177,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
if (classificationId.equals(resource.classificationId)) {
|
||||
Classification classification = classificationResourceAssembler.toModel(resource);
|
||||
classification = classificationService.updateClassification(classification);
|
||||
result = new ResponseEntity<>(classificationResourceAssembler.toResource(classification), HttpStatus.OK);
|
||||
result = ResponseEntity.ok(classificationResourceAssembler.toResource(classification));
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
"ClassificationId ('" + classificationId
|
||||
|
@ -201,7 +197,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException {
|
||||
LOGGER.debug("Entry to deleteClassification(classificationId= {})", classificationId);
|
||||
classificationService.deleteClassification(classificationId);
|
||||
ResponseEntity<?> response = new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
ResponseEntity<?> response = ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from deleteClassification(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.util.stream.Collectors;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -45,7 +44,7 @@ import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
|||
* Controller for Importing / Exporting classifications.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(path = "/v1/classification-definitions", produces = { MediaType.APPLICATION_JSON_VALUE })
|
||||
@RequestMapping(path = "/api/v1/classification-definitions", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public class ClassificationDefinitionController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationDefinitionController.class);
|
||||
|
@ -79,7 +78,7 @@ public class ClassificationDefinitionController {
|
|||
export.add(classificationResourceAssembler.toDefinition(classification));
|
||||
}
|
||||
|
||||
ResponseEntity<List<ClassificationResource>> response = new ResponseEntity<>(export, HttpStatus.OK);
|
||||
ResponseEntity<List<ClassificationResource>> response = ResponseEntity.ok(export);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from exportClassifications(), returning {}", response);
|
||||
}
|
||||
|
@ -89,7 +88,7 @@ public class ClassificationDefinitionController {
|
|||
|
||||
@PostMapping
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<String> importClassifications(
|
||||
public ResponseEntity<Void> importClassifications(
|
||||
@RequestParam("file") MultipartFile file)
|
||||
throws InvalidArgumentException, NotAuthorizedException, ConcurrencyException, ClassificationNotFoundException,
|
||||
ClassificationAlreadyExistException, DomainNotFoundException, IOException {
|
||||
|
@ -101,7 +100,7 @@ public class ClassificationDefinitionController {
|
|||
Map<Classification, String> childrenInFile = mapChildrenToParentKeys(classificationsResources, systemIds);
|
||||
insertOrUpdateClassificationsWithoutParent(classificationsResources, systemIds);
|
||||
updateParentChildrenRelations(childrenInFile);
|
||||
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
|
||||
ResponseEntity<Void> response = ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from importClassifications(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
@ -137,7 +136,8 @@ public class ClassificationDefinitionController {
|
|||
}
|
||||
}
|
||||
if (!duplicates.isEmpty()) {
|
||||
throw new DuplicateKeyException("The 'key|domain'-identifier is not unique for the value(s): " + duplicates.toString());
|
||||
throw new DuplicateKeyException(
|
||||
"The 'key|domain'-identifier is not unique for the value(s): " + duplicates.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import pro.taskana.rest.resource.ReportResourceAssembler;
|
|||
* Controller for all monitoring endpoints.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(path = "/v1/monitor", produces = "application/hal+json")
|
||||
@RequestMapping(path = "/api/v1/monitor", produces = "application/hal+json")
|
||||
public class MonitorController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MonitorController.class);
|
||||
|
@ -48,9 +48,9 @@ public class MonitorController {
|
|||
@RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException,
|
||||
InvalidArgumentException {
|
||||
LOGGER.debug("Entry to getTasksStatusReport()");
|
||||
ResponseEntity<ReportResource> response = new ResponseEntity<>(reportResourceAssembler.toResource(
|
||||
ResponseEntity<ReportResource> response = ResponseEntity.ok(reportResourceAssembler.toResource(
|
||||
taskMonitorService.createTaskStatusReportBuilder().stateIn(states).domainIn(domains).buildReport(),
|
||||
domains, states), HttpStatus.OK);
|
||||
domains, states));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
|
||||
}
|
||||
|
@ -68,7 +68,8 @@ public class MonitorController {
|
|||
ReportResource report = reportResourceAssembler.toResource(
|
||||
taskMonitorService.createWorkbasketReportBuilder()
|
||||
.withColumnHeaders(getRangeTimeInterval())
|
||||
.buildReport(), states);
|
||||
.buildReport(),
|
||||
states);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasksWorkbasketReport(), returning {}", report);
|
||||
|
@ -90,7 +91,8 @@ public class MonitorController {
|
|||
ReportResource report = reportResourceAssembler.toResource(
|
||||
taskMonitorService.createWorkbasketReportBuilder()
|
||||
.stateIn(states)
|
||||
.withColumnHeaders(getDateTimeInterval(daysInPast)).buildPlannedDateBasedReport(),
|
||||
.withColumnHeaders(getDateTimeInterval(daysInPast))
|
||||
.buildPlannedDateBasedReport(),
|
||||
daysInPast, states);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasksWorkbasketPlannedDateReport(), returning {}", report);
|
||||
|
@ -101,7 +103,6 @@ public class MonitorController {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(path = "/tasks-classification-report")
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<ReportResource> getTasksClassificationReport()
|
||||
|
@ -138,14 +139,11 @@ public class MonitorController {
|
|||
private List<TimeIntervalColumnHeader> getRangeTimeInterval() {
|
||||
return Stream.concat(Stream.concat(
|
||||
Stream.of(new TimeIntervalColumnHeader.Range(Integer.MIN_VALUE, -10),
|
||||
new TimeIntervalColumnHeader.Range(-10, -5)
|
||||
),
|
||||
new TimeIntervalColumnHeader.Range(-10, -5)),
|
||||
Stream.of(-4, -3, -2, -1, 0, 1, 2, 3, 4)
|
||||
.map(TimeIntervalColumnHeader.Range::new)
|
||||
),
|
||||
.map(TimeIntervalColumnHeader.Range::new)),
|
||||
Stream.of(new TimeIntervalColumnHeader.Range(5, 10),
|
||||
new TimeIntervalColumnHeader.Range(10, Integer.MAX_VALUE)
|
||||
))
|
||||
new TimeIntervalColumnHeader.Range(10, Integer.MAX_VALUE)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
|
@ -42,7 +41,7 @@ import pro.taskana.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.rest.resource.TaskResource;
|
||||
import pro.taskana.rest.resource.TaskResourceAssembler;
|
||||
import pro.taskana.rest.resource.TaskSummaryResource;
|
||||
import pro.taskana.rest.resource.TaskSummaryListResource;
|
||||
import pro.taskana.rest.resource.TaskSummaryResourceAssembler;
|
||||
|
||||
/**
|
||||
|
@ -50,7 +49,7 @@ import pro.taskana.rest.resource.TaskSummaryResourceAssembler;
|
|||
*/
|
||||
@RestController
|
||||
@EnableHypermediaSupport(type = HypermediaType.HAL)
|
||||
@RequestMapping(path = "/v1/tasks", produces = "application/hal+json")
|
||||
@RequestMapping(path = "/api/v1/tasks", produces = "application/hal+json")
|
||||
public class TaskController extends AbstractPagingController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskController.class);
|
||||
|
@ -89,8 +88,7 @@ public class TaskController extends AbstractPagingController {
|
|||
TaskController(
|
||||
TaskService taskService,
|
||||
TaskResourceAssembler taskResourceAssembler,
|
||||
TaskSummaryResourceAssembler taskSummaryResourceAssembler
|
||||
) {
|
||||
TaskSummaryResourceAssembler taskSummaryResourceAssembler) {
|
||||
this.taskService = taskService;
|
||||
this.taskResourceAssembler = taskResourceAssembler;
|
||||
this.taskSummaryResourceAssembler = taskSummaryResourceAssembler;
|
||||
|
@ -98,7 +96,7 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@GetMapping
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<PagedResources<TaskSummaryResource>> getTasks(
|
||||
public ResponseEntity<TaskSummaryListResource> getTasks(
|
||||
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getTasks(params= {})", params);
|
||||
|
@ -111,9 +109,9 @@ public class TaskController extends AbstractPagingController {
|
|||
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<TaskSummary> taskSummaries = getQueryList(query, pageMetadata);
|
||||
|
||||
PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourceAssembler.toResources(taskSummaries,
|
||||
TaskSummaryListResource pagedResources = taskSummaryResourceAssembler.toResources(taskSummaries,
|
||||
pageMetadata);
|
||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
||||
ResponseEntity<TaskSummaryListResource> response = ResponseEntity.ok(pagedResources);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasks(), returning {}", response);
|
||||
}
|
||||
|
@ -127,8 +125,7 @@ public class TaskController extends AbstractPagingController {
|
|||
throws TaskNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug("Entry to getTask(taskId= {})", taskId);
|
||||
Task task = taskService.getTask(taskId);
|
||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(task),
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(task));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTask(), returning {}", result);
|
||||
}
|
||||
|
@ -144,8 +141,7 @@ public class TaskController extends AbstractPagingController {
|
|||
// TODO verify user
|
||||
taskService.claim(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from claimTask(), returning {}", result);
|
||||
}
|
||||
|
@ -160,8 +156,7 @@ public class TaskController extends AbstractPagingController {
|
|||
LOGGER.debug("Entry to completeTask(taskId= {})", taskId);
|
||||
taskService.forceCompleteTask(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from completeTask(), returning {}", result);
|
||||
}
|
||||
|
@ -175,7 +170,7 @@ public class TaskController extends AbstractPagingController {
|
|||
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||
LOGGER.debug("Entry to deleteTask(taskId= {})", taskId);
|
||||
taskService.forceDeleteTask(taskId);
|
||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from deleteTask(), returning {}", result);
|
||||
return result;
|
||||
}
|
||||
|
@ -190,8 +185,8 @@ public class TaskController extends AbstractPagingController {
|
|||
}
|
||||
|
||||
Task createdTask = taskService.createTask(taskResourceAssembler.toModel(taskResource));
|
||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(createdTask),
|
||||
HttpStatus.CREATED);
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(taskResourceAssembler.toResource(createdTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createTask(), returning {}", result);
|
||||
}
|
||||
|
@ -205,8 +200,7 @@ public class TaskController extends AbstractPagingController {
|
|||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException {
|
||||
LOGGER.debug("Entry to transferTask(taskId= {}, workbasketId= {})", taskId, workbasketId);
|
||||
Task updatedTask = taskService.transfer(taskId, workbasketId);
|
||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from transferTask(), returning {}", result);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaRole;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
|
@ -16,12 +19,11 @@ import pro.taskana.rest.resource.TaskanaUserInfoResource;
|
|||
import pro.taskana.rest.resource.VersionResource;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controller for TaskanaEngine related tasks.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(path = "/api/v1", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public class TaskanaEngineController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineController.class);
|
||||
|
@ -40,46 +42,44 @@ public class TaskanaEngineController {
|
|||
@Value("${version:Local build}")
|
||||
private String version;
|
||||
|
||||
@GetMapping(path = "/v1/domains", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@GetMapping(path = "/domains")
|
||||
public ResponseEntity<List<String>> getDomains() {
|
||||
ResponseEntity<List<String>> response = new ResponseEntity<>(taskanaEngineConfiguration.getDomains(),
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<List<String>> response = ResponseEntity.ok(taskanaEngineConfiguration.getDomains());
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getDomains(), returning {}", response);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/v1/classification-categories", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@GetMapping(path = "/classification-categories")
|
||||
public ResponseEntity<List<String>> getClassificationCategories(String type) {
|
||||
LOGGER.debug("Entry to getClassificationCategories(type = {})", type);
|
||||
ResponseEntity<List<String>> response;
|
||||
if (type != null) {
|
||||
response = new ResponseEntity<>(taskanaEngineConfiguration.getClassificationCategoriesByType(type),
|
||||
HttpStatus.OK);
|
||||
response = ResponseEntity.ok(taskanaEngineConfiguration.getClassificationCategoriesByType(type));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getClassificationCategories(), returning {}", response);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
response = new ResponseEntity<>(taskanaEngineConfiguration.getAllClassificationCategories(), HttpStatus.OK);
|
||||
response = ResponseEntity.ok(taskanaEngineConfiguration.getAllClassificationCategories());
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getClassificationCategories(), returning {}", response);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/v1/classification-types", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@GetMapping(path = "/classification-types")
|
||||
public ResponseEntity<List<String>> getClassificationTypes() {
|
||||
ResponseEntity<List<String>> response = new ResponseEntity<>(
|
||||
taskanaEngineConfiguration.getClassificationTypes(), HttpStatus.OK);
|
||||
ResponseEntity<List<String>> response = ResponseEntity.ok(
|
||||
taskanaEngineConfiguration.getClassificationTypes());
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getClassificationTypes(), returning {}", response);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/v1/current-user-info", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@GetMapping(path = "/current-user-info")
|
||||
public ResponseEntity<TaskanaUserInfoResource> getCurrentUserInfo() {
|
||||
LOGGER.debug("Entry to getCurrentUserInfo()");
|
||||
TaskanaUserInfoResource resource = new TaskanaUserInfoResource();
|
||||
|
@ -90,7 +90,7 @@ public class TaskanaEngineController {
|
|||
resource.getRoles().add(role);
|
||||
}
|
||||
}
|
||||
ResponseEntity<TaskanaUserInfoResource> response = new ResponseEntity<>(resource, HttpStatus.OK);
|
||||
ResponseEntity<TaskanaUserInfoResource> response = ResponseEntity.ok(resource);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getCurrentUserInfo(), returning {}", response);
|
||||
}
|
||||
|
@ -98,11 +98,10 @@ public class TaskanaEngineController {
|
|||
return response;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/v1/history-provider-enabled", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@GetMapping(path = "/history-provider-enabled")
|
||||
public ResponseEntity<Boolean> getIsHistoryProviderEnabled() {
|
||||
ResponseEntity<Boolean> response = new ResponseEntity<>(
|
||||
((TaskanaEngineImpl) taskanaEngine).getHistoryEventProducer().isEnabled(),
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<Boolean> response = ResponseEntity.ok(
|
||||
((TaskanaEngineImpl) taskanaEngine).getHistoryEventProducer().isEnabled());
|
||||
LOGGER.debug("Exit from getIsHistoryProviderEnabled(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
@ -112,12 +111,12 @@ public class TaskanaEngineController {
|
|||
*
|
||||
* @return The current version.
|
||||
*/
|
||||
@GetMapping(path = "/v1/version", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@GetMapping(path = "/version")
|
||||
public ResponseEntity<VersionResource> currentVersion() {
|
||||
LOGGER.debug("Entry to currentVersion()");
|
||||
VersionResource resource = new VersionResource();
|
||||
resource.setVersion(TaskanaEngineConfiguration.class.getPackage().getImplementationVersion());
|
||||
ResponseEntity<VersionResource> response = new ResponseEntity<>(resource, HttpStatus.OK);
|
||||
ResponseEntity<VersionResource> response = ResponseEntity.ok(resource);
|
||||
LOGGER.debug("Exit from currentVersion(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
|||
private ResponseEntity<Object> buildResponse(Exception ex, WebRequest req, HttpStatus status) {
|
||||
TaskanaErrorData errorData = new TaskanaErrorData(status, ex, req);
|
||||
logError(ex, errorData);
|
||||
return new ResponseEntity<>(errorData, status);
|
||||
return ResponseEntity.status(status).body(errorData);
|
||||
}
|
||||
|
||||
private void logError(Exception ex, TaskanaErrorData errorData) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
@ -25,7 +24,7 @@ import pro.taskana.WorkbasketService;
|
|||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.ldap.LdapClient;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemPaginatedListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +32,7 @@ import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
|
|||
*/
|
||||
@RestController
|
||||
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
|
||||
@RequestMapping(path = "/v1/workbasket-access-items", produces = "application/hal+json")
|
||||
@RequestMapping(path = "/api/v1/workbasket-access-items", produces = "application/hal+json")
|
||||
public class WorkbasketAccessItemController extends AbstractPagingController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketAccessItemController.class);
|
||||
|
@ -60,13 +59,16 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
/**
|
||||
* This GET method return all workbasketAccessItems that correspond the given data.
|
||||
*
|
||||
* @param params filter, order and access ids.
|
||||
* @param params
|
||||
* filter, order and access ids.
|
||||
* @return all WorkbasketAccesItemResource.
|
||||
* @throws NotAuthorizedException if the user is not authorized.
|
||||
* @throws InvalidArgumentException if some argument is invalid.
|
||||
* @throws NotAuthorizedException
|
||||
* if the user is not authorized.
|
||||
* @throws InvalidArgumentException
|
||||
* if some argument is invalid.
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseEntity<PagedResources<WorkbasketAccessItemResource>> getWorkbasketAccessItems(
|
||||
public ResponseEntity<WorkbasketAccessItemPaginatedListResource> getWorkbasketAccessItems(
|
||||
@RequestParam MultiValueMap<String, String> params)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
@ -81,13 +83,11 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
PagedResources.PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<WorkbasketAccessItem> workbasketAccessItems = getQueryList(query, pageMetadata);
|
||||
|
||||
PagedResources<WorkbasketAccessItemResource> pagedResources = workbasketAccessItemResourceAssembler.toResources(
|
||||
WorkbasketAccessItemPaginatedListResource pagedResources = workbasketAccessItemResourceAssembler.toResources(
|
||||
workbasketAccessItems,
|
||||
pageMetadata
|
||||
);
|
||||
pageMetadata);
|
||||
|
||||
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(pagedResources,
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<WorkbasketAccessItemPaginatedListResource> response = ResponseEntity.ok(pagedResources);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", response);
|
||||
}
|
||||
|
@ -98,10 +98,13 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
/**
|
||||
* This DELETE method delete all workbasketAccessItems that correspond the given accessId.
|
||||
*
|
||||
* @param accessId which need remove his workbasketAccessItems.
|
||||
* @param accessId
|
||||
* which need remove his workbasketAccessItems.
|
||||
* @return ResponseEntity if the user is not authorized.
|
||||
* @throws NotAuthorizedException if the user is not authorized.
|
||||
* @throws InvalidArgumentException if some argument is invalid.
|
||||
* @throws NotAuthorizedException
|
||||
* if the user is not authorized.
|
||||
* @throws InvalidArgumentException
|
||||
* if some argument is invalid.
|
||||
*/
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Void> removeWorkbasketAccessItems(
|
||||
|
@ -121,7 +124,7 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
accessId + " corresponding to a group, not a user. You just can remove access items for a user");
|
||||
}
|
||||
|
||||
ResponseEntity<Void> response = new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
ResponseEntity<Void> response = ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from removeWorkbasketAccessItems(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
import org.springframework.hateoas.Resources;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
|
@ -41,13 +40,15 @@ import pro.taskana.exceptions.WorkbasketAlreadyExistException;
|
|||
import pro.taskana.exceptions.WorkbasketInUseException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.rest.resource.DistributionTargetListResource;
|
||||
import pro.taskana.rest.resource.DistributionTargetResource;
|
||||
import pro.taskana.rest.resource.DistributionTargetResourceAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketResource;
|
||||
import pro.taskana.rest.resource.WorkbasketResourceAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryResource;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryResourceAssembler;
|
||||
|
||||
/**
|
||||
|
@ -55,7 +56,7 @@ import pro.taskana.rest.resource.WorkbasketSummaryResourceAssembler;
|
|||
*/
|
||||
@RestController
|
||||
@EnableHypermediaSupport(type = HypermediaType.HAL)
|
||||
@RequestMapping(path = "/v1/workbaskets", produces = "application/hal+json")
|
||||
@RequestMapping(path = "/api/v1/workbaskets", produces = "application/hal+json")
|
||||
public class WorkbasketController extends AbstractPagingController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketController.class);
|
||||
|
@ -100,7 +101,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@GetMapping
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<PagedResources<WorkbasketSummaryResource>> getWorkbaskets(
|
||||
public ResponseEntity<WorkbasketSummaryListResource> getWorkbaskets(
|
||||
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getWorkbaskets(params= {})", params);
|
||||
|
@ -112,11 +113,11 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<WorkbasketSummary> workbasketSummaries = getQueryList(query, pageMetadata);
|
||||
PagedResources<WorkbasketSummaryResource> pagedResources = workbasketSummaryResourceAssembler.toResources(workbasketSummaries,
|
||||
WorkbasketSummaryListResource pagedResources = workbasketSummaryResourceAssembler.toResources(
|
||||
workbasketSummaries,
|
||||
pageMetadata);
|
||||
|
||||
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = new ResponseEntity<>(pagedResources,
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity.ok(pagedResources);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbaskets(), returning {}", response);
|
||||
}
|
||||
|
@ -131,7 +132,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
LOGGER.debug("Entry to getWorkbasket(workbasketId= {})", workbasketId);
|
||||
ResponseEntity<WorkbasketResource> result;
|
||||
Workbasket workbasket = workbasketService.getWorkbasket(workbasketId);
|
||||
result = new ResponseEntity<>(workbasketResourceAssembler.toResource(workbasket), HttpStatus.OK);
|
||||
result = ResponseEntity.ok(workbasketResourceAssembler.toResource(workbasket));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbasket(), returning {}", result);
|
||||
}
|
||||
|
@ -145,8 +146,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
throws NotAuthorizedException, InvalidArgumentException,
|
||||
WorkbasketNotFoundException, WorkbasketInUseException {
|
||||
LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId);
|
||||
ResponseEntity<?> response = new ResponseEntity<>(workbasketService.deleteWorkbasket(workbasketId),
|
||||
HttpStatus.ACCEPTED);
|
||||
ResponseEntity<?> response = ResponseEntity.accepted().body(workbasketService.deleteWorkbasket(workbasketId));
|
||||
LOGGER.debug("Exit from markWorkbasketForDeletion(), returning {}",
|
||||
response);
|
||||
return response;
|
||||
|
@ -163,8 +163,8 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource);
|
||||
workbasket = workbasketService.createWorkbasket(workbasket);
|
||||
ResponseEntity<WorkbasketResource> response = new ResponseEntity<>(
|
||||
workbasketResourceAssembler.toResource(workbasket), HttpStatus.CREATED);
|
||||
ResponseEntity<WorkbasketResource> response = ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(workbasketResourceAssembler.toResource(workbasket));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createWorkbasket(), returning {}", response);
|
||||
}
|
||||
|
@ -200,15 +200,14 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@GetMapping(path = "/{workbasketId}/workbasketAccessItems")
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<Resources<WorkbasketAccessItemResource>> getWorkbasketAccessItems(
|
||||
public ResponseEntity<WorkbasketAccessItemListResource> getWorkbasketAccessItems(
|
||||
@PathVariable(value = "workbasketId") String workbasketId)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
LOGGER.debug("Entry to getWorkbasketAccessItems(workbasketId= {})", workbasketId);
|
||||
ResponseEntity<Resources<WorkbasketAccessItemResource>> result;
|
||||
ResponseEntity<WorkbasketAccessItemListResource> result;
|
||||
|
||||
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(workbasketId);
|
||||
result = new ResponseEntity<>(workbasketAccessItemResourceAssembler
|
||||
.toResources(workbasketId, accessItems), HttpStatus.OK);
|
||||
result = ResponseEntity.ok(workbasketAccessItemResourceAssembler.toResources(workbasketId, accessItems));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result);
|
||||
}
|
||||
|
@ -218,7 +217,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@PutMapping(value = "/{workbasketId}/workbasketAccessItems")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Resources<WorkbasketAccessItemResource>> setWorkbasketAccessItems(
|
||||
public ResponseEntity<WorkbasketAccessItemListResource> setWorkbasketAccessItems(
|
||||
@PathVariable(value = "workbasketId") String workbasketId,
|
||||
@RequestBody List<WorkbasketAccessItemResource> workbasketAccessResourceItems)
|
||||
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
|
||||
|
@ -233,9 +232,8 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems);
|
||||
List<WorkbasketAccessItem> updatedWbAccessItems = workbasketService.getWorkbasketAccessItems(workbasketId);
|
||||
|
||||
ResponseEntity<Resources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(
|
||||
workbasketAccessItemResourceAssembler
|
||||
.toResources(workbasketId, updatedWbAccessItems), HttpStatus.OK);
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity.ok(
|
||||
workbasketAccessItemResourceAssembler.toResources(workbasketId, updatedWbAccessItems));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response);
|
||||
}
|
||||
|
@ -245,16 +243,15 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@GetMapping(path = "/{workbasketId}/distribution-targets")
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<Resources<DistributionTargetResource>> getDistributionTargets(
|
||||
public ResponseEntity<DistributionTargetListResource> getDistributionTargets(
|
||||
@PathVariable(value = "workbasketId") String workbasketId)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
|
||||
LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId);
|
||||
ResponseEntity<Resources<DistributionTargetResource>> result;
|
||||
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasketId);
|
||||
Resources<DistributionTargetResource> distributionTargetListResource = distributionTargetResourceAssembler
|
||||
DistributionTargetListResource distributionTargetListResource = distributionTargetResourceAssembler
|
||||
.toResources(workbasketId, distributionTargets);
|
||||
result = new ResponseEntity<>(distributionTargetListResource, HttpStatus.OK);
|
||||
ResponseEntity<DistributionTargetListResource> result = ResponseEntity.ok(distributionTargetListResource);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getDistributionTargets(), returning {}", result);
|
||||
}
|
||||
|
@ -264,7 +261,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@PutMapping(path = "/{workbasketId}/distribution-targets")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Resources<DistributionTargetResource>> setDistributionTargetsForWorkbasketId(
|
||||
public ResponseEntity<DistributionTargetListResource> setDistributionTargetsForWorkbasketId(
|
||||
@PathVariable(value = "workbasketId") String sourceWorkbasketId,
|
||||
@RequestBody List<String> targetWorkbasketIds) throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
@ -276,9 +273,8 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
workbasketService.setDistributionTargets(sourceWorkbasketId, targetWorkbasketIds);
|
||||
|
||||
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(sourceWorkbasketId);
|
||||
ResponseEntity<Resources<DistributionTargetResource>> response = new ResponseEntity<>(
|
||||
distributionTargetResourceAssembler
|
||||
.toResources(sourceWorkbasketId, distributionTargets), HttpStatus.OK);
|
||||
ResponseEntity<DistributionTargetListResource> response = ResponseEntity.ok(
|
||||
distributionTargetResourceAssembler.toResources(sourceWorkbasketId, distributionTargets));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
|
||||
}
|
||||
|
@ -297,7 +293,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
workbasketService.removeDistributionTarget(source.getId(), targetWorkbasketId);
|
||||
}
|
||||
|
||||
ResponseEntity<Resources<DistributionTargetResource>> response = new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
ResponseEntity<Resources<DistributionTargetResource>> response = ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from removeDistributionTargetForWorkbasketId(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.util.stream.Collectors;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -47,7 +46,7 @@ import pro.taskana.rest.resource.WorkbasketResource;
|
|||
* Controller for all {@link WorkbasketDefinitionResource} related endpoints.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(path = "/v1/workbasket-definitions", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@RequestMapping(path = "/api/v1/workbasket-definitions", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public class WorkbasketDefinitionController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketDefinitionController.class);
|
||||
|
@ -58,8 +57,7 @@ public class WorkbasketDefinitionController {
|
|||
|
||||
WorkbasketDefinitionController(
|
||||
WorkbasketService workbasketService,
|
||||
WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler
|
||||
) {
|
||||
WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler) {
|
||||
this.workbasketService = workbasketService;
|
||||
this.workbasketDefinitionAssembler = workbasketDefinitionAssembler;
|
||||
}
|
||||
|
@ -80,8 +78,7 @@ public class WorkbasketDefinitionController {
|
|||
basketExports.add(workbasketDefinitionAssembler.toResource(workbasket));
|
||||
}
|
||||
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response = new ResponseEntity<>(basketExports,
|
||||
HttpStatus.OK);
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response = ResponseEntity.ok(basketExports);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from exportWorkbaskets(), returning {}", response);
|
||||
}
|
||||
|
@ -90,24 +87,32 @@ public class WorkbasketDefinitionController {
|
|||
}
|
||||
|
||||
/**
|
||||
* This method imports a <b>list of {@link WorkbasketDefinitionResource}</b>. This does not exactly match the REST norm, but
|
||||
* we want to have an option to import all settings at once. When a logical equal (key and domain are equal)
|
||||
* workbasket already exists an update will be executed. Otherwise a new workbasket will be created.
|
||||
* This method imports a <b>list of {@link WorkbasketDefinitionResource}</b>. This does not exactly match the REST
|
||||
* norm, but we want to have an option to import all settings at once. When a logical equal (key and domain are
|
||||
* equal) workbasket already exists an update will be executed. Otherwise a new workbasket will be created.
|
||||
*
|
||||
* @param file the list of workbasket definitions which will be imported to the current system.
|
||||
* @param file
|
||||
* the list of workbasket definitions which will be imported to the current system.
|
||||
* @return Return answer is determined by the status code: 200 - all good 400 - list state error (referring to non
|
||||
* existing id's) 401 - not authorized
|
||||
* @throws IOException if multipart file cannot be parsed.
|
||||
* @throws NotAuthorizedException if the user is not authorized.
|
||||
* @throws DomainNotFoundException if domain information is incorrect.
|
||||
* @throws InvalidWorkbasketException if workbasket has invalid information.
|
||||
* @throws WorkbasketAlreadyExistException if workbasket already exists when trying to create a new one.
|
||||
* @throws WorkbasketNotFoundException if do not exists a workbasket in the system with the used id.
|
||||
* @throws InvalidArgumentException if authorization information in workbaskets definitions is incorrect.
|
||||
* existing id's) 401 - not authorized
|
||||
* @throws IOException
|
||||
* if multipart file cannot be parsed.
|
||||
* @throws NotAuthorizedException
|
||||
* if the user is not authorized.
|
||||
* @throws DomainNotFoundException
|
||||
* if domain information is incorrect.
|
||||
* @throws InvalidWorkbasketException
|
||||
* if workbasket has invalid information.
|
||||
* @throws WorkbasketAlreadyExistException
|
||||
* if workbasket already exists when trying to create a new one.
|
||||
* @throws WorkbasketNotFoundException
|
||||
* if do not exists a workbasket in the system with the used id.
|
||||
* @throws InvalidArgumentException
|
||||
* if authorization information in workbaskets definitions is incorrect.
|
||||
*/
|
||||
@PostMapping
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<String> importWorkbaskets(@RequestParam("file") MultipartFile file)
|
||||
public ResponseEntity<Void> importWorkbaskets(@RequestParam("file") MultipartFile file)
|
||||
throws IOException, NotAuthorizedException, DomainNotFoundException, InvalidWorkbasketException,
|
||||
WorkbasketAlreadyExistException, WorkbasketNotFoundException, InvalidArgumentException {
|
||||
LOGGER.debug("Entry to importWorkbaskets()");
|
||||
|
@ -172,7 +177,7 @@ public class WorkbasketDefinitionController {
|
|||
// no verification necessary since the workbasket was already imported in step 1.
|
||||
idConversion.get(definition.getWorkbasket().getWorkbasketId()), distributionTargets);
|
||||
}
|
||||
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
|
||||
ResponseEntity<Void> response = ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from importWorkbaskets(), returning {}", response);
|
||||
return response;
|
||||
}
|
||||
|
@ -195,7 +200,8 @@ public class WorkbasketDefinitionController {
|
|||
}
|
||||
}
|
||||
if (!duplicates.isEmpty()) {
|
||||
throw new DuplicateKeyException("The 'key|domain'-identifier is not unique for the value(s): " + duplicates.toString());
|
||||
throw new DuplicateKeyException(
|
||||
"The 'key|domain'-identifier is not unique for the value(s): " + duplicates.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Resource class for {@link ClassificationSummaryResource} with Pagination.
|
||||
*/
|
||||
public class ClassificationSummaryListResource extends PagedResources<ClassificationSummaryResource> {
|
||||
|
||||
public ClassificationSummaryListResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ClassificationSummaryListResource(Collection<ClassificationSummaryResource> content, PageMetadata metadata,
|
||||
Iterable<Link> links) {
|
||||
super(content, metadata, links);
|
||||
}
|
||||
|
||||
public ClassificationSummaryListResource(Collection<ClassificationSummaryResource> content, PageMetadata metadata,
|
||||
Link... links) {
|
||||
super(content, metadata, links);
|
||||
}
|
||||
|
||||
@JsonProperty("classifications")
|
||||
public Collection<ClassificationSummaryResource> getContent() {
|
||||
return super.getContent();
|
||||
}
|
||||
}
|
|
@ -44,8 +44,8 @@ public class ClassificationSummaryResourceAssembler
|
|||
}
|
||||
|
||||
@PageLinks(ClassificationController.class)
|
||||
public PagedResources<ClassificationSummaryResource> toResources(Collection<ClassificationSummary> entities,
|
||||
public ClassificationSummaryListResource toResources(Collection<ClassificationSummary> entities,
|
||||
PagedResources.PageMetadata pageMetadata) {
|
||||
return new PagedResources<>(toResources(entities), pageMetadata);
|
||||
return new ClassificationSummaryListResource(toResources(entities), pageMetadata);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Resource class for {@link DistributionTargetResource} with Pagination.
|
||||
*/
|
||||
public class DistributionTargetListResource extends PagedResources<DistributionTargetResource> {
|
||||
|
||||
public DistributionTargetListResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DistributionTargetListResource(Collection<DistributionTargetResource> content, Link... links) {
|
||||
super(content, null, links);
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonProperty("distributionTargets")
|
||||
public Collection<DistributionTargetResource> getContent() {
|
||||
return super.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public PageMetadata getMetadata() {
|
||||
return super.getMetadata();
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.hateoas.Resources;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -29,9 +28,11 @@ public class DistributionTargetResourceAssembler extends
|
|||
return new DistributionTargetResource(summary);
|
||||
}
|
||||
|
||||
public Resources<DistributionTargetResource> toResources(String workbasketId,
|
||||
public DistributionTargetListResource toResources(String workbasketId,
|
||||
List<WorkbasketSummary> distributionTargets) throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
Resources<DistributionTargetResource> distributionTargetListResource = new Resources<>(super.toResources(distributionTargets));
|
||||
|
||||
DistributionTargetListResource distributionTargetListResource = new DistributionTargetListResource(
|
||||
toResources(distributionTargets));
|
||||
distributionTargetListResource
|
||||
.add(linkTo(methodOn(WorkbasketController.class).getDistributionTargets(workbasketId))
|
||||
.withSelfRel());
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Base Class for Resources with pagination.
|
||||
*
|
||||
* @param <T>
|
||||
* The Class of the paginatied content
|
||||
*/
|
||||
public class PagedResources<T> extends ResourceSupport {
|
||||
|
||||
private Collection<T> content;
|
||||
|
||||
private PageMetadata metadata;
|
||||
|
||||
/**
|
||||
* Default constructor to allow instantiation by reflection.
|
||||
*/
|
||||
protected PagedResources() {
|
||||
this(new ArrayList<T>(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link PagedResources} from the given content, {@link PageMetadata} and {@link Link}s (optional).
|
||||
*
|
||||
* @param content
|
||||
* must not be {@literal null}.
|
||||
* @param metadata
|
||||
* the metadata
|
||||
* @param links
|
||||
* the links
|
||||
*/
|
||||
public PagedResources(Collection<T> content, PageMetadata metadata, Link... links) {
|
||||
this(content, metadata, Arrays.asList(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link PagedResources} from the given content {@link PageMetadata} and {@link Link}s.
|
||||
*
|
||||
* @param content
|
||||
* must not be {@literal null}.
|
||||
* @param metadata
|
||||
* the metadata
|
||||
* @param links
|
||||
* the links
|
||||
*/
|
||||
public PagedResources(Collection<T> content, PageMetadata metadata, Iterable<Link> links) {
|
||||
super();
|
||||
this.content = content;
|
||||
this.metadata = metadata;
|
||||
this.add(links);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pagination metadata.
|
||||
*
|
||||
* @return the metadata
|
||||
*/
|
||||
@JsonProperty("page")
|
||||
public PageMetadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content.
|
||||
*
|
||||
* @return the content
|
||||
*/
|
||||
@JsonProperty("content")
|
||||
public Collection<T> getContent() {
|
||||
return Collections.unmodifiableCollection(content);
|
||||
};
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Resource class for {@link TaskSummaryResource} with Pagination.
|
||||
*/
|
||||
public class TaskSummaryListResource extends PagedResources<TaskSummaryResource> {
|
||||
|
||||
public TaskSummaryListResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TaskSummaryListResource(Collection<TaskSummaryResource> content, PageMetadata metadata,
|
||||
Iterable<Link> links) {
|
||||
super(content, metadata, links);
|
||||
}
|
||||
|
||||
public TaskSummaryListResource(Collection<TaskSummaryResource> content, PageMetadata metadata, Link... links) {
|
||||
super(content, metadata, links);
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonProperty("tasks")
|
||||
public Collection<TaskSummaryResource> getContent() {
|
||||
return super.getContent();
|
||||
}
|
||||
|
||||
}
|
|
@ -35,9 +35,9 @@ public class TaskSummaryResourceAssembler
|
|||
}
|
||||
|
||||
@PageLinks(TaskController.class)
|
||||
public PagedResources<TaskSummaryResource> toResources(List<TaskSummary> taskSummaries,
|
||||
public TaskSummaryListResource toResources(List<TaskSummary> taskSummaries,
|
||||
PagedResources.PageMetadata pageMetadata) {
|
||||
return new PagedResources<>(toResources(taskSummaries), pageMetadata);
|
||||
return new TaskSummaryListResource(toResources(taskSummaries), pageMetadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* Resource class for {@link WorkbasketAccessItemResource} without Pagination.
|
||||
*/
|
||||
public class WorkbasketAccessItemListResource extends WorkbasketAccessItemPaginatedListResource {
|
||||
|
||||
public WorkbasketAccessItemListResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public WorkbasketAccessItemListResource(Collection<WorkbasketAccessItemResource> content, Link... links) {
|
||||
super(content, null, links);
|
||||
}
|
||||
|
||||
public WorkbasketAccessItemListResource(Collection<WorkbasketAccessItemResource> content, Iterable<Link> links) {
|
||||
super(content, null, links);
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public PageMetadata getMetadata() {
|
||||
return super.getMetadata();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Resource class for {@link WorkbasketAccessItemResource} with Pagination.
|
||||
*/
|
||||
public class WorkbasketAccessItemPaginatedListResource extends PagedResources<WorkbasketAccessItemResource> {
|
||||
|
||||
public WorkbasketAccessItemPaginatedListResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public WorkbasketAccessItemPaginatedListResource(Collection<WorkbasketAccessItemResource> content, PageMetadata metadata,
|
||||
Link... links) {
|
||||
super(content, metadata, links);
|
||||
}
|
||||
|
||||
public WorkbasketAccessItemPaginatedListResource(Collection<WorkbasketAccessItemResource> content, PageMetadata metadata,
|
||||
Iterable<Link> links) {
|
||||
super(content, metadata, links);
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonProperty("accessItems")
|
||||
public Collection<WorkbasketAccessItemResource> getContent() {
|
||||
return super.getContent();
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,6 @@ import java.util.List;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.PagedResources;
|
||||
import org.springframework.hateoas.Resources;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -31,11 +30,11 @@ public class WorkbasketAccessItemResourceAssembler extends
|
|||
|
||||
@Autowired
|
||||
private WorkbasketService workbasketService;
|
||||
|
||||
public WorkbasketAccessItemResourceAssembler() {
|
||||
super(WorkbasketController.class, WorkbasketAccessItemResource.class);
|
||||
}
|
||||
|
||||
|
||||
public WorkbasketAccessItemResource toResource(WorkbasketAccessItem wbAccItem) {
|
||||
return new WorkbasketAccessItemResource(wbAccItem);
|
||||
}
|
||||
|
@ -49,16 +48,18 @@ public class WorkbasketAccessItemResourceAssembler extends
|
|||
return wbAccItemModel;
|
||||
}
|
||||
|
||||
|
||||
@PageLinks(WorkbasketAccessItemController.class)
|
||||
public PagedResources<WorkbasketAccessItemResource> toResources(List<WorkbasketAccessItem> entities,
|
||||
public WorkbasketAccessItemPaginatedListResource toResources(
|
||||
List<WorkbasketAccessItem> entities,
|
||||
PagedResources.PageMetadata pageMetadata) {
|
||||
return new PagedResources<>(toResources(entities), pageMetadata);
|
||||
return new WorkbasketAccessItemPaginatedListResource(toResources(entities), pageMetadata);
|
||||
}
|
||||
|
||||
public Resources<WorkbasketAccessItemResource> toResources(String workbasketId, List<WorkbasketAccessItem> entities)
|
||||
public WorkbasketAccessItemListResource toResources(
|
||||
String workbasketId, List<WorkbasketAccessItem> entities)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
Resources<WorkbasketAccessItemResource> accessItemListResource = new Resources<>(super.toResources(entities));
|
||||
WorkbasketAccessItemListResource accessItemListResource = new WorkbasketAccessItemListResource(
|
||||
super.toResources(entities));
|
||||
accessItemListResource
|
||||
.add(linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(workbasketId))
|
||||
.withSelfRel());
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Resource class for {@link WorkbasketSummaryResource} with Pagination.
|
||||
*/
|
||||
public class WorkbasketSummaryListResource extends PagedResources<WorkbasketSummaryResource> {
|
||||
|
||||
public WorkbasketSummaryListResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public WorkbasketSummaryListResource(Collection<WorkbasketSummaryResource> content, PageMetadata metadata,
|
||||
Link... links) {
|
||||
super(content, metadata, links);
|
||||
}
|
||||
|
||||
public WorkbasketSummaryListResource(Collection<WorkbasketSummaryResource> content, PageMetadata metadata,
|
||||
Iterable<Link> links) {
|
||||
super(content, metadata, links);
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonProperty("workbaskets")
|
||||
public Collection<WorkbasketSummaryResource> getContent() {
|
||||
return super.getContent();
|
||||
}
|
||||
}
|
|
@ -34,9 +34,9 @@ public class WorkbasketSummaryResourceAssembler
|
|||
}
|
||||
|
||||
@PageLinks(WorkbasketController.class)
|
||||
public PagedResources<WorkbasketSummaryResource> toResources(List<WorkbasketSummary> entities,
|
||||
public WorkbasketSummaryListResource toResources(List<WorkbasketSummary> entities,
|
||||
PagedResources.PageMetadata pageMetadata) {
|
||||
return new PagedResources<>(toResources(entities), pageMetadata);
|
||||
return new WorkbasketSummaryListResource(toResources(entities), pageMetadata);
|
||||
}
|
||||
|
||||
public WorkbasketSummary toModel(WorkbasketSummaryResource resource) {
|
||||
|
|
|
@ -131,7 +131,7 @@ export class AccessItemsManagementComponent implements OnInit, OnDestroy {
|
|||
this.sortModel,
|
||||
true)
|
||||
.subscribe((accessItemsResource: AccessItemsWorkbasketResource) => {
|
||||
this.setAccessItemsGroups(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []);
|
||||
this.setAccessItemsGroups(accessItemsResource ? accessItemsResource.accessItems : []);
|
||||
this.requestInProgressService.setRequestInProgress(false);
|
||||
},
|
||||
error => {
|
||||
|
|
|
@ -47,12 +47,11 @@ describe('AccessItemsComponent', () => {
|
|||
workbasketService = TestBed.get(WorkbasketService);
|
||||
alertService = TestBed.get(AlertService);
|
||||
spyOn(workbasketService, 'getWorkBasketAccessItems').and.returnValue(of(new WorkbasketAccessItemsResource(
|
||||
{
|
||||
'accessItems': new Array<WorkbasketAccessItems>(
|
||||
new Array<WorkbasketAccessItems>(
|
||||
new WorkbasketAccessItems('id1', '1', 'accessID1', '', false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false),
|
||||
new WorkbasketAccessItems('id2', '1', 'accessID2'))
|
||||
}, new Links({ 'href': 'someurl' })
|
||||
, new Links({ 'href': 'someurl' })
|
||||
)));
|
||||
spyOn(workbasketService, 'updateWorkBasketAccessItem').and.returnValue(of(true)),
|
||||
spyOn(alertService, 'triggerAlert').and.returnValue(of(true)),
|
||||
|
|
|
@ -106,9 +106,9 @@ export class AccessItemsComponent implements OnChanges, OnDestroy {
|
|||
this.accessItemsubscription = this.workbasketService.getWorkBasketAccessItems(this.workbasket._links.accessItems.href)
|
||||
.subscribe((accessItemsResource: WorkbasketAccessItemsResource) => {
|
||||
this.accessItemsResource = accessItemsResource;
|
||||
this.setAccessItemsGroups(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []);
|
||||
this.accessItemsClone = this.cloneAccessItems(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []);
|
||||
this.accessItemsResetClone = this.cloneAccessItems(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []);
|
||||
this.setAccessItemsGroups(accessItemsResource.accessItems);
|
||||
this.accessItemsClone = this.cloneAccessItems(accessItemsResource.accessItems);
|
||||
this.accessItemsResetClone = this.cloneAccessItems(accessItemsResource.accessItems);
|
||||
this.requestInProgress = false;
|
||||
})
|
||||
this.savingAccessItemsSubscription = this.savingWorkbaskets.triggeredAccessItemsSaving()
|
||||
|
|
|
@ -25,118 +25,118 @@ import { configureTests } from 'app/app.test.configuration';
|
|||
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
|
||||
|
||||
describe('DistributionTargetsComponent', () => {
|
||||
let component: DistributionTargetsComponent;
|
||||
let fixture: ComponentFixture<DistributionTargetsComponent>;
|
||||
let workbasketService;
|
||||
const workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
new Links({ 'href': 'someurl' }, { 'href': 'someurl' }, { 'href': 'someurl' }));
|
||||
let component: DistributionTargetsComponent;
|
||||
let fixture: ComponentFixture<DistributionTargetsComponent>;
|
||||
let workbasketService;
|
||||
const workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
new Links({ 'href': 'someurl' }, { 'href': 'someurl' }, { 'href': 'someurl' }));
|
||||
|
||||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [AngularSvgIconModule, HttpClientModule, InfiniteScrollModule],
|
||||
declarations: [DistributionTargetsComponent, DualListComponent],
|
||||
providers: [WorkbasketService, AlertService, SavingWorkbasketService, GeneralModalService, RequestInProgressService,
|
||||
]
|
||||
})
|
||||
};
|
||||
configureTests(configure).then(testBed => {
|
||||
fixture = TestBed.createComponent(DistributionTargetsComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.workbasket = workbasket;
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => {
|
||||
return of(new WorkbasketSummaryResource(
|
||||
{
|
||||
'workbaskets': new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
|
||||
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
|
||||
new WorkbasketSummary('id3', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
|
||||
}, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||
})
|
||||
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => {
|
||||
return of(new WorkbasketDistributionTargetsResource(
|
||||
{
|
||||
'distributionTargets': new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
|
||||
}, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||
})
|
||||
component.ngOnChanges({
|
||||
active: new SimpleChange(undefined, 'distributionTargets', true)
|
||||
});
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [AngularSvgIconModule, HttpClientModule, InfiniteScrollModule],
|
||||
declarations: [DistributionTargetsComponent, DualListComponent],
|
||||
providers: [WorkbasketService, AlertService, SavingWorkbasketService, GeneralModalService, RequestInProgressService,
|
||||
]
|
||||
})
|
||||
};
|
||||
configureTests(configure).then(testBed => {
|
||||
fixture = TestBed.createComponent(DistributionTargetsComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.workbasket = workbasket;
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => {
|
||||
return of(new WorkbasketSummaryResource(
|
||||
new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
|
||||
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
|
||||
new WorkbasketSummary('id3', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
|
||||
, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||
})
|
||||
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => {
|
||||
return of(new WorkbasketDistributionTargetsResource(
|
||||
new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
|
||||
, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||
})
|
||||
component.ngOnChanges({
|
||||
active: new SimpleChange(undefined, 'distributionTargets', true)
|
||||
});
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should clone distribution target selected on init', () => {
|
||||
expect(component.distributionTargetsClone).toBeDefined();
|
||||
});
|
||||
it('should clone distribution target selected on init', () => {
|
||||
expect(component.distributionTargetsClone).toBeDefined();
|
||||
});
|
||||
|
||||
it('should clone distribution target left and distribution target right lists on init', () => {
|
||||
expect(component.distributionTargetsLeft).toBeDefined();
|
||||
expect(component.distributionTargetsRight).toBeDefined();
|
||||
});
|
||||
it('should clone distribution target left and distribution target right lists on init', () => {
|
||||
expect(component.distributionTargetsLeft).toBeDefined();
|
||||
expect(component.distributionTargetsRight).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have two list with differents elements onInit', () => {
|
||||
let repeteadElemens = false;
|
||||
expect(component.distributionTargetsLeft.length).toBe(2);
|
||||
expect(component.distributionTargetsRight.length).toBe(1);
|
||||
component.distributionTargetsLeft.forEach(leftElement => {
|
||||
component.distributionTargetsRight.forEach(rightElement => {
|
||||
if (leftElement.workbasketId === rightElement.workbasketId) { repeteadElemens = true };
|
||||
})
|
||||
})
|
||||
expect(repeteadElemens).toBeFalsy();
|
||||
});
|
||||
it('should have two list with differents elements onInit', () => {
|
||||
let repeteadElemens = false;
|
||||
expect(component.distributionTargetsLeft.length).toBe(2);
|
||||
expect(component.distributionTargetsRight.length).toBe(1);
|
||||
component.distributionTargetsLeft.forEach(leftElement => {
|
||||
component.distributionTargetsRight.forEach(rightElement => {
|
||||
if (leftElement.workbasketId === rightElement.workbasketId) { repeteadElemens = true };
|
||||
})
|
||||
})
|
||||
expect(repeteadElemens).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should filter left list and keep selected elements as selected', () => {
|
||||
component.performFilter({ filterBy: new FilterModel({
|
||||
name: 'someName', owner: 'someOwner', description: 'someDescription', key: 'someKey'}), side: Side.LEFT });
|
||||
component.distributionTargetsLeft = new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))
|
||||
)
|
||||
expect(component.distributionTargetsLeft.length).toBe(1);
|
||||
expect(component.distributionTargetsLeft[0].workbasketId).toBe('id1');
|
||||
expect(component.distributionTargetsRight.length).toBe(1);
|
||||
expect(component.distributionTargetsRight[0].workbasketId).toBe('id2');
|
||||
});
|
||||
it('should filter left list and keep selected elements as selected', () => {
|
||||
component.performFilter({
|
||||
filterBy: new FilterModel({
|
||||
name: 'someName', owner: 'someOwner', description: 'someDescription', key: 'someKey'
|
||||
}), side: Side.LEFT
|
||||
});
|
||||
component.distributionTargetsLeft = new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))
|
||||
)
|
||||
expect(component.distributionTargetsLeft.length).toBe(1);
|
||||
expect(component.distributionTargetsLeft[0].workbasketId).toBe('id1');
|
||||
expect(component.distributionTargetsRight.length).toBe(1);
|
||||
expect(component.distributionTargetsRight[0].workbasketId).toBe('id2');
|
||||
});
|
||||
|
||||
it('should reset distribution target and distribution target selected on reset', () => {
|
||||
component.distributionTargetsLeft.push(
|
||||
new WorkbasketSummary('id4', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })));
|
||||
component.distributionTargetsRight.push(
|
||||
new WorkbasketSummary('id5', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })));
|
||||
it('should reset distribution target and distribution target selected on reset', () => {
|
||||
component.distributionTargetsLeft.push(
|
||||
new WorkbasketSummary('id4', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })));
|
||||
component.distributionTargetsRight.push(
|
||||
new WorkbasketSummary('id5', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })));
|
||||
|
||||
expect(component.distributionTargetsLeft.length).toBe(3);
|
||||
expect(component.distributionTargetsRight.length).toBe(2);
|
||||
expect(component.distributionTargetsLeft.length).toBe(3);
|
||||
expect(component.distributionTargetsRight.length).toBe(2);
|
||||
|
||||
component.onClear();
|
||||
fixture.detectChanges();
|
||||
expect(component.distributionTargetsLeft.length).toBe(2);
|
||||
expect(component.distributionTargetsRight.length).toBe(1)
|
||||
});
|
||||
component.onClear();
|
||||
fixture.detectChanges();
|
||||
expect(component.distributionTargetsLeft.length).toBe(2);
|
||||
expect(component.distributionTargetsRight.length).toBe(1)
|
||||
});
|
||||
|
||||
it('should save distribution targets selected and update Clone objects.', () => {
|
||||
expect(component.distributionTargetsSelected.length).toBe(1);
|
||||
expect(component.distributionTargetsSelectedClone.length).toBe(1);
|
||||
spyOn(workbasketService, 'updateWorkBasketsDistributionTargets').and.callFake(() => {
|
||||
return of(new WorkbasketDistributionTargetsResource(
|
||||
{
|
||||
'distributionTargets': new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
|
||||
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
|
||||
}, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||
})
|
||||
component.onSave();
|
||||
fixture.detectChanges();
|
||||
expect(component.distributionTargetsSelected.length).toBe(2);
|
||||
expect(component.distributionTargetsSelectedClone.length).toBe(2);
|
||||
expect(component.distributionTargetsLeft.length).toBe(1);
|
||||
it('should save distribution targets selected and update Clone objects.', () => {
|
||||
expect(component.distributionTargetsSelected.length).toBe(1);
|
||||
expect(component.distributionTargetsSelectedClone.length).toBe(1);
|
||||
spyOn(workbasketService, 'updateWorkBasketsDistributionTargets').and.callFake(() => {
|
||||
return of(new WorkbasketDistributionTargetsResource(
|
||||
new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
|
||||
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
|
||||
, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||
})
|
||||
component.onSave();
|
||||
fixture.detectChanges();
|
||||
expect(component.distributionTargetsSelected.length).toBe(2);
|
||||
expect(component.distributionTargetsSelectedClone.length).toBe(2);
|
||||
expect(component.distributionTargetsLeft.length).toBe(1);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -113,7 +113,7 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
|||
this.workbasketService.updateWorkBasketsDistributionTargets(
|
||||
this.distributionTargetsSelectedResource._links.self.href, this.getSeletedIds()).subscribe(response => {
|
||||
this.requestInProgressService.setRequestInProgress(false);
|
||||
this.distributionTargetsSelected = response._embedded ? response._embedded.distributionTargets : [];
|
||||
this.distributionTargetsSelected = response.distributionTargets;
|
||||
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
|
||||
this.distributionTargetsClone = Object.assign([], this.distributionTargetsLeft);
|
||||
this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS,
|
||||
|
@ -145,8 +145,8 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
|||
dualListFilter.filterBy.filterParams.owner, dualListFilter.filterBy.filterParams.type, undefined,
|
||||
dualListFilter.filterBy.filterParams.key, undefined, true).subscribe(resultList => {
|
||||
(dualListFilter.side === Side.RIGHT) ?
|
||||
this.distributionTargetsRight = (resultList._embedded ? resultList._embedded.workbaskets : []) :
|
||||
this.distributionTargetsLeft = (resultList._embedded ? resultList._embedded.workbaskets : []);
|
||||
this.distributionTargetsRight = (resultList.workbaskets) :
|
||||
this.distributionTargetsLeft = (resultList.workbaskets);
|
||||
this.onRequest(dualListFilter.side, true);
|
||||
});
|
||||
}
|
||||
|
@ -168,8 +168,7 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
|||
this.workbasket._links.distributionTargets.href).subscribe(
|
||||
(distributionTargetsSelectedResource: WorkbasketDistributionTargetsResource) => {
|
||||
this.distributionTargetsSelectedResource = distributionTargetsSelectedResource;
|
||||
this.distributionTargetsSelected = distributionTargetsSelectedResource._embedded ?
|
||||
distributionTargetsSelectedResource._embedded.distributionTargets : [];
|
||||
this.distributionTargetsSelected = distributionTargetsSelectedResource.distributionTargets;
|
||||
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
|
||||
TaskanaQueryParameters.page = 1;
|
||||
this.calculateNumberItemsList();
|
||||
|
@ -223,13 +222,13 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
|||
this.page = distributionTargetsAvailable.page;
|
||||
}
|
||||
if (side === this.side.LEFT) {
|
||||
this.distributionTargetsLeft.push(...distributionTargetsAvailable._embedded.workbaskets);
|
||||
this.distributionTargetsLeft.push(...distributionTargetsAvailable.workbaskets);
|
||||
} else if (side === this.side.RIGHT) {
|
||||
this.distributionTargetsRight = Object.assign([], distributionTargetsAvailable._embedded.workbaskets);
|
||||
this.distributionTargetsRight = Object.assign([], distributionTargetsAvailable.workbaskets);
|
||||
} else {
|
||||
this.distributionTargetsLeft.push(...distributionTargetsAvailable._embedded.workbaskets);
|
||||
this.distributionTargetsRight = Object.assign([], distributionTargetsAvailable._embedded.workbaskets);
|
||||
this.distributionTargetsClone = Object.assign([], distributionTargetsAvailable._embedded.workbaskets);
|
||||
this.distributionTargetsLeft.push(...distributionTargetsAvailable.workbaskets);
|
||||
this.distributionTargetsRight = Object.assign([], distributionTargetsAvailable.workbaskets);
|
||||
this.distributionTargetsClone = Object.assign([], distributionTargetsAvailable.workbaskets);
|
||||
}
|
||||
this.onRequest(undefined, true);
|
||||
});
|
||||
|
|
|
@ -34,76 +34,75 @@ import { InfiniteScrollModule } from 'ngx-infinite-scroll';
|
|||
import { ImportExportService } from 'app/administration/services/import-export/import-export.service';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {
|
||||
}
|
||||
|
||||
describe('WorkbasketDetailsComponent', () => {
|
||||
let component: WorkbasketDetailsComponent;
|
||||
let fixture: ComponentFixture<WorkbasketDetailsComponent>;
|
||||
let debugElement;
|
||||
let masterAndDetailService;
|
||||
let workbasketService;
|
||||
let router;
|
||||
const workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
new Links({ 'href': 'someurl' }, { 'href': 'someurl' }, { 'href': 'someurl' }));
|
||||
let component: WorkbasketDetailsComponent;
|
||||
let fixture: ComponentFixture<WorkbasketDetailsComponent>;
|
||||
let debugElement;
|
||||
let masterAndDetailService;
|
||||
let workbasketService;
|
||||
let router;
|
||||
const workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
new Links({ 'href': 'someurl' }, { 'href': 'someurl' }, { 'href': 'someurl' }));
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '*', component: DummyDetailComponent }
|
||||
];
|
||||
const routes: Routes = [
|
||||
{ path: '*', component: DummyDetailComponent }
|
||||
];
|
||||
|
||||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [RouterTestingModule.withRoutes(routes), FormsModule, AngularSvgIconModule, HttpClientModule, ReactiveFormsModule,
|
||||
InfiniteScrollModule],
|
||||
declarations: [WorkbasketDetailsComponent, WorkbasketInformationComponent,
|
||||
AccessItemsComponent,
|
||||
DistributionTargetsComponent, DualListComponent, DummyDetailComponent],
|
||||
providers: [WorkbasketService, MasterAndDetailService, GeneralModalService, RequestInProgressService,
|
||||
AlertService, SavingWorkbasketService, CustomFieldsService, ImportExportService]
|
||||
})
|
||||
};
|
||||
configureTests(configure).then(testBed => {
|
||||
fixture = TestBed.createComponent(WorkbasketDetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
router = TestBed.get(Router)
|
||||
fixture.detectChanges();
|
||||
masterAndDetailService = TestBed.get(MasterAndDetailService);
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
spyOn(masterAndDetailService, 'getShowDetail').and.callFake(() => { return of(true) })
|
||||
spyOn(workbasketService, 'getSelectedWorkBasket').and.callFake(() => { return of('id1') })
|
||||
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => {
|
||||
return of(new WorkbasketSummaryResource(
|
||||
{
|
||||
'workbaskets': new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '',
|
||||
false, new Links({ 'href': 'someurl' })))
|
||||
}, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||
})
|
||||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [RouterTestingModule.withRoutes(routes), FormsModule, AngularSvgIconModule, HttpClientModule, ReactiveFormsModule,
|
||||
InfiniteScrollModule],
|
||||
declarations: [WorkbasketDetailsComponent, WorkbasketInformationComponent,
|
||||
AccessItemsComponent,
|
||||
DistributionTargetsComponent, DualListComponent, DummyDetailComponent],
|
||||
providers: [WorkbasketService, MasterAndDetailService, GeneralModalService, RequestInProgressService,
|
||||
AlertService, SavingWorkbasketService, CustomFieldsService, ImportExportService]
|
||||
})
|
||||
};
|
||||
configureTests(configure).then(testBed => {
|
||||
fixture = TestBed.createComponent(WorkbasketDetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
router = TestBed.get(Router)
|
||||
fixture.detectChanges();
|
||||
masterAndDetailService = TestBed.get(MasterAndDetailService);
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
spyOn(masterAndDetailService, 'getShowDetail').and.callFake(() => { return of(true) })
|
||||
spyOn(workbasketService, 'getSelectedWorkBasket').and.callFake(() => { return of('id1') })
|
||||
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => {
|
||||
return of(new WorkbasketSummaryResource(
|
||||
new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '',
|
||||
false, new Links({ 'href': 'someurl' })))
|
||||
, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||
})
|
||||
|
||||
spyOn(workbasketService, 'getWorkBasket').and.callFake(() => { return of(workbasket) })
|
||||
spyOn(workbasketService, 'getWorkBasketAccessItems').and.callFake(() => {
|
||||
return of(new WorkbasketAccessItemsResource(
|
||||
{ 'accessItems': new Array<WorkbasketAccessItems>() }, new Links({ 'href': 'url' })))
|
||||
})
|
||||
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => {
|
||||
return of(new WorkbasketSummaryResource(
|
||||
{ 'workbaskets': new Array<WorkbasketSummary>() }, new LinksWorkbasketSummary({ 'href': 'url' })))
|
||||
})
|
||||
done();
|
||||
});
|
||||
});
|
||||
spyOn(workbasketService, 'getWorkBasket').and.callFake(() => { return of(workbasket) })
|
||||
spyOn(workbasketService, 'getWorkBasketAccessItems').and.callFake(() => {
|
||||
return of(new WorkbasketAccessItemsResource(
|
||||
new Array<WorkbasketAccessItems>(), new Links({ 'href': 'url' })))
|
||||
})
|
||||
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => {
|
||||
return of(new WorkbasketSummaryResource(
|
||||
new Array<WorkbasketSummary>(), new LinksWorkbasketSummary({ 'href': 'url' })))
|
||||
})
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
afterEach(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -25,150 +25,150 @@ import { Page } from 'app/models/page';
|
|||
import { ImportExportService } from 'app/administration/services/import-export/import-export.service';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
class DummyDetailComponent {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-pagination',
|
||||
template: 'dummydetail'
|
||||
selector: 'taskana-pagination',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
class PaginationComponent {
|
||||
@Input()
|
||||
page: Page;
|
||||
@Output()
|
||||
workbasketsResourceChange = new EventEmitter<any>();
|
||||
@Output() changePage = new EventEmitter<any>();
|
||||
@Input()
|
||||
page: Page;
|
||||
@Output()
|
||||
workbasketsResourceChange = new EventEmitter<any>();
|
||||
@Output() changePage = new EventEmitter<any>();
|
||||
}
|
||||
|
||||
const workbasketSummaryResource: WorkbasketSummaryResource = new WorkbasketSummaryResource({
|
||||
'workbaskets': new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('1', 'key1', 'NAME1', 'description 1', 'owner 1', '', '', 'PERSONAL', '', '', '', ''),
|
||||
new WorkbasketSummary('2', 'key2', 'NAME2', 'description 2', 'owner 2', '', '', 'GROUP', '', '', '', ''))
|
||||
}, new LinksWorkbasketSummary({ 'href': 'url' }));
|
||||
const workbasketSummaryResource: WorkbasketSummaryResource = new WorkbasketSummaryResource(
|
||||
new Array<WorkbasketSummary>(
|
||||
new WorkbasketSummary('1', 'key1', 'NAME1', 'description 1', 'owner 1', '', '', 'PERSONAL', '', '', '', ''),
|
||||
new WorkbasketSummary('2', 'key2', 'NAME2', 'description 2', 'owner 2', '', '', 'GROUP', '', '', '', ''))
|
||||
, new LinksWorkbasketSummary({ 'href': 'url' }));
|
||||
|
||||
|
||||
describe('WorkbasketListComponent', () => {
|
||||
let component: WorkbasketListComponent;
|
||||
let fixture: ComponentFixture<WorkbasketListComponent>;
|
||||
let debugElement: any = undefined;
|
||||
let workbasketService: WorkbasketService;
|
||||
let workbasketSummarySpy;
|
||||
let component: WorkbasketListComponent;
|
||||
let fixture: ComponentFixture<WorkbasketListComponent>;
|
||||
let debugElement: any = undefined;
|
||||
let workbasketService: WorkbasketService;
|
||||
let workbasketSummarySpy;
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' },
|
||||
{ path: 'workbaskets', component: DummyDetailComponent }
|
||||
];
|
||||
const routes: Routes = [
|
||||
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' },
|
||||
{ path: 'workbaskets', component: DummyDetailComponent }
|
||||
];
|
||||
|
||||
|
||||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
declarations: [
|
||||
WorkbasketListComponent,
|
||||
DummyDetailComponent,
|
||||
WorkbasketListToolbarComponent,
|
||||
ImportExportComponent
|
||||
],
|
||||
imports: [
|
||||
AngularSvgIconModule,
|
||||
HttpClientModule,
|
||||
RouterTestingModule.withRoutes(routes)
|
||||
],
|
||||
providers: [
|
||||
WorkbasketService,
|
||||
WorkbasketDefinitionService,
|
||||
ClassificationDefinitionService,
|
||||
OrientationService,
|
||||
ImportExportService
|
||||
]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then(testBed => {
|
||||
fixture = TestBed.createComponent(WorkbasketListComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
const orientationService = TestBed.get(OrientationService);
|
||||
workbasketSummarySpy = spyOn(workbasketService, 'getWorkBasketsSummary').and.returnValue(of(workbasketSummaryResource));
|
||||
spyOn(workbasketService, 'getSelectedWorkBasket').and.returnValue(of('2'));
|
||||
spyOn(orientationService, 'getOrientation').and.returnValue(of(undefined));
|
||||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
declarations: [
|
||||
WorkbasketListComponent,
|
||||
DummyDetailComponent,
|
||||
WorkbasketListToolbarComponent,
|
||||
ImportExportComponent
|
||||
],
|
||||
imports: [
|
||||
AngularSvgIconModule,
|
||||
HttpClientModule,
|
||||
RouterTestingModule.withRoutes(routes)
|
||||
],
|
||||
providers: [
|
||||
WorkbasketService,
|
||||
WorkbasketDefinitionService,
|
||||
ClassificationDefinitionService,
|
||||
OrientationService,
|
||||
ImportExportService
|
||||
]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then(testBed => {
|
||||
fixture = TestBed.createComponent(WorkbasketListComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
const orientationService = TestBed.get(OrientationService);
|
||||
workbasketSummarySpy = spyOn(workbasketService, 'getWorkBasketsSummary').and.returnValue(of(workbasketSummaryResource));
|
||||
spyOn(workbasketService, 'getSelectedWorkBasket').and.returnValue(of('2'));
|
||||
spyOn(orientationService, 'getOrientation').and.returnValue(of(undefined));
|
||||
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.detectChanges();
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should call workbasketService.getWorkbasketsSummary method on init', () => {
|
||||
component.ngOnInit();
|
||||
expect(workbasketService.getWorkBasketsSummary).toHaveBeenCalled();
|
||||
workbasketService.getWorkBasketsSummary().subscribe(value => {
|
||||
expect(value).toBe(workbasketSummaryResource);
|
||||
})
|
||||
});
|
||||
|
||||
it('should have wb-action-toolbar, wb-search-bar, wb-list-container, wb-pagination,' +
|
||||
' collapsedMenufilterWb and taskana-filter created in the html', () => {
|
||||
expect(debugElement.querySelector('#wb-action-toolbar')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-search-bar')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-pagination')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-list-container')).toBeDefined();
|
||||
expect(debugElement.querySelector('#collapsedMenufilterWb')).toBeDefined();
|
||||
expect(debugElement.querySelector('taskana-filter')).toBeDefined();
|
||||
expect(debugElement.querySelectorAll('#wb-list-container > li').length).toBe(3);
|
||||
afterEach(() => {
|
||||
fixture.detectChanges();
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
// it('should have two workbasketsummary rows created with the second one selected.', fakeAsync(() => {
|
||||
// tick(0);
|
||||
// fixture.detectChanges();
|
||||
// fixture.whenStable().then(() => {
|
||||
// expect(debugElement.querySelectorAll('#wb-list-container > li').length).toBe(3);
|
||||
// expect(debugElement.querySelectorAll('#wb-list-container > li')[1].getAttribute('class'))
|
||||
// .toBe('list-group-item ng-star-inserted');
|
||||
// expect(debugElement.querySelectorAll('#wb-list-container > li')[2].getAttribute('class'))
|
||||
// .toBe('list-group-item ng-star-inserted active');
|
||||
// })
|
||||
//
|
||||
// }));
|
||||
|
||||
it('should have two workbasketsummary rows created with two different icons: user and users', () => {
|
||||
expect(debugElement.querySelectorAll('#wb-list-container > li')[1]
|
||||
.querySelector('svg-icon').getAttribute('ng-reflect-src')).toBe('./assets/icons/user.svg');
|
||||
expect(debugElement.querySelectorAll('#wb-list-container > li')[2]
|
||||
.querySelector('svg-icon').getAttribute('ng-reflect-src')).toBe('./assets/icons/users.svg');
|
||||
});
|
||||
|
||||
it('should have rendered sort by: name, id, description, owner and type', () => {
|
||||
expect(debugElement.querySelector('#sort-by-name')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-key')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-description')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-owner')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-type')).toBeDefined();
|
||||
|
||||
});
|
||||
|
||||
it('should have performRequest with forced = true after performFilter is triggered', (() => {
|
||||
const filter = new FilterModel({
|
||||
name: 'someName', owner: 'someOwner', description: 'someDescription',
|
||||
key: 'someKey', type: 'PERSONAL'
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
component.performFilter(filter);
|
||||
|
||||
expect(workbasketSummarySpy.calls.all()[1].args).toEqual([true, 'key', 'asc',
|
||||
undefined, 'someName', 'someDescription', undefined, 'someOwner', 'PERSONAL', undefined, 'someKey', undefined]);
|
||||
it('should call workbasketService.getWorkbasketsSummary method on init', () => {
|
||||
component.ngOnInit();
|
||||
expect(workbasketService.getWorkBasketsSummary).toHaveBeenCalled();
|
||||
workbasketService.getWorkBasketsSummary().subscribe(value => {
|
||||
expect(value).toBe(workbasketSummaryResource);
|
||||
})
|
||||
});
|
||||
|
||||
}));
|
||||
it('should have wb-action-toolbar, wb-search-bar, wb-list-container, wb-pagination,' +
|
||||
' collapsedMenufilterWb and taskana-filter created in the html', () => {
|
||||
expect(debugElement.querySelector('#wb-action-toolbar')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-search-bar')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-pagination')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-list-container')).toBeDefined();
|
||||
expect(debugElement.querySelector('#collapsedMenufilterWb')).toBeDefined();
|
||||
expect(debugElement.querySelector('taskana-filter')).toBeDefined();
|
||||
expect(debugElement.querySelectorAll('#wb-list-container > li').length).toBe(3);
|
||||
});
|
||||
|
||||
// it('should have two workbasketsummary rows created with the second one selected.', fakeAsync(() => {
|
||||
// tick(0);
|
||||
// fixture.detectChanges();
|
||||
// fixture.whenStable().then(() => {
|
||||
// expect(debugElement.querySelectorAll('#wb-list-container > li').length).toBe(3);
|
||||
// expect(debugElement.querySelectorAll('#wb-list-container > li')[1].getAttribute('class'))
|
||||
// .toBe('list-group-item ng-star-inserted');
|
||||
// expect(debugElement.querySelectorAll('#wb-list-container > li')[2].getAttribute('class'))
|
||||
// .toBe('list-group-item ng-star-inserted active');
|
||||
// })
|
||||
//
|
||||
// }));
|
||||
|
||||
it('should have two workbasketsummary rows created with two different icons: user and users', () => {
|
||||
expect(debugElement.querySelectorAll('#wb-list-container > li')[1]
|
||||
.querySelector('svg-icon').getAttribute('ng-reflect-src')).toBe('./assets/icons/user.svg');
|
||||
expect(debugElement.querySelectorAll('#wb-list-container > li')[2]
|
||||
.querySelector('svg-icon').getAttribute('ng-reflect-src')).toBe('./assets/icons/users.svg');
|
||||
});
|
||||
|
||||
it('should have rendered sort by: name, id, description, owner and type', () => {
|
||||
expect(debugElement.querySelector('#sort-by-name')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-key')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-description')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-owner')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-type')).toBeDefined();
|
||||
|
||||
});
|
||||
|
||||
it('should have performRequest with forced = true after performFilter is triggered', (() => {
|
||||
const filter = new FilterModel({
|
||||
name: 'someName', owner: 'someOwner', description: 'someDescription',
|
||||
key: 'someKey', type: 'PERSONAL'
|
||||
});
|
||||
component.performFilter(filter);
|
||||
|
||||
expect(workbasketSummarySpy.calls.all()[1].args).toEqual([true, 'key', 'asc',
|
||||
undefined, 'someName', 'someDescription', undefined, 'someOwner', 'PERSONAL', undefined, 'someKey', undefined]);
|
||||
|
||||
}));
|
||||
|
||||
});
|
||||
|
|
|
@ -109,7 +109,7 @@ export class WorkbasketListComponent implements OnInit, OnDestroy {
|
|||
this.filterBy.filterParams.type, undefined, this.filterBy.filterParams.key, undefined)
|
||||
.subscribe(resultList => {
|
||||
this.workbasketsResource = resultList;
|
||||
this.workbaskets = resultList._embedded ? resultList._embedded.workbaskets : [];
|
||||
this.workbaskets = resultList.workbaskets;
|
||||
this.requestInProgress = false;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { AccessItemWorkbasket } from './access-item-workbasket';
|
|||
|
||||
export class AccessItemsWorkbasketResource {
|
||||
constructor(
|
||||
public _embedded: { 'accessItems': Array<AccessItemWorkbasket> } = { 'accessItems': [] },
|
||||
public accessItems: Array<AccessItemWorkbasket> = [],
|
||||
public _links: Links = undefined
|
||||
) { }
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@ import { Links } from './links';
|
|||
|
||||
export class ClassificationResource {
|
||||
constructor(
|
||||
public _embedded: {
|
||||
'classificationSummaryResourceList': Array<Classification>
|
||||
} = { 'classificationSummaryResourceList': [] },
|
||||
public classifications: Array<Classification> = [],
|
||||
public _links: Links = new Links(),
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { WorkbasketAccessItems } from './workbasket-access-items';
|
|||
|
||||
export class WorkbasketAccessItemsResource {
|
||||
constructor(
|
||||
public _embedded: { 'accessItems': Array<WorkbasketAccessItems> } = { 'accessItems': [] },
|
||||
public accessItems: Array<WorkbasketAccessItems> = [],
|
||||
public _links: Links = undefined
|
||||
) { }
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ import { WorkbasketSummary } from './workbasket-summary';
|
|||
import { Links } from './links';
|
||||
|
||||
export class WorkbasketDistributionTargetsResource {
|
||||
constructor(public _embedded: { 'distributionTargets': Array<WorkbasketSummary> } =
|
||||
{ 'distributionTargets': [] }, public _links: Links = null) {
|
||||
constructor(
|
||||
public distributionTargets: Array<WorkbasketSummary> = [],
|
||||
public _links: Links = null) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import {Links} from './links';
|
||||
import {Workbasket} from './workbasket';
|
||||
import { Links } from './links';
|
||||
import { Workbasket } from './workbasket';
|
||||
|
||||
export class WorkbasketResource {
|
||||
constructor(public _embedded: { 'workbaskets': Array<Workbasket> } = { 'workbaskets': [] },
|
||||
public _links: Links = undefined) {}
|
||||
constructor(
|
||||
public workbaskets: Array<Workbasket> = [],
|
||||
public _links: Links = undefined) { }
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@ import { LinksWorkbasketSummary } from './links-workbasket-summary';
|
|||
|
||||
export class WorkbasketSummaryResource {
|
||||
constructor(
|
||||
public _embedded: {
|
||||
'workbaskets': Array<WorkbasketSummary>
|
||||
} = { 'workbaskets': [] },
|
||||
public workbaskets: Array<WorkbasketSummary> = [],
|
||||
public _links: LinksWorkbasketSummary = new LinksWorkbasketSummary(),
|
||||
public page: Page = new Page()
|
||||
) {
|
||||
|
|
|
@ -115,10 +115,10 @@ export class ClassificationsService {
|
|||
classificationRef,
|
||||
classificationTypes,
|
||||
(classification: any, classificationType) => {
|
||||
if (!classification._embedded) {
|
||||
if (!classification.classifications) {
|
||||
return [];
|
||||
}
|
||||
return this.buildHierarchy(classification._embedded.classificationSummaryResourceList, classificationType);
|
||||
return this.buildHierarchy(classification.classifications, classificationType);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
import { throwError as observableThrowError, Observable, Subject } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
@ -18,175 +19,176 @@ import { QueryParametersModel } from 'app/models/query-parameters';
|
|||
@Injectable()
|
||||
export class WorkbasketService {
|
||||
|
||||
public workBasketSelected = new Subject<string>();
|
||||
public workBasketSaved = new Subject<number>();
|
||||
private workbasketSummaryRef: Observable<WorkbasketSummaryResource> = new Observable();
|
||||
public workBasketSelected = new Subject<string>();
|
||||
public workBasketSaved = new Subject<number>();
|
||||
private workbasketSummaryRef: Observable<WorkbasketSummaryResource> = new Observable();
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
private domainService: DomainService
|
||||
) { }
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
private domainService: DomainService
|
||||
) { }
|
||||
|
||||
// #region "REST calls"
|
||||
// GET
|
||||
getWorkBasketsSummary(forceRequest: boolean = false,
|
||||
sortBy: string = TaskanaQueryParameters.parameters.KEY,
|
||||
order: string = Direction.ASC,
|
||||
name: string = undefined,
|
||||
nameLike: string = undefined,
|
||||
descLike: string = undefined,
|
||||
owner: string = undefined,
|
||||
ownerLike: string = undefined,
|
||||
type: string = undefined,
|
||||
key: string = undefined,
|
||||
keyLike: string = undefined,
|
||||
requiredPermission: string = undefined,
|
||||
allPages: boolean = false) {
|
||||
// #region "REST calls"
|
||||
// GET
|
||||
getWorkBasketsSummary(forceRequest: boolean = false,
|
||||
sortBy: string = TaskanaQueryParameters.parameters.KEY,
|
||||
order: string = Direction.ASC,
|
||||
name: string = undefined,
|
||||
nameLike: string = undefined,
|
||||
descLike: string = undefined,
|
||||
owner: string = undefined,
|
||||
ownerLike: string = undefined,
|
||||
type: string = undefined,
|
||||
key: string = undefined,
|
||||
keyLike: string = undefined,
|
||||
requiredPermission: string = undefined,
|
||||
allPages: boolean = false) {
|
||||
|
||||
if (this.workbasketSummaryRef && !forceRequest) {
|
||||
return this.workbasketSummaryRef;
|
||||
}
|
||||
if (this.workbasketSummaryRef && !forceRequest) {
|
||||
return this.workbasketSummaryRef;
|
||||
}
|
||||
|
||||
|
||||
return this.domainService.getSelectedDomain().pipe(mergeMap(domain => {
|
||||
return this.workbasketSummaryRef = this.httpClient.get<WorkbasketSummaryResource>(
|
||||
`${environment.taskanaRestUrl}/v1/workbaskets/${TaskanaQueryParameters.getQueryParameters(this.workbasketParameters(sortBy, order, name,
|
||||
nameLike, descLike, owner, ownerLike, type, key, keyLike, requiredPermission, allPages, domain))}`)
|
||||
.pipe(tap((workbaskets => {
|
||||
return workbaskets;
|
||||
})))
|
||||
}), tap(() => {
|
||||
this.domainService.domainChangedComplete();
|
||||
}));
|
||||
return this.domainService.getSelectedDomain().pipe(mergeMap(domain => {
|
||||
return this.workbasketSummaryRef = this.httpClient.get<WorkbasketSummaryResource>(
|
||||
`${environment.taskanaRestUrl}/v1/workbaskets/${TaskanaQueryParameters
|
||||
.getQueryParameters(this.workbasketParameters(sortBy, order, name, nameLike, descLike, owner, ownerLike,
|
||||
type, key, keyLike, requiredPermission, allPages, domain))}`)
|
||||
.pipe(tap((workbaskets => {
|
||||
return workbaskets;
|
||||
})))
|
||||
}), tap(() => {
|
||||
this.domainService.domainChangedComplete();
|
||||
}));
|
||||
|
||||
}
|
||||
// GET
|
||||
getWorkBasket(id: string): Observable<Workbasket> {
|
||||
return this.httpClient.get<Workbasket>(`${environment.taskanaRestUrl}/v1/workbaskets/${id}`);
|
||||
}
|
||||
}
|
||||
// GET
|
||||
getWorkBasket(id: string): Observable<Workbasket> {
|
||||
return this.httpClient.get<Workbasket>(`${environment.taskanaRestUrl}/v1/workbaskets/${id}`);
|
||||
}
|
||||
|
||||
// GET
|
||||
getAllWorkBaskets(): Observable<WorkbasketResource> {
|
||||
return this.httpClient.get<WorkbasketResource>(`${environment.taskanaRestUrl}/v1/workbaskets?required-permission=OPEN`);
|
||||
}
|
||||
// GET
|
||||
getAllWorkBaskets(): Observable<WorkbasketResource> {
|
||||
return this.httpClient.get<WorkbasketResource>(`${environment.taskanaRestUrl}/v1/workbaskets?required-permission=OPEN`);
|
||||
}
|
||||
|
||||
// POST
|
||||
createWorkbasket(workbasket: Workbasket): Observable<Workbasket> {
|
||||
return this.httpClient
|
||||
.post<Workbasket>(`${environment.taskanaRestUrl}/v1/workbaskets`, workbasket);
|
||||
// POST
|
||||
createWorkbasket(workbasket: Workbasket): Observable<Workbasket> {
|
||||
return this.httpClient
|
||||
.post<Workbasket>(`${environment.taskanaRestUrl}/v1/workbaskets`, workbasket);
|
||||
|
||||
}
|
||||
// PUT
|
||||
updateWorkbasket(url: string, workbasket: Workbasket): Observable<Workbasket> {
|
||||
return this.httpClient
|
||||
.put<Workbasket>(url, workbasket).pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
}
|
||||
// delete
|
||||
markWorkbasketForDeletion(url: string): Observable<any> {
|
||||
return this.httpClient
|
||||
.delete<any>(url);
|
||||
}
|
||||
// GET
|
||||
getWorkBasketAccessItems(url: string): Observable<WorkbasketAccessItemsResource> {
|
||||
return this.httpClient.get<WorkbasketAccessItemsResource>(url);
|
||||
}
|
||||
// POST
|
||||
createWorkBasketAccessItem(url: string, workbasketAccessItem: WorkbasketAccessItems): Observable<WorkbasketAccessItems> {
|
||||
return this.httpClient.post<WorkbasketAccessItems>(url, workbasketAccessItem);
|
||||
}
|
||||
// PUT
|
||||
updateWorkBasketAccessItem(url: string, workbasketAccessItem: Array<WorkbasketAccessItems>): Observable<string> {
|
||||
return this.httpClient.put<string>(url,
|
||||
workbasketAccessItem);
|
||||
}
|
||||
// GET
|
||||
getWorkBasketsDistributionTargets(url: string): Observable<WorkbasketDistributionTargetsResource> {
|
||||
return this.httpClient.get<WorkbasketDistributionTargetsResource>(url);
|
||||
}
|
||||
}
|
||||
// PUT
|
||||
updateWorkbasket(url: string, workbasket: Workbasket): Observable<Workbasket> {
|
||||
return this.httpClient
|
||||
.put<Workbasket>(url, workbasket).pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
}
|
||||
// delete
|
||||
markWorkbasketForDeletion(url: string): Observable<any> {
|
||||
return this.httpClient
|
||||
.delete<any>(url);
|
||||
}
|
||||
// GET
|
||||
getWorkBasketAccessItems(url: string): Observable<WorkbasketAccessItemsResource> {
|
||||
return this.httpClient.get<WorkbasketAccessItemsResource>(url);
|
||||
}
|
||||
// POST
|
||||
createWorkBasketAccessItem(url: string, workbasketAccessItem: WorkbasketAccessItems): Observable<WorkbasketAccessItems> {
|
||||
return this.httpClient.post<WorkbasketAccessItems>(url, workbasketAccessItem);
|
||||
}
|
||||
// PUT
|
||||
updateWorkBasketAccessItem(url: string, workbasketAccessItem: Array<WorkbasketAccessItems>): Observable<string> {
|
||||
return this.httpClient.put<string>(url,
|
||||
workbasketAccessItem);
|
||||
}
|
||||
// GET
|
||||
getWorkBasketsDistributionTargets(url: string): Observable<WorkbasketDistributionTargetsResource> {
|
||||
return this.httpClient.get<WorkbasketDistributionTargetsResource>(url);
|
||||
}
|
||||
|
||||
// PUT
|
||||
updateWorkBasketsDistributionTargets(url: string, distributionTargetsIds: Array<string>):
|
||||
Observable<WorkbasketDistributionTargetsResource> {
|
||||
return this.httpClient.put<WorkbasketDistributionTargetsResource>(url, distributionTargetsIds);
|
||||
}
|
||||
// DELETE
|
||||
removeDistributionTarget(url: string) {
|
||||
return this.httpClient.delete<string>(url);
|
||||
}
|
||||
// PUT
|
||||
updateWorkBasketsDistributionTargets(url: string, distributionTargetsIds: Array<string>):
|
||||
Observable<WorkbasketDistributionTargetsResource> {
|
||||
return this.httpClient.put<WorkbasketDistributionTargetsResource>(url, distributionTargetsIds);
|
||||
}
|
||||
// DELETE
|
||||
removeDistributionTarget(url: string) {
|
||||
return this.httpClient.delete<string>(url);
|
||||
}
|
||||
|
||||
|
||||
// #endregion
|
||||
// #region "Service extras"
|
||||
selectWorkBasket(id: string) {
|
||||
this.workBasketSelected.next(id);
|
||||
}
|
||||
// #endregion
|
||||
// #region "Service extras"
|
||||
selectWorkBasket(id: string) {
|
||||
this.workBasketSelected.next(id);
|
||||
}
|
||||
|
||||
getSelectedWorkBasket(): Observable<string> {
|
||||
return this.workBasketSelected.asObservable();
|
||||
}
|
||||
getSelectedWorkBasket(): Observable<string> {
|
||||
return this.workBasketSelected.asObservable();
|
||||
}
|
||||
|
||||
triggerWorkBasketSaved() {
|
||||
this.workBasketSaved.next(Date.now());
|
||||
}
|
||||
triggerWorkBasketSaved() {
|
||||
this.workBasketSaved.next(Date.now());
|
||||
}
|
||||
|
||||
workbasketSavedTriggered(): Observable<number> {
|
||||
return this.workBasketSaved.asObservable();
|
||||
}
|
||||
workbasketSavedTriggered(): Observable<number> {
|
||||
return this.workBasketSaved.asObservable();
|
||||
}
|
||||
|
||||
// #endregion
|
||||
// #endregion
|
||||
|
||||
// #region private
|
||||
// #region private
|
||||
|
||||
private handleError(error: Response | any) {
|
||||
let errMsg: string;
|
||||
if (error instanceof Response) {
|
||||
const body = error.json() || '';
|
||||
const err = JSON.stringify(body);
|
||||
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
|
||||
} else {
|
||||
errMsg = error.message ? error.message : error.toString();
|
||||
}
|
||||
console.error(errMsg);
|
||||
return observableThrowError(errMsg);
|
||||
}
|
||||
private handleError(error: Response | any) {
|
||||
let errMsg: string;
|
||||
if (error instanceof Response) {
|
||||
const body = error.json() || '';
|
||||
const err = JSON.stringify(body);
|
||||
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
|
||||
} else {
|
||||
errMsg = error.message ? error.message : error.toString();
|
||||
}
|
||||
console.error(errMsg);
|
||||
return observableThrowError(errMsg);
|
||||
}
|
||||
|
||||
|
||||
private workbasketParameters(
|
||||
sortBy: string = TaskanaQueryParameters.parameters.KEY,
|
||||
order: string = Direction.ASC,
|
||||
name: string = undefined,
|
||||
nameLike: string = undefined,
|
||||
descLike: string = undefined,
|
||||
owner: string = undefined,
|
||||
ownerLike: string = undefined,
|
||||
type: string = undefined,
|
||||
key: string = undefined,
|
||||
keyLike: string = undefined,
|
||||
requiredPermission: string = undefined,
|
||||
allPages: boolean = false,
|
||||
domain: string = ''): QueryParametersModel {
|
||||
private workbasketParameters(
|
||||
sortBy: string = TaskanaQueryParameters.parameters.KEY,
|
||||
order: string = Direction.ASC,
|
||||
name: string = undefined,
|
||||
nameLike: string = undefined,
|
||||
descLike: string = undefined,
|
||||
owner: string = undefined,
|
||||
ownerLike: string = undefined,
|
||||
type: string = undefined,
|
||||
key: string = undefined,
|
||||
keyLike: string = undefined,
|
||||
requiredPermission: string = undefined,
|
||||
allPages: boolean = false,
|
||||
domain: string = ''): QueryParametersModel {
|
||||
|
||||
const parameters = new QueryParametersModel();
|
||||
parameters.SORTBY = sortBy;
|
||||
parameters.SORTDIRECTION = order;
|
||||
parameters.NAME = name;
|
||||
parameters.NAMELIKE = nameLike;
|
||||
parameters.DESCLIKE = descLike;
|
||||
parameters.OWNER = owner;
|
||||
parameters.OWNERLIKE = ownerLike;
|
||||
parameters.TYPE = type;
|
||||
parameters.KEY = key;
|
||||
parameters.KEYLIKE = keyLike;
|
||||
parameters.REQUIREDPERMISSION = requiredPermission;
|
||||
parameters.DOMAIN = domain;
|
||||
if (allPages) {
|
||||
TaskanaQueryParameters.page = undefined;
|
||||
TaskanaQueryParameters.pageSize = undefined;
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
const parameters = new QueryParametersModel();
|
||||
parameters.SORTBY = sortBy;
|
||||
parameters.SORTDIRECTION = order;
|
||||
parameters.NAME = name;
|
||||
parameters.NAMELIKE = nameLike;
|
||||
parameters.DESCLIKE = descLike;
|
||||
parameters.OWNER = owner;
|
||||
parameters.OWNERLIKE = ownerLike;
|
||||
parameters.TYPE = type;
|
||||
parameters.KEY = key;
|
||||
parameters.KEYLIKE = keyLike;
|
||||
parameters.REQUIREDPERMISSION = requiredPermission;
|
||||
parameters.DOMAIN = domain;
|
||||
if (allPages) {
|
||||
TaskanaQueryParameters.page = undefined;
|
||||
TaskanaQueryParameters.pageSize = undefined;
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
// #endregion
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import {Task} from './task';
|
|||
import { Page } from 'app/models/page';
|
||||
|
||||
export class TaskResource {
|
||||
constructor(public _embedded: { 'tasks': Array<Task> } = { 'tasks': [] },
|
||||
constructor(public tasks: Array<Task>,
|
||||
public _links: Links = undefined,
|
||||
public page: Page = new Page()) {}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ export class TaskComponent implements OnInit, OnDestroy {
|
|||
this.requestInProgress = true;
|
||||
this.workbasketService.getAllWorkBaskets().subscribe(workbaskets => {
|
||||
this.requestInProgress = false;
|
||||
this.workbaskets = workbaskets._embedded ? workbaskets._embedded.workbaskets : [];
|
||||
this.workbaskets = workbaskets.workbaskets;
|
||||
|
||||
let index = -1;
|
||||
for (let i = 0; i < this.workbaskets.length; i++) {
|
||||
|
|
|
@ -18,59 +18,58 @@ import { Classification } from 'app/models/classification';
|
|||
import { Links } from 'app/models/links';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {
|
||||
}
|
||||
|
||||
// TODO: test pending to test. Failing random
|
||||
xdescribe('GeneralComponent', () => {
|
||||
let component: TaskdetailsGeneralFieldsComponent;
|
||||
let fixture: ComponentFixture<TaskdetailsGeneralFieldsComponent>;
|
||||
let classificationsService;
|
||||
let component: TaskdetailsGeneralFieldsComponent;
|
||||
let fixture: ComponentFixture<TaskdetailsGeneralFieldsComponent>;
|
||||
let classificationsService;
|
||||
|
||||
const routes: Routes = [
|
||||
{path: '*', component: DummyDetailComponent}
|
||||
];
|
||||
const routes: Routes = [
|
||||
{ path: '*', component: DummyDetailComponent }
|
||||
];
|
||||
|
||||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
||||
declarations: [TaskdetailsGeneralFieldsComponent, DummyDetailComponent],
|
||||
providers: [HttpClient, ClassificationCategoriesService, CustomFieldsService,
|
||||
DomainService, RequestInProgressService, SelectedRouteService, ClassificationsService]
|
||||
})
|
||||
};
|
||||
configureTests(configure).then(testBed => {
|
||||
classificationsService = TestBed.get(ClassificationsService);
|
||||
spyOn(classificationsService, 'getClassificationsByDomain').and.returnValue(new ClassificationResource(
|
||||
{
|
||||
'classificationSummaryResourceList': new Array<Classification>(
|
||||
new Classification('id1', '1', 'category', 'type', 'domain_a', 'classification1', 'parentId',
|
||||
1, 'service', new Links({ 'href': 'someurl' })),
|
||||
new Classification('id2', '2', 'category', 'type', 'domain_a', 'classification2', 'parentId2',
|
||||
1, 'service', new Links({ 'href': 'someurl' })))
|
||||
}, new Links({ 'href': 'someurl' })
|
||||
));
|
||||
done();
|
||||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
||||
declarations: [TaskdetailsGeneralFieldsComponent, DummyDetailComponent],
|
||||
providers: [HttpClient, ClassificationCategoriesService, CustomFieldsService,
|
||||
DomainService, RequestInProgressService, SelectedRouteService, ClassificationsService]
|
||||
})
|
||||
};
|
||||
configureTests(configure).then(testBed => {
|
||||
classificationsService = TestBed.get(ClassificationsService);
|
||||
spyOn(classificationsService, 'getClassificationsByDomain').and.returnValue(new ClassificationResource(
|
||||
new Array<Classification>(
|
||||
new Classification('id1', '1', 'category', 'type', 'domain_a', 'classification1', 'parentId',
|
||||
1, 'service', new Links({ 'href': 'someurl' })),
|
||||
new Classification('id2', '2', 'category', 'type', 'domain_a', 'classification2', 'parentId2',
|
||||
1, 'service', new Links({ 'href': 'someurl' })))
|
||||
, new Links({ 'href': 'someurl' })
|
||||
));
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TaskdetailsGeneralFieldsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TaskdetailsGeneralFieldsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should call to getClassificationsByDomain', done => {
|
||||
component.ngOnInit();
|
||||
expect(classificationsService.getClassificationsByDomain).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
it('should call to getClassificationsByDomain', done => {
|
||||
component.ngOnInit();
|
||||
expect(classificationsService.getClassificationsByDomain).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,82 +8,82 @@ import { NgForm } from '@angular/forms';
|
|||
import { DomainService } from 'app/services/domain/domain.service';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-task-details-general-fields',
|
||||
templateUrl: './general-fields.component.html',
|
||||
styleUrls: ['./general-fields.component.scss']
|
||||
selector: 'taskana-task-details-general-fields',
|
||||
templateUrl: './general-fields.component.html',
|
||||
styleUrls: ['./general-fields.component.scss']
|
||||
})
|
||||
export class TaskdetailsGeneralFieldsComponent implements OnInit, OnChanges {
|
||||
|
||||
@Input()
|
||||
task: Task;
|
||||
@Output() taskChange: EventEmitter<Task> = new EventEmitter<Task>();
|
||||
@Input()
|
||||
task: Task;
|
||||
@Output() taskChange: EventEmitter<Task> = new EventEmitter<Task>();
|
||||
|
||||
@Input()
|
||||
saveToggleTriggered: boolean;
|
||||
@Output() formValid: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||
@Input()
|
||||
saveToggleTriggered: boolean;
|
||||
@Output() formValid: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||
|
||||
@ViewChild('TaskForm')
|
||||
taskForm: NgForm;
|
||||
@ViewChild('TaskForm')
|
||||
taskForm: NgForm;
|
||||
|
||||
toogleValidationMap = new Map<string, boolean>();
|
||||
requestInProgress = false;
|
||||
classifications: Classification[] = undefined;
|
||||
toogleValidationMap = new Map<string, boolean>();
|
||||
requestInProgress = false;
|
||||
classifications: Classification[] = undefined;
|
||||
|
||||
ownerField = this.customFieldsService.getCustomField(
|
||||
'Owner',
|
||||
'tasks.information.owner'
|
||||
);
|
||||
ownerField = this.customFieldsService.getCustomField(
|
||||
'Owner',
|
||||
'tasks.information.owner'
|
||||
);
|
||||
|
||||
constructor(
|
||||
private classificationService: ClassificationsService,
|
||||
private customFieldsService: CustomFieldsService,
|
||||
private formsValidatorService: FormsValidatorService,
|
||||
private domainService: DomainService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.getClassificationByDomain();
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes.saveToggleTriggered && changes.saveToggleTriggered.currentValue !== changes.saveToggleTriggered.previousValue) {
|
||||
this.validate();
|
||||
constructor(
|
||||
private classificationService: ClassificationsService,
|
||||
private customFieldsService: CustomFieldsService,
|
||||
private formsValidatorService: FormsValidatorService,
|
||||
private domainService: DomainService) {
|
||||
}
|
||||
}
|
||||
|
||||
selectClassification(classification: Classification) {
|
||||
this.task.classificationSummaryResource = classification;
|
||||
}
|
||||
|
||||
isFieldValid(field: string): boolean {
|
||||
return this.formsValidatorService.isFieldValid(this.taskForm, field);
|
||||
}
|
||||
|
||||
updateDate($event) {
|
||||
if (new Date(this.task.due).toISOString() !== $event) {
|
||||
this.task.due = $event;
|
||||
ngOnInit() {
|
||||
this.getClassificationByDomain();
|
||||
}
|
||||
}
|
||||
|
||||
private validate() {
|
||||
this.formsValidatorService.formSubmitAttempt = true;
|
||||
this.formsValidatorService
|
||||
.validateFormInformation(this.taskForm, this.toogleValidationMap)
|
||||
.then(value => {
|
||||
if (value) {
|
||||
this.formValid.emit(true);
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes.saveToggleTriggered && changes.saveToggleTriggered.currentValue !== changes.saveToggleTriggered.previousValue) {
|
||||
this.validate();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private changedClassification(itemSelected: any) {
|
||||
this.task.classificationSummaryResource = itemSelected;
|
||||
}
|
||||
selectClassification(classification: Classification) {
|
||||
this.task.classificationSummaryResource = classification;
|
||||
}
|
||||
|
||||
private async getClassificationByDomain() {
|
||||
this.requestInProgress = true;
|
||||
this.classifications = (await this.classificationService.getClassificationsByDomain(this.domainService.getSelectedDomainValue()))
|
||||
._embedded.classificationSummaryResourceList;
|
||||
this.requestInProgress = false;
|
||||
}
|
||||
isFieldValid(field: string): boolean {
|
||||
return this.formsValidatorService.isFieldValid(this.taskForm, field);
|
||||
}
|
||||
|
||||
updateDate($event) {
|
||||
if (new Date(this.task.due).toISOString() !== $event) {
|
||||
this.task.due = $event;
|
||||
}
|
||||
}
|
||||
|
||||
private validate() {
|
||||
this.formsValidatorService.formSubmitAttempt = true;
|
||||
this.formsValidatorService
|
||||
.validateFormInformation(this.taskForm, this.toogleValidationMap)
|
||||
.then(value => {
|
||||
if (value) {
|
||||
this.formValid.emit(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private changedClassification(itemSelected: any) {
|
||||
this.task.classificationSummaryResource = itemSelected;
|
||||
}
|
||||
|
||||
private async getClassificationByDomain() {
|
||||
this.requestInProgress = true;
|
||||
this.classifications = (await this.classificationService.getClassificationsByDomain(this.domainService.getSelectedDomainValue()))
|
||||
.classifications;
|
||||
this.requestInProgress = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ export class TaskListToolbarComponent implements OnInit {
|
|||
|
||||
ngOnInit() {
|
||||
this.workbasketService.getAllWorkBaskets().subscribe(workbaskets => {
|
||||
this.workbaskets = workbaskets._embedded ? workbaskets._embedded.workbaskets : [];
|
||||
this.workbaskets = workbaskets.workbaskets;
|
||||
this.workbaskets.forEach(workbasket => {
|
||||
this.workbasketNames.push(workbasket.name);
|
||||
});
|
||||
|
|
|
@ -142,8 +142,8 @@ export class TaskMasterComponent implements OnInit, OnDestroy {
|
|||
this.objectReference ? this.objectReference.value : undefined)
|
||||
.subscribe(tasks => {
|
||||
this.requestInProgress = false;
|
||||
if (tasks._embedded) {
|
||||
this.tasks = tasks._embedded.tasks;
|
||||
if (tasks.tasks) {
|
||||
this.tasks = tasks.tasks;
|
||||
} else {
|
||||
this.tasks = [];
|
||||
this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'The selected Workbasket is empty!'));
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
|
||||
export const environment = {
|
||||
production: false,
|
||||
taskanaRestUrl: 'http://localhost:8080',
|
||||
taskanaRestUrl: 'http://localhost:8080/api',
|
||||
taskanaLogoutUrl: 'http://localhost:8080/logout'
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue