TSK-881: Refactored REST-Api

This commit is contained in:
Dennis Lehmann 2019-09-17 11:27:59 +02:00 committed by Holger Hagen
parent 1d41e99f9d
commit 352d0d67cd
67 changed files with 1425 additions and 1237 deletions

View File

@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.time.Instant; import java.time.Instant;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -49,7 +50,7 @@ public class CompleteTaskAccTest extends AbstractAccTest {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
assertEquals(TaskState.CLAIMED, assertEquals(TaskState.CLAIMED,
taskService.getTask("TKI:000000000000000000000000000000000001").getState()); taskService.getTask("TKI:000000000000000000000000000000000001").getState());
Task completedTask = taskService.completeTask("TKI:000000000000000000000000000000000001"); Task completedTask = taskService.completeTask("TKI:000000000000000000000000000000000001");
assertNotNull(completedTask); assertNotNull(completedTask);
@ -209,8 +210,8 @@ public class CompleteTaskAccTest extends AbstractAccTest {
assertNotNull(createdTask); assertNotNull(createdTask);
assertEquals(createdTask.getOwner(), "other_user"); assertEquals(createdTask.getOwner(), "other_user");
waitAMillisecond();
Instant beforeForceClaim = Instant.now(); Instant beforeForceClaim = Instant.now();
waitAMillisecond();
Task taskAfterClaim = taskService.forceClaim(createdTask.getId()); Task taskAfterClaim = taskService.forceClaim(createdTask.getId());
assertEquals(CurrentUserContext.getUserid(), taskAfterClaim.getOwner()); assertEquals(CurrentUserContext.getUserid(), taskAfterClaim.getOwner());

View File

@ -33,7 +33,7 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/** /**
* Generate Rest Docu for AbstractPagingController. * Generate Rest Docu for AbstractPagingController.
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@ -77,7 +77,7 @@ public class AbstractPagingControllerRestDocumentation {
pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page"); pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page");
pagingFieldDescriptors = new FieldDescriptor[] { pagingFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.classificationSummaryResourceList").ignored(), subsectionWithPath("classifications").ignored(),
fieldWithPath("_links").ignored(), fieldWithPath("_links").ignored(),
fieldWithPath("_links.self").ignored(), fieldWithPath("_links.self").ignored(),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
@ -96,7 +96,7 @@ public class AbstractPagingControllerRestDocumentation {
@Test @Test
public void commonSummaryResourceFieldsDocTest() throws Exception { public void commonSummaryResourceFieldsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("CommonSummaryResourceFields", .andDo(MockMvcRestDocumentation.document("CommonSummaryResourceFields",

View File

@ -38,9 +38,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/** /**
* Generate REST Dokumentation for ClassificationController. * Generate REST Dokumentation for ClassificationController.
*
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@ -113,7 +113,7 @@ public class ClassificationControllerRestDocumentation {
allClassificationsFieldDescriptors = new FieldDescriptor[] { allClassificationsFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.classificationSummaryResourceList") subsectionWithPath("classifications")
.description("An Array of <<classification-subset, Classification-Subsets>>"), .description("An Array of <<classification-subset, Classification-Subsets>>"),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored() fieldWithPath("page").ignored()
@ -243,7 +243,7 @@ public class ClassificationControllerRestDocumentation {
@Test @Test
public void getAllClassificationsDocTest() throws Exception { public void getAllClassificationsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -254,7 +254,7 @@ public class ClassificationControllerRestDocumentation {
@Test @Test
public void getSpecificClassificationDocTest() throws Exception { public void getSpecificClassificationDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetSpecificClassificationDocTest", .andDo(MockMvcRestDocumentation.document("GetSpecificClassificationDocTest",
@ -264,7 +264,7 @@ public class ClassificationControllerRestDocumentation {
@Test @Test
public void classificationSubsetDocTest() throws Exception { public void classificationSubsetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("ClassificationSubset", .andDo(MockMvcRestDocumentation.document("ClassificationSubset",
@ -274,7 +274,7 @@ public class ClassificationControllerRestDocumentation {
@Test @Test
public void createAndDeleteClassificationDocTest() throws Exception { public void createAndDeleteClassificationDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders 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") .contentType("application/hal+json")
.content("{\"key\":\"Key0815casdgdgh\", \"domain\":\"DOMAIN_B\"}") .content("{\"key\":\"Key0815casdgdgh\", \"domain\":\"DOMAIN_B\"}")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
@ -288,7 +288,7 @@ public class ClassificationControllerRestDocumentation {
String newId = content.substring(content.indexOf("CLI:"), content.indexOf("CLI:") + 40); String newId = content.substring(content.indexOf("CLI:"), content.indexOf("CLI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders 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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteClassificationDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteClassificationDocTest"));
@ -296,7 +296,8 @@ public class ClassificationControllerRestDocumentation {
@Test @Test
public void updateClassificationDocTest() throws Exception { 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -315,7 +316,7 @@ public class ClassificationControllerRestDocumentation {
String modifiedTask = new String(originalTask.toString()); String modifiedTask = new String(originalTask.toString());
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json") .contentType("application/json")
.content(modifiedTask)) .content(modifiedTask))

View File

@ -74,7 +74,7 @@ public class ClassificationDefinitionControllerRestDocumentation {
@Test @Test
public void exportAllClassificationDefinitions() throws Exception { public void exportAllClassificationDefinitions() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -86,13 +86,12 @@ public class ClassificationDefinitionControllerRestDocumentation {
public void importClassificationDefinitions() throws Exception { public void importClassificationDefinitions() throws Exception {
String definitionString = "[{\"key\":\"Key0815\", \"domain\":\"DOMAIN_B\"}]"; 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", .file("file",
definitionString.getBytes()) definitionString.getBytes())
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(document("ImportClassificationDefinitions", requestParts( .andDo(document("ImportClassificationDefinitions", requestParts(
partWithName("file").description("The file to upload")) partWithName("file").description("The file to upload"))));
));
} }
} }

View File

@ -106,7 +106,7 @@ public class CommonRestDocumentation {
@Test @Test
public void commonFieldsDocTest() throws Exception { public void commonFieldsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("CommonFields", .andDo(MockMvcRestDocumentation.document("CommonFields",

View File

@ -84,7 +84,7 @@ public class MonitorControllerRestDocumentation {
@Test @Test
public void getTaskStatusReport() throws Exception { public void getTaskStatusReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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=")) .header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest", .andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest",
@ -95,7 +95,7 @@ public class MonitorControllerRestDocumentation {
public void tasksWorkbasketReport() throws Exception { public void tasksWorkbasketReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port .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") .accept("application/hal+json")
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) .header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -106,7 +106,7 @@ public class MonitorControllerRestDocumentation {
@Test @Test
public void tasksClassificationReport() throws Exception { public void tasksClassificationReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/hal+json")
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) .header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -117,7 +117,7 @@ public class MonitorControllerRestDocumentation {
@Test @Test
public void getTimestampReport() throws Exception { public void getTimestampReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/hal+json")
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) .header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -136,7 +136,7 @@ public class TaskControllerRestDocumentation {
allTasksFieldDescriptors = new FieldDescriptor[] { 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").ignored(),
fieldWithPath("_links.self").ignored(), fieldWithPath("_links.self").ignored(),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
@ -333,7 +333,7 @@ public class TaskControllerRestDocumentation {
@Test @Test
public void getAllTasksDocTest() throws Exception { public void getAllTasksDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -344,7 +344,7 @@ public class TaskControllerRestDocumentation {
@Test @Test
public void getSpecificTaskDocTest() throws Exception { public void getSpecificTaskDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -355,7 +355,7 @@ public class TaskControllerRestDocumentation {
@Test @Test
public void taskSubSetDocTest() throws Exception { public void taskSubSetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -365,7 +365,7 @@ public class TaskControllerRestDocumentation {
@Test @Test
public void updateTaskDocTest() throws Exception { 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -383,7 +383,7 @@ public class TaskControllerRestDocumentation {
String originalTask = content.toString(); String originalTask = content.toString();
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json") .contentType("application/json")
.content(originalTask)) .content(originalTask))
@ -397,7 +397,7 @@ public class TaskControllerRestDocumentation {
public void createAndDeleteTaskDocTest() throws Exception { public void createAndDeleteTaskDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders 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") .contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
@ -413,7 +413,7 @@ public class TaskControllerRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders 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 .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
@ -423,7 +423,7 @@ public class TaskControllerRestDocumentation {
public void claimTaskDocTest() throws Exception { public void claimTaskDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders 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") .contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
@ -437,7 +437,7 @@ public class TaskControllerRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content("{}")) .content("{}"))
@ -446,7 +446,7 @@ public class TaskControllerRestDocumentation {
responseFields(taskFieldDescriptors))); responseFields(taskFieldDescriptors)));
this.mockMvc.perform(RestDocumentationRequestBuilders 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 .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
@ -455,7 +455,7 @@ public class TaskControllerRestDocumentation {
@Test @Test
public void completeTaskDocTest() throws Exception { public void completeTaskDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders 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") .contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
@ -469,7 +469,7 @@ public class TaskControllerRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content("{}")) .content("{}"))
@ -478,7 +478,7 @@ public class TaskControllerRestDocumentation {
responseFields(taskFieldDescriptors))); responseFields(taskFieldDescriptors)));
this.mockMvc.perform(RestDocumentationRequestBuilders 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 .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
@ -487,7 +487,7 @@ public class TaskControllerRestDocumentation {
@Test @Test
public void transferTaskDocTest() throws Exception { public void transferTaskDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders 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") .contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
@ -502,7 +502,7 @@ public class TaskControllerRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders 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") + "/transfer/WBI:100000000000000000000000000000000001")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -510,7 +510,7 @@ public class TaskControllerRestDocumentation {
responseFields(taskFieldDescriptors))); responseFields(taskFieldDescriptors)));
this.mockMvc.perform(RestDocumentationRequestBuilders 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 .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent()); .andExpect(MockMvcResultMatchers.status().isNoContent());
} }

View File

@ -89,7 +89,7 @@ public class TaskanaEngineControllerRestDocumentation {
@Test @Test
public void getAllDomainsDocTest() throws Exception { public void getAllDomainsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -100,7 +100,7 @@ public class TaskanaEngineControllerRestDocumentation {
@Test @Test
public void getAllClassificationCategoriesDocTest() throws Exception { public void getAllClassificationCategoriesDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -111,7 +111,7 @@ public class TaskanaEngineControllerRestDocumentation {
@Test @Test
public void getAllClassificationTypesDocTest() throws Exception { public void getAllClassificationTypesDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -122,7 +122,7 @@ public class TaskanaEngineControllerRestDocumentation {
@Test @Test
public void getCurrentUserInfo() throws Exception { public void getCurrentUserInfo() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -133,7 +133,7 @@ public class TaskanaEngineControllerRestDocumentation {
@Test @Test
public void getHistoryProviderIsEnabled() throws Exception { public void getHistoryProviderIsEnabled() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -65,82 +65,82 @@ public class WorkbasketAccessItemControllerRestDocumentation {
.withRequestDefaults(prettyPrint())) .withRequestDefaults(prettyPrint()))
.build(); .build();
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID"); accessItemFieldDescriptionsMap.put("accessItems.accessItemId", "Unique ID");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketId", "The workbasket id"); accessItemFieldDescriptionsMap.put("accessItems.workbasketId", "The workbasket id");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId", accessItemFieldDescriptionsMap.put("accessItems.accessId",
"The access id. This could be either a userid or a full qualified group id"); "The access id. This could be either a userid or a full qualified group id");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessName", "The name"); accessItemFieldDescriptionsMap.put("accessItems.accessName", "The name");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketKey", "The workbasket key"); accessItemFieldDescriptionsMap.put("accessItems.workbasketKey", "The workbasket key");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead", accessItemFieldDescriptionsMap.put("accessItems.permRead",
"The permission to read the information about the workbasket"); "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"); "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)"); "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)"); "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"); "The permission to distribute tasks from the workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom1", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom1", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom2", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom2", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom3", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom3", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom4", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom4", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom5", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom5", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom6", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom6", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom7", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom7", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom8", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom8", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom9", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom9", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom10", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom10", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom11", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom11", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom12", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom12", "");
accessItemFieldDescriptionsMap.put("_links.self.href", "Link to self"); accessItemFieldDescriptionsMap.put("_links.self.href", "Link to self");
accessItemFieldDescriptionsMap.put("page", "Number of page"); accessItemFieldDescriptionsMap.put("page", "Number of page");
accessItemFieldDescriptors = new FieldDescriptor[] { accessItemFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("_embedded.accessItems[].accessItemId") fieldWithPath("accessItems[].accessItemId")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")), .description(accessItemFieldDescriptionsMap.get("accessItems.accessItemId")),
fieldWithPath("_embedded.accessItems[].workbasketId") fieldWithPath("accessItems[].workbasketId")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")), .description(accessItemFieldDescriptionsMap.get("accessItems.workbasketId")),
fieldWithPath("_embedded.accessItems[].accessId") fieldWithPath("accessItems[].accessId")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")), .description(accessItemFieldDescriptionsMap.get("accessItems.accessId")),
fieldWithPath("_embedded.accessItems[].accessName") fieldWithPath("accessItems[].accessName")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")), .description(accessItemFieldDescriptionsMap.get("accessItems.accessName")),
fieldWithPath("_embedded.accessItems[].workbasketKey") fieldWithPath("accessItems[].workbasketKey")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")), .description(accessItemFieldDescriptionsMap.get("accessItems.workbasketKey")),
fieldWithPath("_embedded.accessItems[].permRead") fieldWithPath("accessItems[].permRead")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")), .description(accessItemFieldDescriptionsMap.get("accessItems.permRead")),
fieldWithPath("_embedded.accessItems[].permOpen") fieldWithPath("accessItems[].permOpen")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")), .description(accessItemFieldDescriptionsMap.get("accessItems.permOpen")),
fieldWithPath("_embedded.accessItems[].permAppend") fieldWithPath("accessItems[].permAppend")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")), .description(accessItemFieldDescriptionsMap.get("accessItems.permAppend")),
fieldWithPath("_embedded.accessItems[].permTransfer") fieldWithPath("accessItems[].permTransfer")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")), .description(accessItemFieldDescriptionsMap.get("accessItems.permTransfer")),
fieldWithPath("_embedded.accessItems[].permDistribute") fieldWithPath("accessItems[].permDistribute")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")), .description(accessItemFieldDescriptionsMap.get("accessItems.permDistribute")),
fieldWithPath("_embedded.accessItems[].permCustom1") fieldWithPath("accessItems[].permCustom1")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom1")),
fieldWithPath("_embedded.accessItems[].permCustom2") fieldWithPath("accessItems[].permCustom2")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom2")),
fieldWithPath("_embedded.accessItems[].permCustom3") fieldWithPath("accessItems[].permCustom3")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom3")),
fieldWithPath("_embedded.accessItems[].permCustom4") fieldWithPath("accessItems[].permCustom4")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom4")),
fieldWithPath("_embedded.accessItems[].permCustom5") fieldWithPath("accessItems[].permCustom5")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom5")),
fieldWithPath("_embedded.accessItems[].permCustom6") fieldWithPath("accessItems[].permCustom6")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom6")),
fieldWithPath("_embedded.accessItems[].permCustom7") fieldWithPath("accessItems[].permCustom7")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom7")),
fieldWithPath("_embedded.accessItems[].permCustom8") fieldWithPath("accessItems[].permCustom8")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom8")),
fieldWithPath("_embedded.accessItems[].permCustom9") fieldWithPath("accessItems[].permCustom9")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom9")),
fieldWithPath("_embedded.accessItems[].permCustom10") fieldWithPath("accessItems[].permCustom10")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom10")),
fieldWithPath("_embedded.accessItems[].permCustom11") fieldWithPath("accessItems[].permCustom11")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom11")),
fieldWithPath("_embedded.accessItems[].permCustom12") fieldWithPath("accessItems[].permCustom12")
.description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
fieldWithPath("_links.self.href").description(accessItemFieldDescriptionsMap.get("_links.self.href")), fieldWithPath("_links.self.href").description(accessItemFieldDescriptionsMap.get("_links.self.href")),
fieldWithPath("page").description(accessItemFieldDescriptionsMap.get("page")) fieldWithPath("page").description(accessItemFieldDescriptionsMap.get("page"))
}; };
@ -151,7 +151,7 @@ public class WorkbasketAccessItemControllerRestDocumentation {
this.mockMvc this.mockMvc
.perform(RestDocumentationRequestBuilders .perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port .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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -163,7 +163,7 @@ public class WorkbasketAccessItemControllerRestDocumentation {
public void removeWorkbasketAccessItemsDocTest() throws Exception { public void removeWorkbasketAccessItemsDocTest() throws Exception {
this.mockMvc this.mockMvc
.perform(RestDocumentationRequestBuilders .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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest")); .andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest"));

View File

@ -108,39 +108,39 @@ public class WorkbasketControllerRestDocumentation {
workbasketFieldDescriptionsMap.put("_links.accessItems.href", "The Access-Items of the workbasket"); workbasketFieldDescriptionsMap.put("_links.accessItems.href", "The Access-Items of the workbasket");
workbasketFieldDescriptionsMap.put("_links.allWorkbaskets.href", "Link to all workbaskets"); workbasketFieldDescriptionsMap.put("_links.allWorkbaskets.href", "Link to all workbaskets");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID"); accessItemFieldDescriptionsMap.put("accessItems.accessItemId", "Unique ID");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketId", "The workbasket"); accessItemFieldDescriptionsMap.put("accessItems.workbasketId", "The workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketKey", "The workbasket key"); accessItemFieldDescriptionsMap.put("accessItems.workbasketKey", "The workbasket key");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId", 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)"); "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("accessItems.accessName", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead", accessItemFieldDescriptionsMap.put("accessItems.permRead",
"The permission to read the information about the workbasket"); "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"); "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)"); "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)"); "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"); "The permission to distribute tasks from the workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom1", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom1", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom2", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom2", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom3", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom3", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom4", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom4", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom5", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom5", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom6", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom6", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom7", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom7", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom8", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom8", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom9", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom9", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom10", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom10", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom11", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom11", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom12", ""); accessItemFieldDescriptionsMap.put("accessItems.permCustom12", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems._links.workbasket.href", "Link to the workbasket"); accessItemFieldDescriptionsMap.put("accessItems._links.workbasket.href", "Link to the workbasket");
allWorkbasketsFieldDescriptors = new FieldDescriptor[] { allWorkbasketsFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.workbaskets").description( subsectionWithPath("workbaskets").description(
"An Array of <<workbasket-subset, Workbasket-Subsets>>"), "An Array of <<workbasket-subset, Workbasket-Subsets>>"),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored() fieldWithPath("page").ignored()
@ -203,62 +203,62 @@ public class WorkbasketControllerRestDocumentation {
}; };
accessItemFieldDescriptors = new FieldDescriptor[] { accessItemFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("_embedded.accessItems[].accessItemId").description( fieldWithPath("accessItems[].accessItemId").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")), accessItemFieldDescriptionsMap.get("accessItems.accessItemId")),
fieldWithPath("_embedded.accessItems[].workbasketId").description( fieldWithPath("accessItems[].workbasketId").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")), accessItemFieldDescriptionsMap.get("accessItems.workbasketId")),
fieldWithPath("_embedded.accessItems[].workbasketKey").description( fieldWithPath("accessItems[].workbasketKey").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")), accessItemFieldDescriptionsMap.get("accessItems.workbasketKey")),
fieldWithPath("_embedded.accessItems[].accessId").description( fieldWithPath("accessItems[].accessId").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")), accessItemFieldDescriptionsMap.get("accessItems.accessId")),
fieldWithPath("_embedded.accessItems[].accessName").description( fieldWithPath("accessItems[].accessName").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")), accessItemFieldDescriptionsMap.get("accessItems.accessName")),
fieldWithPath("_embedded.accessItems[].permRead").description( fieldWithPath("accessItems[].permRead").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")), accessItemFieldDescriptionsMap.get("accessItems.permRead")),
fieldWithPath("_embedded.accessItems[].permOpen").description( fieldWithPath("accessItems[].permOpen").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")), accessItemFieldDescriptionsMap.get("accessItems.permOpen")),
fieldWithPath("_embedded.accessItems[].permAppend").description( fieldWithPath("accessItems[].permAppend").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")), accessItemFieldDescriptionsMap.get("accessItems.permAppend")),
fieldWithPath("_embedded.accessItems[].permTransfer").description( fieldWithPath("accessItems[].permTransfer").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")), accessItemFieldDescriptionsMap.get("accessItems.permTransfer")),
fieldWithPath("_embedded.accessItems[].permDistribute").description( fieldWithPath("accessItems[].permDistribute").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")), accessItemFieldDescriptionsMap.get("accessItems.permDistribute")),
fieldWithPath("_embedded.accessItems[].permCustom1").description( fieldWithPath("accessItems[].permCustom1").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")), accessItemFieldDescriptionsMap.get("accessItems.permCustom1")),
fieldWithPath("_embedded.accessItems[].permCustom2").description( fieldWithPath("accessItems[].permCustom2").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")), accessItemFieldDescriptionsMap.get("accessItems.permCustom2")),
fieldWithPath("_embedded.accessItems[].permCustom3").description( fieldWithPath("accessItems[].permCustom3").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")), accessItemFieldDescriptionsMap.get("accessItems.permCustom3")),
fieldWithPath("_embedded.accessItems[].permCustom4").description( fieldWithPath("accessItems[].permCustom4").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")), accessItemFieldDescriptionsMap.get("accessItems.permCustom4")),
fieldWithPath("_embedded.accessItems[].permCustom5").description( fieldWithPath("accessItems[].permCustom5").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")), accessItemFieldDescriptionsMap.get("accessItems.permCustom5")),
fieldWithPath("_embedded.accessItems[].permCustom6").description( fieldWithPath("accessItems[].permCustom6").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")), accessItemFieldDescriptionsMap.get("accessItems.permCustom6")),
fieldWithPath("_embedded.accessItems[].permCustom7").description( fieldWithPath("accessItems[].permCustom7").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")), accessItemFieldDescriptionsMap.get("accessItems.permCustom7")),
fieldWithPath("_embedded.accessItems[].permCustom8").description( fieldWithPath("accessItems[].permCustom8").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")), accessItemFieldDescriptionsMap.get("accessItems.permCustom8")),
fieldWithPath("_embedded.accessItems[].permCustom9").description( fieldWithPath("accessItems[].permCustom9").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")), accessItemFieldDescriptionsMap.get("accessItems.permCustom9")),
fieldWithPath("_embedded.accessItems[].permCustom10").description( fieldWithPath("accessItems[].permCustom10").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")), accessItemFieldDescriptionsMap.get("accessItems.permCustom10")),
fieldWithPath("_embedded.accessItems[].permCustom11").description( fieldWithPath("accessItems[].permCustom11").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")), accessItemFieldDescriptionsMap.get("accessItems.permCustom11")),
fieldWithPath("_embedded.accessItems[].permCustom12").description( fieldWithPath("accessItems[].permCustom12").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")), accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.workbasket.href").ignored() fieldWithPath("_links.workbasket.href").ignored()
}; };
allWorkbasketAccessItemsFieldDescriptors = new FieldDescriptor[] { 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.self.href").ignored(),
fieldWithPath("_links.workbasket.href").ignored() fieldWithPath("_links.workbasket.href").ignored()
}; };
allDistributionTargetsFieldDescriptors = new FieldDescriptor[] { allDistributionTargetsFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.distributionTargets").description( subsectionWithPath("distributionTargets").description(
"An array of <<workbasket-subset, workbasket subsets>>"), "An array of <<workbasket-subset, workbasket subsets>>"),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.workbasket.href").ignored() fieldWithPath("_links.workbasket.href").ignored()
@ -317,7 +317,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void getAllWorkbasketsDocTest() throws Exception { public void getAllWorkbasketsDocTest() throws Exception {
this.mockMvc.perform( 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -328,7 +328,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void getSpecificWorkbasketDocTest() throws Exception { public void getSpecificWorkbasketDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get( 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -339,7 +339,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void getAllWorkbasketAccessItemsDocTest() throws Exception { public void getAllWorkbasketAccessItemsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -350,7 +350,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void workbasketSubsetDocTest() throws Exception { public void workbasketSubsetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get( 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -361,7 +361,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void removeWorkbasketAsDistributionTargetDocTest() throws Exception { public void removeWorkbasketAsDistributionTargetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port 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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAsDistributionTargetDocTest")); .andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAsDistributionTargetDocTest"));
@ -370,7 +370,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void getAllWorkbasketDistributionTargets() throws Exception { public void getAllWorkbasketDistributionTargets() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port 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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketDistributionTargets", .andDo(MockMvcRestDocumentation.document("GetAllWorkbasketDistributionTargets",
@ -379,7 +379,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void createWorkbasketDocTest() throws Exception { 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") .contentType("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content( .content(
@ -395,7 +395,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void updateWorkbasketDocTest() throws Exception { 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
@ -414,7 +414,7 @@ public class WorkbasketControllerRestDocumentation {
String modifiedWorkbasket = new String(originalWorkbasket.toString()); String modifiedWorkbasket = new String(originalWorkbasket.toString());
this.mockMvc.perform(RestDocumentationRequestBuilders.put( 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") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json") .contentType("application/json")
.content(modifiedWorkbasket)) .content(modifiedWorkbasket))
@ -427,7 +427,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void markWorkbasketForDeletionDocTest() throws Exception { public void markWorkbasketForDeletionDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.delete( 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=")) .header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isAccepted()) .andExpect(MockMvcResultMatchers.status().isAccepted())
.andDo(MockMvcRestDocumentation.document("MarkWorkbasketForDeletionDocTest")); .andDo(MockMvcRestDocumentation.document("MarkWorkbasketForDeletionDocTest"));
@ -436,7 +436,7 @@ public class WorkbasketControllerRestDocumentation {
@Test @Test
public void accessItemDocTest() throws Exception { public void accessItemDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -34,7 +34,6 @@ import pro.taskana.rest.RestConfiguration;
/** /**
* Generate Rest Documentation for Workbasket Definitions. * Generate Rest Documentation for Workbasket Definitions.
*
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@ -75,7 +74,7 @@ public class WorkbasketDefinitionControllerRestDocumentation {
@Test @Test
public void exportAllWorkbasketDefinitions() throws Exception { public void exportAllWorkbasketDefinitions() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders 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") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .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", .file("file",
definitionString.getBytes()) definitionString.getBytes())
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(document("ImportWorkbasketDefinitions", requestParts( .andDo(document("ImportWorkbasketDefinitions", requestParts(
partWithName("file").description("The file to upload")))); partWithName("file").description("The file to upload"))));
} }

View File

@ -92,12 +92,10 @@ public class AsyncUpdateJobIntTest {
String updatedClassification; String updatedClassification;
ResponseEntity<ClassificationResource> response = template.exchange( 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, HttpMethod.GET,
request, request,
new ParameterizedTypeReference<ClassificationResource>() { ParameterizedTypeReference.forType(ClassificationResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
ClassificationResource classification = response.getBody(); ClassificationResource classification = response.getBody();
@ -109,7 +107,7 @@ public class AsyncUpdateJobIntTest {
updatedClassification = mapper.writeValueAsString(classification); 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("PUT"); con.setRequestMethod("PUT");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -131,12 +129,10 @@ public class AsyncUpdateJobIntTest {
// verify the classification modified timestamp is after 'before' // verify the classification modified timestamp is after 'before'
ResponseEntity<ClassificationResource> repeatedResponse = template.exchange( 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, HttpMethod.GET,
request, request,
new ParameterizedTypeReference<ClassificationResource>() { ParameterizedTypeReference.forType(ClassificationResource.class));
});
ClassificationResource modifiedClassificationResource = repeatedResponse.getBody(); ClassificationResource modifiedClassificationResource = repeatedResponse.getBody();
Classification modifiedClassification = classificationResourceAssembler.toModel(modifiedClassificationResource); Classification modifiedClassification = classificationResourceAssembler.toModel(modifiedClassificationResource);
@ -178,12 +174,10 @@ public class AsyncUpdateJobIntTest {
HttpEntity<String> admRequest = new HttpEntity<String>(admHeaders); HttpEntity<String> admRequest = new HttpEntity<String>(admHeaders);
ResponseEntity<TaskResource> taskResponse = admTemplate.exchange( 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, HttpMethod.GET,
admRequest, admRequest,
new ParameterizedTypeReference<TaskResource>() { ParameterizedTypeReference.forType(TaskResource.class));
});
TaskResource taskResource = taskResponse.getBody(); TaskResource taskResource = taskResponse.getBody();
Task task = taskResourceAssembler.toModel(taskResource); Task task = taskResourceAssembler.toModel(taskResource);

View File

@ -53,9 +53,8 @@ public class AccessIdValidationControllerIntTest {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<List<AccessIdResource>> response = template.exchange( 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>>() { new ParameterizedTypeReference<List<AccessIdResource>>() {
}); });
List<AccessIdResource> body = response.getBody(); List<AccessIdResource> body = response.getBody();
assertNotNull(body); assertNotNull(body);
@ -75,10 +74,8 @@ public class AccessIdValidationControllerIntTest {
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
try { try {
template.exchange( template.exchange(
"http://127.0.0.1:" + port + "/v1/access-ids?search-for=al", HttpMethod.GET, request, "http://127.0.0.1:" + port + "/api/v1/access-ids?search-for=al", HttpMethod.GET, request,
new ParameterizedTypeReference<List<AccessIdResource>>() { ParameterizedTypeReference.forType(List.class));
});
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
assertTrue(e.getResponseBodyAsString().contains("Minimum searchFor length =")); assertTrue(e.getResponseBodyAsString().contains("Minimum searchFor length ="));
@ -100,7 +97,7 @@ public class AccessIdValidationControllerIntTest {
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template; return template;
} }

View File

@ -22,7 +22,6 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -41,21 +40,22 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.Task; import pro.taskana.Task;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.rest.resource.ClassificationSummaryListResource;
import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.ClassificationSummaryResource;
import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskResource;
import pro.taskana.rest.resource.TaskResourceAssembler; import pro.taskana.rest.resource.TaskResourceAssembler;
/** /**
* Test ClassificationController. * Test ClassificationController.
* @author bbr
* *
* @author bbr
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
properties = {"devMode=true"}) properties = {"devMode=true"})
public class ClassificationControllerIntTest { public class ClassificationControllerIntTest {
@Autowired @Autowired
private TaskResourceAssembler taskResourceAssembler; private TaskResourceAssembler taskResourceAssembler;
@Autowired @Autowired
@ -77,59 +77,51 @@ public class ClassificationControllerIntTest {
@Test @Test
public void testGetAllClassifications() { public void testGetAllClassifications() {
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange( ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
server + port + "/v1/classifications", HttpMethod.GET, request, server + port + "/api/v1/classifications", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() { ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
} }
@Test @Test
public void testGetAllClassificationsFilterByCustomAttribute() { public void testGetAllClassificationsFilterByCustomAttribute() {
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange( ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
server + port + "/v1/classifications?domain=DOMAIN_A&custom-1-like=RVNR", HttpMethod.GET, server + port + "/api/v1/classifications?domain=DOMAIN_A&custom-1-like=RVNR", HttpMethod.GET,
request, request,
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() { ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(13, response.getBody().getContent().size()); assertEquals(13, response.getBody().getContent().size());
} }
@Test @Test
public void testGetAllClassificationsKeepingFilters() { public void testGetAllClassificationsKeepingFilters() {
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange( ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
server + port + "/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc", HttpMethod.GET, server + port + "/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc", HttpMethod.GET,
request, request,
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() { ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertTrue(response.getBody() assertTrue(response.getBody()
.getLink(Link.REL_SELF) .getLink(Link.REL_SELF)
.getHref() .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(17, response.getBody().getContent().size());
assertEquals("A12", response.getBody().getContent().iterator().next().key); assertEquals("A12", response.getBody().getContent().iterator().next().key);
} }
@Test @Test
public void testGetSecondPageSortedByKey() { public void testGetSecondPageSortedByKey() {
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange( ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
server + port + "/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5", server + port + "/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5",
HttpMethod.GET, HttpMethod.GET,
request, request,
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() { ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
});
assertEquals(5, response.getBody().getContent().size()); assertEquals(5, response.getBody().getContent().size());
assertEquals("L1050", response.getBody().getContent().iterator().next().key); assertEquals("L1050", response.getBody().getContent().iterator().next().key);
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertTrue(response.getBody() assertTrue(response.getBody()
.getLink(Link.REL_SELF) .getLink(Link.REL_SELF)
.getHref() .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_FIRST));
assertNotNull(response.getBody().getLink(Link.REL_LAST)); assertNotNull(response.getBody().getLink(Link.REL_LAST));
assertNotNull(response.getBody().getLink(Link.REL_NEXT)); assertNotNull(response.getBody().getLink(Link.REL_NEXT));
@ -139,7 +131,7 @@ public class ClassificationControllerIntTest {
@Test @Test
public void testCreateClassification() throws IOException { public void testCreateClassification() throws IOException {
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}"; 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -153,7 +145,7 @@ public class ClassificationControllerIntTest {
con.disconnect(); con.disconnect();
newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS_2\",\"name\":\"new classification\",\"type\":\"TASK\"}"; 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 = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -170,7 +162,7 @@ public class ClassificationControllerIntTest {
@Test @Test
public void testCreateClassificationWithParentId() throws IOException { 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\"}"; 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -187,7 +179,7 @@ public class ClassificationControllerIntTest {
@Test @Test
public void testCreateClassificationWithParentKey() throws IOException { public void testCreateClassificationWithParentKey() throws IOException {
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}"; 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -206,7 +198,7 @@ public class ClassificationControllerIntTest {
throws IOException { throws IOException {
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}"; 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -219,12 +211,10 @@ public class ClassificationControllerIntTest {
assertEquals(201, con.getResponseCode()); assertEquals(201, con.getResponseCode());
con.disconnect(); con.disconnect();
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange( ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
server + port + "/v1/classifications", HttpMethod.GET, server + port + "/api/v1/classifications", HttpMethod.GET,
request, request,
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() { ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
boolean foundClassificationCreated = false; boolean foundClassificationCreated = false;
for (ClassificationSummaryResource classification : response.getBody().getContent()) { for (ClassificationSummaryResource classification : response.getBody().getContent()) {
@ -240,7 +230,7 @@ public class ClassificationControllerIntTest {
@Test @Test
public void testReturn400IfCreateClassificationWithIncompatibleParentIdAndKey() throws IOException { 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\"}"; 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -257,7 +247,7 @@ public class ClassificationControllerIntTest {
@Test @Test
public void testCreateClassificationWithClassificationIdReturnsError400() throws IOException { public void testCreateClassificationWithClassificationIdReturnsError400() throws IOException {
String newClassification = "{\"classificationId\":\"someId\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}"; 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -278,12 +268,10 @@ public class ClassificationControllerIntTest {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<ClassificationSummaryResource> response = template.exchange( 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, HttpMethod.GET,
request, request,
new ParameterizedTypeReference<ClassificationSummaryResource>() { ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
});
assertEquals("Zustimmungserklärung", response.getBody().name); assertEquals("Zustimmungserklärung", response.getBody().name);
} }
@ -295,21 +283,17 @@ public class ClassificationControllerIntTest {
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<ClassificationSummaryResource> response = template.exchange( 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, HttpMethod.DELETE,
request, request,
new ParameterizedTypeReference<ClassificationSummaryResource>() { ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
});
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
response = template.exchange( 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, HttpMethod.GET,
request, request,
new ParameterizedTypeReference<ClassificationSummaryResource>() { ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
});
} }
private void verifyTaskIsModifiedAfter(String taskId, Instant before) private void verifyTaskIsModifiedAfter(String taskId, Instant before)
@ -321,12 +305,10 @@ public class ClassificationControllerIntTest {
HttpEntity<String> admRequest = new HttpEntity<String>(admHeaders); HttpEntity<String> admRequest = new HttpEntity<String>(admHeaders);
ResponseEntity<TaskResource> taskResponse = admTemplate.exchange( 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, HttpMethod.GET,
admRequest, admRequest,
new ParameterizedTypeReference<TaskResource>() { ParameterizedTypeReference.forType(TaskResource.class));
});
TaskResource taskResource = taskResponse.getBody(); TaskResource taskResource = taskResponse.getBody();
Task task = taskResourceAssembler.toModel(taskResource); Task task = taskResourceAssembler.toModel(taskResource);

View File

@ -29,7 +29,6 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -49,6 +48,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationResource;
import pro.taskana.rest.resource.ClassificationSummaryListResource;
import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.ClassificationSummaryResource;
/** /**
@ -56,7 +56,7 @@ import pro.taskana.rest.resource.ClassificationSummaryResource;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"devMode=true" }) "devMode=true"})
public class ClassificationDefinitionControllerIntTest { public class ClassificationDefinitionControllerIntTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class);
@ -88,9 +88,8 @@ public class ClassificationDefinitionControllerIntTest {
@Test @Test
public void testExportClassifications() { public void testExportClassifications() {
ResponseEntity<ClassificationResource[]> response = template.exchange( ResponseEntity<ClassificationResource[]> response = template.exchange(
server + port + "/v1/classification-definitions?domain=DOMAIN_B", server + port + "/api/v1/classification-definitions?domain=DOMAIN_B",
HttpMethod.GET, request, new ParameterizedTypeReference<ClassificationResource[]>() { HttpMethod.GET, request, ParameterizedTypeReference.forType(ClassificationResource[].class));
});
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
assertTrue(response.getBody().length >= 5); assertTrue(response.getBody().length >= 5);
assertTrue(response.getBody().length <= 7); assertTrue(response.getBody().length <= 7);
@ -100,9 +99,8 @@ public class ClassificationDefinitionControllerIntTest {
@Test @Test
public void testExportClassificationsFromWrongDomain() { public void testExportClassificationsFromWrongDomain() {
ResponseEntity<ClassificationResource[]> response = template.exchange( ResponseEntity<ClassificationResource[]> response = template.exchange(
server + port + "/v1/classification-definitions?domain=ADdfe", server + port + "/api/v1/classification-definitions?domain=ADdfe",
HttpMethod.GET, request, new ParameterizedTypeReference<ClassificationResource[]>() { HttpMethod.GET, request, ParameterizedTypeReference.forType(ClassificationResource[].class));
});
assertEquals(0, response.getBody().length); assertEquals(0, response.getBody().length);
} }
@ -136,8 +134,8 @@ public class ClassificationDefinitionControllerIntTest {
List<String> clList = new ArrayList<>(); List<String> clList = new ArrayList<>();
clList.add(objMapper.writeValueAsString(classification)); clList.add(objMapper.writeValueAsString(classification));
ResponseEntity<String> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
} }
@Test @Test
@ -205,8 +203,8 @@ public class ClassificationDefinitionControllerIntTest {
clList.add(c1); clList.add(c1);
clList.add(c2); clList.add(c2);
ResponseEntity<String> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
} }
@Test @Test
@ -235,15 +233,15 @@ public class ClassificationDefinitionControllerIntTest {
List<String> clList = new ArrayList<>(); List<String> clList = new ArrayList<>();
clList.add(objMapper.writeValueAsString(existingClassification)); clList.add(objMapper.writeValueAsString(existingClassification));
ResponseEntity<String> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
existingClassification.setName("second new Name"); existingClassification.setName("second new Name");
clList = new ArrayList<>(); clList = new ArrayList<>();
clList.add(objMapper.writeValueAsString(existingClassification)); clList.add(objMapper.writeValueAsString(existingClassification));
response = importRequest(clList); response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
ClassificationSummaryResource testClassification = this.getClassificationWithKeyAndDomain("L110107", ClassificationSummaryResource testClassification = this.getClassificationWithKeyAndDomain("L110107",
"DOMAIN_A"); "DOMAIN_A");
@ -262,8 +260,8 @@ public class ClassificationDefinitionControllerIntTest {
clList.add(objMapper.writeValueAsString(existingClassification)); clList.add(objMapper.writeValueAsString(existingClassification));
clList.add(objMapper.writeValueAsString(newClassification)); clList.add(objMapper.writeValueAsString(newClassification));
ResponseEntity<String> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("L11010", "DOMAIN_A"); ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("L11010", "DOMAIN_A");
ClassificationSummaryResource testNewCl = getClassificationWithKeyAndDomain("newClass", "DOMAIN_A"); ClassificationSummaryResource testNewCl = getClassificationWithKeyAndDomain("newClass", "DOMAIN_A");
@ -301,8 +299,8 @@ public class ClassificationDefinitionControllerIntTest {
clList.add(c22); clList.add(c22);
clList.add(c1); clList.add(c1);
ResponseEntity<String> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A"); ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A");
ClassificationSummaryResource childCl = getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A"); ClassificationSummaryResource childCl = getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A");
@ -332,8 +330,8 @@ public class ClassificationDefinitionControllerIntTest {
clList.add(parent); clList.add(parent);
clList.add(child); clList.add(child);
ResponseEntity<String> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
ClassificationSummaryResource rightParentCl = getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_A"); ClassificationSummaryResource rightParentCl = getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_A");
ClassificationSummaryResource wrongParentCl = getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_B"); ClassificationSummaryResource wrongParentCl = getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_B");
@ -364,8 +362,8 @@ public class ClassificationDefinitionControllerIntTest {
clList.add(withNewParent); clList.add(withNewParent);
clList.add(withoutParent); clList.add(withoutParent);
ResponseEntity<String> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
Thread.sleep(10); Thread.sleep(10);
LOGGER.debug("Wait 10 ms to give the system a chance to update"); LOGGER.debug("Wait 10 ms to give the system a chance to update");
@ -413,17 +411,15 @@ public class ClassificationDefinitionControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = template.exchange( ResponseEntity<ClassificationSummaryListResource> response = template.exchange(
"http://127.0.0.1:" + port + "/v1/classifications?key=" + key + "&domain=" + domain, "http://127.0.0.1:" + port + "/api/v1/classifications?key=" + key + "&domain=" + domain,
HttpMethod.GET, HttpMethod.GET,
request, request,
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() { ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
});
return response.getBody().getContent().toArray(new ClassificationSummaryResource[1])[0]; 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"); LOGGER.debug("Start Import");
File tmpFile = File.createTempFile("test", ".tmp"); File tmpFile = File.createTempFile("test", ".tmp");
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmpFile), StandardCharsets.UTF_8); OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmpFile), StandardCharsets.UTF_8);
@ -435,10 +431,10 @@ public class ClassificationDefinitionControllerIntTest {
body.add("file", new FileSystemResource(tmpFile)); body.add("file", new FileSystemResource(tmpFile));
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); 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(); RestTemplate restTemplate = new RestTemplate();
return restTemplate.postForEntity(serverUrl, requestEntity, String.class); return restTemplate.postForEntity(serverUrl, requestEntity, Void.class);
} }
/** /**

View File

@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; 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.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender; import ch.qos.logback.core.Appender;
import pro.taskana.ldap.LdapCacheTestImpl; import pro.taskana.ldap.LdapCacheTestImpl;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.ClassificationSummaryListResource;
import pro.taskana.rest.resource.ClassificationSummaryResource;
/** /**
* Test general Exception Handling. * Test general Exception Handling.
*
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
"devMode=true"}) properties = {
"devMode=true"})
public class GenenalExceptionHandlingTest { public class GenenalExceptionHandlingTest {
String server = "http://127.0.0.1:"; String server = "http://127.0.0.1:";
@ -69,8 +67,8 @@ public class GenenalExceptionHandlingTest {
logger.addAppender(mockAppender); logger.addAppender(mockAppender);
} }
//Always have this teardown otherwise we can stuff up our expectations. Besides, it's // Always have this teardown otherwise we can stuff up our expectations. Besides, it's
//good coding practise // good coding practise
@After @After
public void teardown() { public void teardown() {
final Logger logger = (Logger) LoggerFactory.getLogger(TaskanaRestExceptionHandler.class); final Logger logger = (Logger) LoggerFactory.getLogger(TaskanaRestExceptionHandler.class);
@ -83,10 +81,8 @@ public class GenenalExceptionHandlingTest {
AccessIdController.setLdapCache(new LdapCacheTestImpl()); AccessIdController.setLdapCache(new LdapCacheTestImpl());
template.exchange( template.exchange(
server + port + "/v1/access-ids?search-for=al", HttpMethod.GET, request, server + port + "/api/v1/access-ids?search-for=al", HttpMethod.GET, request,
new ParameterizedTypeReference<List<AccessIdResource>>() { ParameterizedTypeReference.forType(List.class));
});
} catch (Exception ex) { } catch (Exception ex) {
verify(mockAppender).doAppend(captorLoggingEvent.capture()); verify(mockAppender).doAppend(captorLoggingEvent.capture());
assertTrue( assertTrue(
@ -98,10 +94,8 @@ public class GenenalExceptionHandlingTest {
public void testDeleteNonExisitingClassificationExceptionIsLogged() { public void testDeleteNonExisitingClassificationExceptionIsLogged() {
try { try {
template.exchange( template.exchange(
server + port + "/v1/classifications/non-existing-id", HttpMethod.DELETE, request, server + port + "/api/v1/classifications/non-existing-id", HttpMethod.DELETE, request,
new ParameterizedTypeReference<PagedResources<ClassificationSummaryResource>>() { ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
});
} catch (Exception ex) { } catch (Exception ex) {
verify(mockAppender).doAppend(captorLoggingEvent.capture()); verify(mockAppender).doAppend(captorLoggingEvent.capture());
assertTrue(captorLoggingEvent.getValue() assertTrue(captorLoggingEvent.getValue()
@ -125,7 +119,7 @@ public class GenenalExceptionHandlingTest {
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template; return template;
} }
} }

View File

@ -28,7 +28,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -48,7 +47,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.exceptions.SystemException; import pro.taskana.exceptions.SystemException;
import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskResource;
import pro.taskana.rest.resource.TaskSummaryResource; import pro.taskana.rest.resource.TaskSummaryListResource;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
/** /**
@ -84,11 +83,9 @@ public class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); 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", HttpMethod.GET, request, "http://127.0.0.1:" + port + "/api/v1/tasks", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(25, response.getBody().getContent().size()); assertEquals(25, response.getBody().getContent().size());
} }
@ -99,12 +96,10 @@ public class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); // teamlead_1 headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); // teamlead_1
HttpEntity<String> request = new HttpEntity<String>(headers); 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?workbasket-id=WBI:100000000000000000000000000000000001", "http://127.0.0.1:" + port + "/api/v1/tasks?workbasket-id=WBI:100000000000000000000000000000000001",
HttpMethod.GET, request, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(22, response.getBody().getContent().size()); assertEquals(22, response.getBody().getContent().size());
} }
@ -115,12 +110,10 @@ public class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2 headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
HttpEntity<String> request = new HttpEntity<String>(headers); 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?workbasket-key=USER_1_2&domain=DOMAIN_A", "http://127.0.0.1:" + port + "/api/v1/tasks?workbasket-key=USER_1_2&domain=DOMAIN_A",
HttpMethod.GET, request, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(20, response.getBody().getContent().size()); assertEquals(20, response.getBody().getContent().size());
} }
@ -132,12 +125,10 @@ public class TaskControllerIntTest {
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2 headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
try { try {
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange( ResponseEntity<TaskSummaryListResource> response = template.exchange(
"http://127.0.0.1:" + port + "/v1/tasks?workbasket-key=USER_1_2", "http://127.0.0.1:" + port + "/api/v1/tasks?workbasket-key=USER_1_2",
HttpMethod.GET, request, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
fail(); fail();
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
@ -150,11 +141,9 @@ public class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // Role Admin headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // Role Admin
HttpEntity<String> request = new HttpEntity<String>(headers); 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", HttpMethod.GET, request, "http://127.0.0.1:" + port + "/api/v1/tasks", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(73, response.getBody().getContent().size()); assertEquals(73, response.getBody().getContent().size());
} }
@ -165,17 +154,15 @@ public class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); 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.type=VNR&por.value=22334455&sort-by=por.value&order=desc", "http://127.0.0.1:" + port + "/api/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc",
HttpMethod.GET, request, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertTrue(response.getBody() assertTrue(response.getBody()
.getLink(Link.REL_SELF) .getLink(Link.REL_SELF)
.getHref() .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 @Test
@ -186,11 +173,9 @@ public class TaskControllerIntTest {
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
try { try {
template.exchange( 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, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
fail(); fail();
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
@ -204,14 +189,12 @@ public class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // Role Admin headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // Role Admin
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange( ResponseEntity<TaskSummaryListResource> response = template.exchange(
"http://127.0.0.1:" + port "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, HttpMethod.GET,
request, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertEquals(1, response.getBody().getContent().size()); assertEquals(1, response.getBody().getContent().size());
assertTrue(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=14")); assertTrue(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=14"));
assertEquals("TKI:100000000000000000000000000000000000", assertEquals("TKI:100000000000000000000000000000000000",
@ -220,7 +203,7 @@ public class TaskControllerIntTest {
assertTrue(response.getBody() assertTrue(response.getBody()
.getLink(Link.REL_SELF) .getLink(Link.REL_SELF)
.getHref() .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_FIRST));
assertNotNull(response.getBody().getLink(Link.REL_LAST)); assertNotNull(response.getBody().getLink(Link.REL_LAST));
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS)); assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
@ -235,20 +218,16 @@ public class TaskControllerIntTest {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); 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?sort-by=due&order=desc", HttpMethod.GET, "http://127.0.0.1:" + port + "/api/v1/tasks?sort-by=due&order=desc", HttpMethod.GET,
request, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertEquals(25, response.getBody().getContent().size()); assertEquals(25, response.getBody().getContent().size());
response = template.exchange( 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, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertEquals(5, response.getBody().getContent().size()); assertEquals(5, response.getBody().getContent().size());
assertTrue(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=5")); assertTrue(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=5"));
assertEquals("TKI:000000000000000000000000000000000023", assertEquals("TKI:000000000000000000000000000000000023",
@ -257,7 +236,7 @@ public class TaskControllerIntTest {
assertTrue(response.getBody() assertTrue(response.getBody()
.getLink(Link.REL_SELF) .getLink(Link.REL_SELF)
.getHref() .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_FIRST));
assertNotNull(response.getBody().getLink(Link.REL_LAST)); assertNotNull(response.getBody().getLink(Link.REL_LAST));
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS)); assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
@ -271,14 +250,12 @@ public class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange( ResponseEntity<TaskSummaryListResource> response = template.exchange(
"http://127.0.0.1:" + port "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, HttpMethod.GET,
request, request,
new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() { ParameterizedTypeReference.forType(TaskSummaryListResource.class));
});
assertEquals(1, response.getBody().getContent().size()); assertEquals(1, response.getBody().getContent().size());
assertEquals("TKI:000000000000000000000000000000000013", assertEquals("TKI:000000000000000000000000000000000013",
response.getBody().getContent().iterator().next().getTaskId()); response.getBody().getContent().iterator().next().getTaskId());
@ -287,7 +264,7 @@ public class TaskControllerIntTest {
.getLink(Link.REL_SELF) .getLink(Link.REL_SELF)
.getHref() .getHref()
.endsWith( .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_FIRST));
assertNotNull(response.getBody().getLink(Link.REL_LAST)); assertNotNull(response.getBody().getLink(Link.REL_LAST));
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS)); assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
@ -295,7 +272,7 @@ public class TaskControllerIntTest {
@Test @Test
public void testGetTaskWithAttachments() throws IOException { 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
@ -321,7 +298,7 @@ public class TaskControllerIntTest {
@Test @Test
public void testGetAndUpdateTask() throws IOException { 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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -350,7 +327,7 @@ public class TaskControllerIntTest {
assertEquals(200, con.getResponseCode()); assertEquals(200, con.getResponseCode());
con.disconnect(); 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 = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -382,7 +359,7 @@ public class TaskControllerIntTest {
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; + "\"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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setDoOutput(true); con.setDoOutput(true);
@ -412,7 +389,7 @@ public class TaskControllerIntTest {
assertTrue(taskIdOfCreatedTask.startsWith("TKI:")); assertTrue(taskIdOfCreatedTask.startsWith("TKI:"));
// delete task again to clean test data // 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 = (HttpURLConnection) url.openConnection();
con.setRequestMethod("DELETE"); con.setRequestMethod("DELETE");
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); // admin con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); // admin
@ -426,7 +403,7 @@ public class TaskControllerIntTest {
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; + "\"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(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setDoOutput(true); con.setDoOutput(true);
@ -439,12 +416,11 @@ public class TaskControllerIntTest {
assertEquals(400, con.getResponseCode()); assertEquals(400, con.getResponseCode());
con.disconnect(); con.disconnect();
taskToCreateJson = taskToCreateJson = "{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"},"
"{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"}," + "\"workbasketSummaryResource\":{\"workbasketId\":\"\"},"
+ "\"workbasketSummaryResource\":{\"workbasketId\":\"\"}," + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
+ "\"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 = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
con.setDoOutput(true); con.setDoOutput(true);
@ -474,7 +450,7 @@ public class TaskControllerIntTest {
// converter.setSupportedMediaTypes(ImmutableList.of(MediaTypes.HAL_JSON)); // converter.setSupportedMediaTypes(ImmutableList.of(MediaTypes.HAL_JSON));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template; return template;
} }

View File

@ -32,10 +32,10 @@ import pro.taskana.rest.resource.TaskanaUserInfoResource;
/** /**
* Test TaskanaEngineController. * Test TaskanaEngineController.
*
*/ */
@RunWith(SpringRunner.class) @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 { public class TaskanaEngineControllerIntTest {
@LocalServerPort @LocalServerPort
@ -48,9 +48,8 @@ public class TaskanaEngineControllerIntTest {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<List<String>> response = template.exchange( ResponseEntity<List<String>> response = template.exchange(
"http://127.0.0.1:" + port + "/v1/domains", HttpMethod.GET, request, "http://127.0.0.1:" + port + "/api/v1/domains", HttpMethod.GET, request,
new ParameterizedTypeReference<List<String>>() { ParameterizedTypeReference.forType(List.class));
});
assertTrue(response.getBody().contains("DOMAIN_A")); assertTrue(response.getBody().contains("DOMAIN_A"));
} }
@ -61,9 +60,8 @@ public class TaskanaEngineControllerIntTest {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<List<String>> response = template.exchange( ResponseEntity<List<String>> response = template.exchange(
"http://127.0.0.1:" + port + "/v1/classification-types", HttpMethod.GET, request, "http://127.0.0.1:" + port + "/api/v1/classification-types", HttpMethod.GET, request,
new ParameterizedTypeReference<List<String>>() { ParameterizedTypeReference.forType(List.class));
});
assertTrue(response.getBody().contains("TASK")); assertTrue(response.getBody().contains("TASK"));
assertTrue(response.getBody().contains("DOCUMENT")); assertTrue(response.getBody().contains("DOCUMENT"));
assertFalse(response.getBody().contains("UNKNOWN")); assertFalse(response.getBody().contains("UNKNOWN"));
@ -76,9 +74,8 @@ public class TaskanaEngineControllerIntTest {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<List<String>> response = template.exchange( ResponseEntity<List<String>> response = template.exchange(
"http://127.0.0.1:" + port + "/v1/classification-categories/?type=TASK", HttpMethod.GET, request, "http://127.0.0.1:" + port + "/api/v1/classification-categories/?type=TASK", HttpMethod.GET, request,
new ParameterizedTypeReference<List<String>>() { ParameterizedTypeReference.forType(List.class));
});
assertTrue(response.getBody().contains("MANUAL")); assertTrue(response.getBody().contains("MANUAL"));
assertTrue(response.getBody().contains("EXTERNAL")); assertTrue(response.getBody().contains("EXTERNAL"));
assertTrue(response.getBody().contains("AUTOMATIC")); assertTrue(response.getBody().contains("AUTOMATIC"));
@ -93,9 +90,8 @@ public class TaskanaEngineControllerIntTest {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<TaskanaUserInfoResource> response = template.exchange( ResponseEntity<TaskanaUserInfoResource> response = template.exchange(
"http://127.0.0.1:" + port + "/v1/current-user-info", HttpMethod.GET, request, "http://127.0.0.1:" + port + "/api/v1/current-user-info", HttpMethod.GET, request,
new ParameterizedTypeReference<TaskanaUserInfoResource>() { ParameterizedTypeReference.forType(TaskanaUserInfoResource.class));
});
assertEquals("teamlead_1", response.getBody().getUserId()); assertEquals("teamlead_1", response.getBody().getUserId());
assertTrue(response.getBody().getGroupIds().contains("businessadmin")); assertTrue(response.getBody().getGroupIds().contains("businessadmin"));
assertTrue(response.getBody().getRoles().contains(TaskanaRole.BUSINESS_ADMIN)); assertTrue(response.getBody().getRoles().contains(TaskanaRole.BUSINESS_ADMIN));

View File

@ -17,7 +17,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; 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.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; 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. * Test WorkbasketAccessItemController.
*
*/ */
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ -61,20 +60,18 @@ public class WorkbasketAccessItemControllerIntTest {
@Test @Test
public void testGetAllWorkbasketAccessItems() { public void testGetAllWorkbasketAccessItems() {
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = template.exchange( ResponseEntity<WorkbasketAccessItemListResource> response = template.exchange(
url + port + "/v1/workbasket-access-items", HttpMethod.GET, request, url + port + "/api/v1/workbasket-access-items", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() { ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
} }
@Test @Test
public void testGetWorkbasketAccessItemsKeepingFilters() { 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"; String parameters = "/api/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( ResponseEntity<WorkbasketAccessItemListResource> response = template.exchange(
url + port + parameters, HttpMethod.GET, request, url + port + parameters, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() { ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertTrue(response.getBody() assertTrue(response.getBody()
.getLink(Link.REL_SELF) .getLink(Link.REL_SELF)
@ -87,10 +84,9 @@ public class WorkbasketAccessItemControllerIntTest {
try { try {
template.exchange( template.exchange(
url + port 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, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() { ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
});
fail(); fail();
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
@ -100,11 +96,10 @@ public class WorkbasketAccessItemControllerIntTest {
@Test @Test
public void testGetSecondPageSortedByWorkbasketKey() { 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"; String parameters = "/api/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( ResponseEntity<WorkbasketAccessItemPaginatedListResource> response = template.exchange(
url + port + parameters, HttpMethod.GET, request, url + port + parameters, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() { ParameterizedTypeReference.forType(WorkbasketAccessItemPaginatedListResource.class));
});
assertEquals(1, response.getBody().getContent().size()); assertEquals(1, response.getBody().getContent().size());
assertEquals("user_1_1", response.getBody().getContent().iterator().next().accessId); assertEquals("user_1_1", response.getBody().getContent().iterator().next().accessId);
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
@ -123,23 +118,21 @@ public class WorkbasketAccessItemControllerIntTest {
@Test @Test
public void testRemoveWorkbasketAccessItemsOfUser() { 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( ResponseEntity<Void> response = template.exchange(
url + port + parameters, HttpMethod.DELETE, request, url + port + parameters, HttpMethod.DELETE, request,
new ParameterizedTypeReference<Void>() { ParameterizedTypeReference.forType(Void.class));
});
assertNull(response.getBody()); assertNull(response.getBody());
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
} }
@Test @Test
public void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() { 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 { try {
ResponseEntity<Void> response = template.exchange( ResponseEntity<Void> response = template.exchange(
url + port + parameters, HttpMethod.DELETE, request, url + port + parameters, HttpMethod.DELETE, request,
new ParameterizedTypeReference<Void>() { ParameterizedTypeReference.forType(Void.class));
});
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
} }
@ -159,7 +152,7 @@ public class WorkbasketAccessItemControllerIntTest {
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template; return template;
} }
} }

View File

@ -17,8 +17,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; 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.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.rest.resource.DistributionTargetListResource;
import pro.taskana.rest.resource.DistributionTargetResource; import pro.taskana.rest.resource.DistributionTargetResource;
import pro.taskana.rest.resource.WorkbasketSummaryResource; import pro.taskana.rest.resource.WorkbasketSummaryListResource;
/** /**
* Test WorkbasketController. * Test WorkbasketController.
*
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
@ -63,30 +61,27 @@ public class WorkbasketControllerIntTest {
@Test @Test
public void testGetAllWorkbaskets() { public void testGetAllWorkbaskets() {
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange( ResponseEntity<WorkbasketSummaryListResource> response = template.exchange(
url + port + "/v1/workbaskets", HttpMethod.GET, request, url + port + "/api/v1/workbaskets", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() { ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
} }
@Test @Test
public void testGetAllWorkbasketsBusinessAdminHasOpenPermission() { public void testGetAllWorkbasketsBusinessAdminHasOpenPermission() {
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange( ResponseEntity<WorkbasketSummaryListResource> response = template.exchange(
url + port + "/v1/workbaskets?required-permission=OPEN", HttpMethod.GET, request, url + port + "/api/v1/workbaskets?required-permission=OPEN", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() { ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(3, response.getBody().getContent().size()); assertEquals(3, response.getBody().getContent().size());
} }
@Test @Test
public void testGetAllWorkbasketsKeepingFilters() { public void testGetAllWorkbasketsKeepingFilters() {
String parameters = "/v1/workbaskets?type=PERSONAL&sort-by=key&order=desc"; String parameters = "/api/v1/workbaskets?type=PERSONAL&sort-by=key&order=desc";
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange( ResponseEntity<WorkbasketSummaryListResource> response = template.exchange(
url + port + parameters, HttpMethod.GET, request, url + port + parameters, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() { ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
});
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertTrue(response.getBody() assertTrue(response.getBody()
.getLink(Link.REL_SELF) .getLink(Link.REL_SELF)
@ -98,9 +93,8 @@ public class WorkbasketControllerIntTest {
public void testThrowsExceptionIfInvalidFilterIsUsed() { public void testThrowsExceptionIfInvalidFilterIsUsed() {
try { try {
template.exchange( template.exchange(
url + port + "/v1/workbaskets?invalid=PERSONAL", HttpMethod.GET, request, url + port + "/api/v1/workbaskets?invalid=PERSONAL", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() { ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
});
fail(); fail();
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
@ -111,11 +105,10 @@ public class WorkbasketControllerIntTest {
@Test @Test
public void testGetSecondPageSortedByKey() { public void testGetSecondPageSortedByKey() {
String parameters = "/v1/workbaskets?sort-by=key&order=desc&page=2&page-size=5"; String parameters = "/api/v1/workbaskets?sort-by=key&order=desc&page=2&page-size=5";
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange( ResponseEntity<WorkbasketSummaryListResource> response = template.exchange(
url + port + parameters, HttpMethod.GET, request, url + port + parameters, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() { ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
});
assertEquals(5, response.getBody().getContent().size()); assertEquals(5, response.getBody().getContent().size());
assertEquals("USER_1_1", response.getBody().getContent().iterator().next().getKey()); assertEquals("USER_1_1", response.getBody().getContent().iterator().next().getKey());
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertNotNull(response.getBody().getLink(Link.REL_SELF));
@ -131,17 +124,16 @@ public class WorkbasketControllerIntTest {
@Test @Test
public void testRemoveWorkbasketAsDistributionTarget() { public void testRemoveWorkbasketAsDistributionTarget() {
String parameters = "/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007"; String parameters = "/api/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007";
ResponseEntity<?> response = template.exchange( ResponseEntity<?> response = template.exchange(
url + port + parameters, HttpMethod.DELETE, request, url + port + parameters, HttpMethod.DELETE, request,
Void.class); Void.class);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
ResponseEntity<Resources<DistributionTargetResource>> response2 = template.exchange( ResponseEntity<DistributionTargetListResource> response2 = template.exchange(
url + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets", url + port + "/api/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets",
HttpMethod.GET, request, HttpMethod.GET, request,
new ParameterizedTypeReference<Resources<DistributionTargetResource>>() { ParameterizedTypeReference.forType(DistributionTargetListResource.class));
});
assertEquals(HttpStatus.OK, response2.getStatusCode()); assertEquals(HttpStatus.OK, response2.getStatusCode());
Iterator<DistributionTargetResource> iterator = response2.getBody().getContent().iterator(); Iterator<DistributionTargetResource> iterator = response2.getBody().getContent().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {

View File

@ -43,6 +43,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.rest.resource.WorkbasketDefinitionResource; import pro.taskana.rest.resource.WorkbasketDefinitionResource;
/** /**
* Integration tests for WorkbasketDefinitionController. * Integration tests for WorkbasketDefinitionController.
*/ */
@ -70,9 +71,8 @@ public class WorkbasketDefinitionControllerIntTest {
@Test @Test
public void testExportWorkbasketFromDomain() { public void testExportWorkbasketFromDomain() {
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange( 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>>() { new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {
}); });
assertNotNull(response.getBody()); assertNotNull(response.getBody());
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
@ -97,31 +97,27 @@ public class WorkbasketDefinitionControllerIntTest {
@Test @Test
public void testExportWorkbasketsFromWrongDomain() { public void testExportWorkbasketsFromWrongDomain() {
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange( ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange(
server + port + "/v1/workbasket-definitions?domain=wrongDomain", server + port + "/api/v1/workbasket-definitions?domain=wrongDomain",
HttpMethod.GET, request, new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() { HttpMethod.GET, request, ParameterizedTypeReference.forType(List.class));
});
assertEquals(0, response.getBody().size()); assertEquals(0, response.getBody().size());
} }
@Test @Test
public void testImportWorkbasket() throws IOException { public void testImportWorkbasket() throws IOException {
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange( 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>>() { HttpMethod.GET, request, ParameterizedTypeReference.forType(List.class));
});
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add(objMapper.writeValueAsString(response.getBody().get(0))); list.add(objMapper.writeValueAsString(response.getBody().get(0)));
ResponseEntity<String> responseImport = importRequest(list); ResponseEntity<Void> responseImport = importRequest(list);
assertEquals(HttpStatus.OK, responseImport.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, responseImport.getStatusCode());
} }
@Test @Test
public void testFailOnImportDuplicates() throws IOException { public void testFailOnImportDuplicates() throws IOException {
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange( 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>>() { HttpMethod.GET, request, new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {
}); });
@ -141,9 +137,8 @@ public class WorkbasketDefinitionControllerIntTest {
public void testNoErrorWhenImportWithSameIdButDifferentKeyAndDomain() public void testNoErrorWhenImportWithSameIdButDifferentKeyAndDomain()
throws IOException { throws IOException {
ResponseEntity<List<WorkbasketDefinitionResource>> response = template.exchange( 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>>() { HttpMethod.GET, request, new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {
}); });
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
@ -151,11 +146,11 @@ public class WorkbasketDefinitionControllerIntTest {
list.add(objMapper.writeValueAsString(wbDef)); list.add(objMapper.writeValueAsString(wbDef));
wbDef.getWorkbasket().setKey("new Key for this WB"); wbDef.getWorkbasket().setKey("new Key for this WB");
list.add(objMapper.writeValueAsString(wbDef)); list.add(objMapper.writeValueAsString(wbDef));
ResponseEntity<String> responseImport = importRequest(list); ResponseEntity<Void> responseImport = importRequest(list);
assertEquals(HttpStatus.OK, responseImport.getStatusCode()); 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"); File tmpFile = File.createTempFile("test", ".tmp");
FileWriter writer = new FileWriter(tmpFile); FileWriter writer = new FileWriter(tmpFile);
writer.write(clList.toString()); writer.write(clList.toString());
@ -166,10 +161,10 @@ public class WorkbasketDefinitionControllerIntTest {
body.add("file", new FileSystemResource(tmpFile)); body.add("file", new FileSystemResource(tmpFile));
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); 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(); 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.setSupportedMediaTypes(MediaType.parseMediaTypes("application/haljson,*/*"));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); return new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
} }
} }

View File

@ -31,8 +31,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.rest.resource.TaskanaUserInfoResource; 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. * This test class is configured to run with postgres DB if you want to run it with h2 it is needed. to change data
* to change data source configuration at project-defaults.yml. * source configuration at project-defaults.yml.
*/ */
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
public class TaskanaWildflyTest { public class TaskanaWildflyTest {
@ -43,7 +43,8 @@ public class TaskanaWildflyTest {
File[] files = Maven.resolver() File[] files = Maven.resolver()
.loadPomFromFile("pom.xml") .loadPomFromFile("pom.xml")
.importRuntimeDependencies() .importRuntimeDependencies()
.resolve().withTransitivity() .resolve()
.withTransitivity()
.asFile(); .asFile();
return ShrinkWrap.create(WebArchive.class, "taskana.war") return ShrinkWrap.create(WebArchive.class, "taskana.war")
@ -61,10 +62,8 @@ public class TaskanaWildflyTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<TaskanaUserInfoResource> response = getRestTemplate().exchange( ResponseEntity<TaskanaUserInfoResource> response = getRestTemplate().exchange(
"http://127.0.0.1:" + "8090" + "/v1/current-user-info", HttpMethod.GET, request, "http://127.0.0.1:" + "8090" + "/api/v1/current-user-info", HttpMethod.GET, request,
new ParameterizedTypeReference<TaskanaUserInfoResource>() { ParameterizedTypeReference.forType(TaskanaUserInfoResource.class));
});
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
} }
@ -77,7 +76,7 @@ public class TaskanaWildflyTest {
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/json")); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/json"));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template; return template;
} }
} }

View File

@ -1,6 +1,5 @@
package pro.taskana.rest; package pro.taskana.rest;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -8,7 +7,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -27,7 +25,7 @@ import pro.taskana.rest.resource.AccessIdResource;
*/ */
@RestController @RestController
@EnableHypermediaSupport(type = HypermediaType.HAL) @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 { public class AccessIdController {
private static final Logger LOGGER = LoggerFactory.getLogger(AccessIdController.class); private static final Logger LOGGER = LoggerFactory.getLogger(AccessIdController.class);
@ -49,23 +47,22 @@ public class AccessIdController {
ResponseEntity<List<AccessIdResource>> response; ResponseEntity<List<AccessIdResource>> response;
if (ldapClient.useLdap()) { if (ldapClient.useLdap()) {
List<AccessIdResource> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor); List<AccessIdResource> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor);
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK); response = ResponseEntity.ok(accessIdUsers);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from validateAccessIds(), returning {}", response); LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
} }
return response; return response;
} else if (ldapCache != null) { } else if (ldapCache != null) {
response = new ResponseEntity<>( response = ResponseEntity.ok(
ldapCache.findMatchingAccessId(searchFor, ldapClient.getMaxNumberOfReturnedAccessIds()), ldapCache.findMatchingAccessId(searchFor, ldapClient.getMaxNumberOfReturnedAccessIds()));
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from validateAccessIds(), returning {}", response); LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
} }
return response; return response;
} else { } else {
response = new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND); response = ResponseEntity.notFound().build();
LOGGER.debug("Exit from validateAccessIds(), returning {}", response); LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
return response; return response;
} }
@ -85,7 +82,7 @@ public class AccessIdController {
if (ldapClient.useLdap()) { if (ldapClient.useLdap()) {
accessIdUsers = ldapClient.searchUsersAndGroups(accessId); accessIdUsers = ldapClient.searchUsersAndGroups(accessId);
accessIdUsers.addAll(ldapClient.searchGroupsofUsersIsMember(accessId)); accessIdUsers.addAll(ldapClient.searchGroupsofUsersIsMember(accessId));
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK); response = ResponseEntity.ok(accessIdUsers);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response); LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
} }
@ -93,14 +90,14 @@ public class AccessIdController {
return response; return response;
} else if (ldapCache != null) { } else if (ldapCache != null) {
accessIdUsers = ldapCache.findGroupsOfUser(accessId, ldapClient.getMaxNumberOfReturnedAccessIds()); accessIdUsers = ldapCache.findGroupsOfUser(accessId, ldapClient.getMaxNumberOfReturnedAccessIds());
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK); response = ResponseEntity.ok(accessIdUsers);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response); LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
} }
return response; return response;
} else { } else {
response = new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND); response = ResponseEntity.notFound().build();
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response); LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
return response; return response;
} }

View File

@ -4,7 +4,6 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.PagedResources.PageMetadata; import org.springframework.hateoas.PagedResources.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
@ -36,7 +35,7 @@ import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationResource;
import pro.taskana.rest.resource.ClassificationResourceAssembler; import pro.taskana.rest.resource.ClassificationResourceAssembler;
import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.ClassificationSummaryListResource;
import pro.taskana.rest.resource.ClassificationSummaryResourceAssembler; import pro.taskana.rest.resource.ClassificationSummaryResourceAssembler;
/** /**
@ -44,7 +43,7 @@ import pro.taskana.rest.resource.ClassificationSummaryResourceAssembler;
*/ */
@RestController @RestController
@EnableHypermediaSupport(type = HypermediaType.HAL) @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 { public class ClassificationController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class);
@ -100,7 +99,7 @@ public class ClassificationController extends AbstractPagingController {
@GetMapping @GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<PagedResources<ClassificationSummaryResource>> getClassifications( public ResponseEntity<ClassificationSummaryListResource> getClassifications(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException { @RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getClassifications(params= {})", params); LOGGER.debug("Entry to getClassifications(params= {})", params);
@ -113,14 +112,12 @@ public class ClassificationController extends AbstractPagingController {
PageMetadata pageMetadata = getPageMetadata(params, query); PageMetadata pageMetadata = getPageMetadata(params, query);
List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata); List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata);
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = new ResponseEntity<>( ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity.ok(
classificationSummaryResourceAssembler.toResources( classificationSummaryResourceAssembler.toResources(
classificationSummaries, classificationSummaries,
pageMetadata), pageMetadata));
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassifications(), returning {}", LOGGER.debug("Exit from getClassifications(), returning {}", response);
new ResponseEntity<>(response, HttpStatus.OK));
} }
return response; return response;
@ -135,11 +132,10 @@ public class ClassificationController extends AbstractPagingController {
} }
Classification classification = classificationService.getClassification(classificationId); Classification classification = classificationService.getClassification(classificationId);
ResponseEntity<ClassificationResource> response = new ResponseEntity<>( ResponseEntity<ClassificationResource> response = ResponseEntity.ok(
classificationResourceAssembler.toResource(classification), HttpStatus.OK); classificationResourceAssembler.toResource(classification));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassification(), returning {}", LOGGER.debug("Exit from getClassification(), returning {}", response);
ResponseEntity.status(HttpStatus.OK).body(classificationResourceAssembler.toResource(classification)));
} }
return response; return response;
@ -157,8 +153,8 @@ public class ClassificationController extends AbstractPagingController {
Classification classification = classificationResourceAssembler.toModel(resource); Classification classification = classificationResourceAssembler.toModel(resource);
classification = classificationService.createClassification(classification); classification = classificationService.createClassification(classification);
ResponseEntity<ClassificationResource> response = new ResponseEntity<>( ResponseEntity<ClassificationResource> response = ResponseEntity.status(HttpStatus.CREATED)
classificationResourceAssembler.toResource(classification), HttpStatus.CREATED); .body(classificationResourceAssembler.toResource(classification));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createClassification(), returning {}", response); LOGGER.debug("Exit from createClassification(), returning {}", response);
} }
@ -181,7 +177,7 @@ public class ClassificationController extends AbstractPagingController {
if (classificationId.equals(resource.classificationId)) { if (classificationId.equals(resource.classificationId)) {
Classification classification = classificationResourceAssembler.toModel(resource); Classification classification = classificationResourceAssembler.toModel(resource);
classification = classificationService.updateClassification(classification); classification = classificationService.updateClassification(classification);
result = new ResponseEntity<>(classificationResourceAssembler.toResource(classification), HttpStatus.OK); result = ResponseEntity.ok(classificationResourceAssembler.toResource(classification));
} else { } else {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"ClassificationId ('" + classificationId "ClassificationId ('" + classificationId
@ -201,7 +197,7 @@ public class ClassificationController extends AbstractPagingController {
throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException { throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException {
LOGGER.debug("Entry to deleteClassification(classificationId= {})", classificationId); LOGGER.debug("Entry to deleteClassification(classificationId= {})", classificationId);
classificationService.deleteClassification(classificationId); classificationService.deleteClassification(classificationId);
ResponseEntity<?> response = new ResponseEntity<>(HttpStatus.NO_CONTENT); ResponseEntity<?> response = ResponseEntity.noContent().build();
LOGGER.debug("Exit from deleteClassification(), returning {}", response); LOGGER.debug("Exit from deleteClassification(), returning {}", response);
return response; return response;
} }

View File

@ -12,7 +12,6 @@ import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -45,7 +44,7 @@ import pro.taskana.rest.resource.ClassificationResourceAssembler;
* Controller for Importing / Exporting classifications. * Controller for Importing / Exporting classifications.
*/ */
@RestController @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 { public class ClassificationDefinitionController {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationDefinitionController.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationDefinitionController.class);
@ -79,7 +78,7 @@ public class ClassificationDefinitionController {
export.add(classificationResourceAssembler.toDefinition(classification)); export.add(classificationResourceAssembler.toDefinition(classification));
} }
ResponseEntity<List<ClassificationResource>> response = new ResponseEntity<>(export, HttpStatus.OK); ResponseEntity<List<ClassificationResource>> response = ResponseEntity.ok(export);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from exportClassifications(), returning {}", response); LOGGER.debug("Exit from exportClassifications(), returning {}", response);
} }
@ -89,7 +88,7 @@ public class ClassificationDefinitionController {
@PostMapping @PostMapping
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<String> importClassifications( public ResponseEntity<Void> importClassifications(
@RequestParam("file") MultipartFile file) @RequestParam("file") MultipartFile file)
throws InvalidArgumentException, NotAuthorizedException, ConcurrencyException, ClassificationNotFoundException, throws InvalidArgumentException, NotAuthorizedException, ConcurrencyException, ClassificationNotFoundException,
ClassificationAlreadyExistException, DomainNotFoundException, IOException { ClassificationAlreadyExistException, DomainNotFoundException, IOException {
@ -101,7 +100,7 @@ public class ClassificationDefinitionController {
Map<Classification, String> childrenInFile = mapChildrenToParentKeys(classificationsResources, systemIds); Map<Classification, String> childrenInFile = mapChildrenToParentKeys(classificationsResources, systemIds);
insertOrUpdateClassificationsWithoutParent(classificationsResources, systemIds); insertOrUpdateClassificationsWithoutParent(classificationsResources, systemIds);
updateParentChildrenRelations(childrenInFile); updateParentChildrenRelations(childrenInFile);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK); ResponseEntity<Void> response = ResponseEntity.noContent().build();
LOGGER.debug("Exit from importClassifications(), returning {}", response); LOGGER.debug("Exit from importClassifications(), returning {}", response);
return response; return response;
} }
@ -137,7 +136,8 @@ public class ClassificationDefinitionController {
} }
} }
if (!duplicates.isEmpty()) { 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());
} }
} }

View File

@ -28,7 +28,7 @@ import pro.taskana.rest.resource.ReportResourceAssembler;
* Controller for all monitoring endpoints. * Controller for all monitoring endpoints.
*/ */
@RestController @RestController
@RequestMapping(path = "/v1/monitor", produces = "application/hal+json") @RequestMapping(path = "/api/v1/monitor", produces = "application/hal+json")
public class MonitorController { public class MonitorController {
private static final Logger LOGGER = LoggerFactory.getLogger(MonitorController.class); private static final Logger LOGGER = LoggerFactory.getLogger(MonitorController.class);
@ -48,9 +48,9 @@ public class MonitorController {
@RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException, @RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException,
InvalidArgumentException { InvalidArgumentException {
LOGGER.debug("Entry to getTasksStatusReport()"); 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(), taskMonitorService.createTaskStatusReportBuilder().stateIn(states).domainIn(domains).buildReport(),
domains, states), HttpStatus.OK); domains, states));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response); LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
} }
@ -68,7 +68,8 @@ public class MonitorController {
ReportResource report = reportResourceAssembler.toResource( ReportResource report = reportResourceAssembler.toResource(
taskMonitorService.createWorkbasketReportBuilder() taskMonitorService.createWorkbasketReportBuilder()
.withColumnHeaders(getRangeTimeInterval()) .withColumnHeaders(getRangeTimeInterval())
.buildReport(), states); .buildReport(),
states);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksWorkbasketReport(), returning {}", report); LOGGER.debug("Exit from getTasksWorkbasketReport(), returning {}", report);
@ -90,7 +91,8 @@ public class MonitorController {
ReportResource report = reportResourceAssembler.toResource( ReportResource report = reportResourceAssembler.toResource(
taskMonitorService.createWorkbasketReportBuilder() taskMonitorService.createWorkbasketReportBuilder()
.stateIn(states) .stateIn(states)
.withColumnHeaders(getDateTimeInterval(daysInPast)).buildPlannedDateBasedReport(), .withColumnHeaders(getDateTimeInterval(daysInPast))
.buildPlannedDateBasedReport(),
daysInPast, states); daysInPast, states);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksWorkbasketPlannedDateReport(), returning {}", report); LOGGER.debug("Exit from getTasksWorkbasketPlannedDateReport(), returning {}", report);
@ -101,7 +103,6 @@ public class MonitorController {
} }
@GetMapping(path = "/tasks-classification-report") @GetMapping(path = "/tasks-classification-report")
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ReportResource> getTasksClassificationReport() public ResponseEntity<ReportResource> getTasksClassificationReport()
@ -138,14 +139,11 @@ public class MonitorController {
private List<TimeIntervalColumnHeader> getRangeTimeInterval() { private List<TimeIntervalColumnHeader> getRangeTimeInterval() {
return Stream.concat(Stream.concat( return Stream.concat(Stream.concat(
Stream.of(new TimeIntervalColumnHeader.Range(Integer.MIN_VALUE, -10), 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) 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), Stream.of(new TimeIntervalColumnHeader.Range(5, 10),
new TimeIntervalColumnHeader.Range(10, Integer.MAX_VALUE) new TimeIntervalColumnHeader.Range(10, Integer.MAX_VALUE)))
))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }

View File

@ -5,7 +5,6 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.PagedResources.PageMetadata; import org.springframework.hateoas.PagedResources.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
@ -42,7 +41,7 @@ import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskResource;
import pro.taskana.rest.resource.TaskResourceAssembler; import pro.taskana.rest.resource.TaskResourceAssembler;
import pro.taskana.rest.resource.TaskSummaryResource; import pro.taskana.rest.resource.TaskSummaryListResource;
import pro.taskana.rest.resource.TaskSummaryResourceAssembler; import pro.taskana.rest.resource.TaskSummaryResourceAssembler;
/** /**
@ -50,7 +49,7 @@ import pro.taskana.rest.resource.TaskSummaryResourceAssembler;
*/ */
@RestController @RestController
@EnableHypermediaSupport(type = HypermediaType.HAL) @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 { public class TaskController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskController.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskController.class);
@ -89,8 +88,7 @@ public class TaskController extends AbstractPagingController {
TaskController( TaskController(
TaskService taskService, TaskService taskService,
TaskResourceAssembler taskResourceAssembler, TaskResourceAssembler taskResourceAssembler,
TaskSummaryResourceAssembler taskSummaryResourceAssembler TaskSummaryResourceAssembler taskSummaryResourceAssembler) {
) {
this.taskService = taskService; this.taskService = taskService;
this.taskResourceAssembler = taskResourceAssembler; this.taskResourceAssembler = taskResourceAssembler;
this.taskSummaryResourceAssembler = taskSummaryResourceAssembler; this.taskSummaryResourceAssembler = taskSummaryResourceAssembler;
@ -98,7 +96,7 @@ public class TaskController extends AbstractPagingController {
@GetMapping @GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<PagedResources<TaskSummaryResource>> getTasks( public ResponseEntity<TaskSummaryListResource> getTasks(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException { @RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getTasks(params= {})", params); LOGGER.debug("Entry to getTasks(params= {})", params);
@ -111,9 +109,9 @@ public class TaskController extends AbstractPagingController {
PageMetadata pageMetadata = getPageMetadata(params, query); PageMetadata pageMetadata = getPageMetadata(params, query);
List<TaskSummary> taskSummaries = getQueryList(query, pageMetadata); List<TaskSummary> taskSummaries = getQueryList(query, pageMetadata);
PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourceAssembler.toResources(taskSummaries, TaskSummaryListResource pagedResources = taskSummaryResourceAssembler.toResources(taskSummaries,
pageMetadata); pageMetadata);
ResponseEntity<PagedResources<TaskSummaryResource>> response = new ResponseEntity<>(pagedResources, HttpStatus.OK); ResponseEntity<TaskSummaryListResource> response = ResponseEntity.ok(pagedResources);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasks(), returning {}", response); LOGGER.debug("Exit from getTasks(), returning {}", response);
} }
@ -127,8 +125,7 @@ public class TaskController extends AbstractPagingController {
throws TaskNotFoundException, NotAuthorizedException { throws TaskNotFoundException, NotAuthorizedException {
LOGGER.debug("Entry to getTask(taskId= {})", taskId); LOGGER.debug("Entry to getTask(taskId= {})", taskId);
Task task = taskService.getTask(taskId); Task task = taskService.getTask(taskId);
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(task), ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(task));
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTask(), returning {}", result); LOGGER.debug("Exit from getTask(), returning {}", result);
} }
@ -144,8 +141,7 @@ public class TaskController extends AbstractPagingController {
// TODO verify user // TODO verify user
taskService.claim(taskId); taskService.claim(taskId);
Task updatedTask = taskService.getTask(taskId); Task updatedTask = taskService.getTask(taskId);
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask), ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from claimTask(), returning {}", result); LOGGER.debug("Exit from claimTask(), returning {}", result);
} }
@ -160,8 +156,7 @@ public class TaskController extends AbstractPagingController {
LOGGER.debug("Entry to completeTask(taskId= {})", taskId); LOGGER.debug("Entry to completeTask(taskId= {})", taskId);
taskService.forceCompleteTask(taskId); taskService.forceCompleteTask(taskId);
Task updatedTask = taskService.getTask(taskId); Task updatedTask = taskService.getTask(taskId);
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask), ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from completeTask(), returning {}", result); LOGGER.debug("Exit from completeTask(), returning {}", result);
} }
@ -175,7 +170,7 @@ public class TaskController extends AbstractPagingController {
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
LOGGER.debug("Entry to deleteTask(taskId= {})", taskId); LOGGER.debug("Entry to deleteTask(taskId= {})", taskId);
taskService.forceDeleteTask(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); LOGGER.debug("Exit from deleteTask(), returning {}", result);
return result; return result;
} }
@ -190,8 +185,8 @@ public class TaskController extends AbstractPagingController {
} }
Task createdTask = taskService.createTask(taskResourceAssembler.toModel(taskResource)); Task createdTask = taskService.createTask(taskResourceAssembler.toModel(taskResource));
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(createdTask), ResponseEntity<TaskResource> result = ResponseEntity.status(HttpStatus.CREATED)
HttpStatus.CREATED); .body(taskResourceAssembler.toResource(createdTask));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createTask(), returning {}", result); LOGGER.debug("Exit from createTask(), returning {}", result);
} }
@ -205,8 +200,7 @@ public class TaskController extends AbstractPagingController {
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException { throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException {
LOGGER.debug("Entry to transferTask(taskId= {}, workbasketId= {})", taskId, workbasketId); LOGGER.debug("Entry to transferTask(taskId= {}, workbasketId= {})", taskId, workbasketId);
Task updatedTask = taskService.transfer(taskId, workbasketId); Task updatedTask = taskService.transfer(taskId, workbasketId);
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask), ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from transferTask(), returning {}", result); LOGGER.debug("Exit from transferTask(), returning {}", result);
} }

View File

@ -1,13 +1,16 @@
package pro.taskana.rest; package pro.taskana.rest;
import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole; import pro.taskana.TaskanaRole;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
@ -16,12 +19,11 @@ import pro.taskana.rest.resource.TaskanaUserInfoResource;
import pro.taskana.rest.resource.VersionResource; import pro.taskana.rest.resource.VersionResource;
import pro.taskana.security.CurrentUserContext; import pro.taskana.security.CurrentUserContext;
import java.util.List;
/** /**
* Controller for TaskanaEngine related tasks. * Controller for TaskanaEngine related tasks.
*/ */
@RestController @RestController
@RequestMapping(path = "/api/v1", produces = MediaType.APPLICATION_JSON_VALUE)
public class TaskanaEngineController { public class TaskanaEngineController {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineController.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineController.class);
@ -40,46 +42,44 @@ public class TaskanaEngineController {
@Value("${version:Local build}") @Value("${version:Local build}")
private String version; private String version;
@GetMapping(path = "/v1/domains", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/domains")
public ResponseEntity<List<String>> getDomains() { public ResponseEntity<List<String>> getDomains() {
ResponseEntity<List<String>> response = new ResponseEntity<>(taskanaEngineConfiguration.getDomains(), ResponseEntity<List<String>> response = ResponseEntity.ok(taskanaEngineConfiguration.getDomains());
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getDomains(), returning {}", response); LOGGER.debug("Exit from getDomains(), returning {}", response);
} }
return response; return response;
} }
@GetMapping(path = "/v1/classification-categories", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/classification-categories")
public ResponseEntity<List<String>> getClassificationCategories(String type) { public ResponseEntity<List<String>> getClassificationCategories(String type) {
LOGGER.debug("Entry to getClassificationCategories(type = {})", type); LOGGER.debug("Entry to getClassificationCategories(type = {})", type);
ResponseEntity<List<String>> response; ResponseEntity<List<String>> response;
if (type != null) { if (type != null) {
response = new ResponseEntity<>(taskanaEngineConfiguration.getClassificationCategoriesByType(type), response = ResponseEntity.ok(taskanaEngineConfiguration.getClassificationCategoriesByType(type));
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassificationCategories(), returning {}", response); LOGGER.debug("Exit from getClassificationCategories(), returning {}", response);
} }
return response; return response;
} }
response = new ResponseEntity<>(taskanaEngineConfiguration.getAllClassificationCategories(), HttpStatus.OK); response = ResponseEntity.ok(taskanaEngineConfiguration.getAllClassificationCategories());
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassificationCategories(), returning {}", response); LOGGER.debug("Exit from getClassificationCategories(), returning {}", response);
} }
return response; return response;
} }
@GetMapping(path = "/v1/classification-types", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/classification-types")
public ResponseEntity<List<String>> getClassificationTypes() { public ResponseEntity<List<String>> getClassificationTypes() {
ResponseEntity<List<String>> response = new ResponseEntity<>( ResponseEntity<List<String>> response = ResponseEntity.ok(
taskanaEngineConfiguration.getClassificationTypes(), HttpStatus.OK); taskanaEngineConfiguration.getClassificationTypes());
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassificationTypes(), returning {}", response); LOGGER.debug("Exit from getClassificationTypes(), returning {}", response);
} }
return response; return response;
} }
@GetMapping(path = "/v1/current-user-info", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/current-user-info")
public ResponseEntity<TaskanaUserInfoResource> getCurrentUserInfo() { public ResponseEntity<TaskanaUserInfoResource> getCurrentUserInfo() {
LOGGER.debug("Entry to getCurrentUserInfo()"); LOGGER.debug("Entry to getCurrentUserInfo()");
TaskanaUserInfoResource resource = new TaskanaUserInfoResource(); TaskanaUserInfoResource resource = new TaskanaUserInfoResource();
@ -90,7 +90,7 @@ public class TaskanaEngineController {
resource.getRoles().add(role); resource.getRoles().add(role);
} }
} }
ResponseEntity<TaskanaUserInfoResource> response = new ResponseEntity<>(resource, HttpStatus.OK); ResponseEntity<TaskanaUserInfoResource> response = ResponseEntity.ok(resource);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getCurrentUserInfo(), returning {}", response); LOGGER.debug("Exit from getCurrentUserInfo(), returning {}", response);
} }
@ -98,11 +98,10 @@ public class TaskanaEngineController {
return response; return response;
} }
@GetMapping(path = "/v1/history-provider-enabled", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/history-provider-enabled")
public ResponseEntity<Boolean> getIsHistoryProviderEnabled() { public ResponseEntity<Boolean> getIsHistoryProviderEnabled() {
ResponseEntity<Boolean> response = new ResponseEntity<>( ResponseEntity<Boolean> response = ResponseEntity.ok(
((TaskanaEngineImpl) taskanaEngine).getHistoryEventProducer().isEnabled(), ((TaskanaEngineImpl) taskanaEngine).getHistoryEventProducer().isEnabled());
HttpStatus.OK);
LOGGER.debug("Exit from getIsHistoryProviderEnabled(), returning {}", response); LOGGER.debug("Exit from getIsHistoryProviderEnabled(), returning {}", response);
return response; return response;
} }
@ -112,12 +111,12 @@ public class TaskanaEngineController {
* *
* @return The current version. * @return The current version.
*/ */
@GetMapping(path = "/v1/version", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/version")
public ResponseEntity<VersionResource> currentVersion() { public ResponseEntity<VersionResource> currentVersion() {
LOGGER.debug("Entry to currentVersion()"); LOGGER.debug("Entry to currentVersion()");
VersionResource resource = new VersionResource(); VersionResource resource = new VersionResource();
resource.setVersion(TaskanaEngineConfiguration.class.getPackage().getImplementationVersion()); 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); LOGGER.debug("Exit from currentVersion(), returning {}", response);
return response; return response;
} }

View File

@ -130,7 +130,7 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
private ResponseEntity<Object> buildResponse(Exception ex, WebRequest req, HttpStatus status) { private ResponseEntity<Object> buildResponse(Exception ex, WebRequest req, HttpStatus status) {
TaskanaErrorData errorData = new TaskanaErrorData(status, ex, req); TaskanaErrorData errorData = new TaskanaErrorData(status, ex, req);
logError(ex, errorData); logError(ex, errorData);
return new ResponseEntity<>(errorData, status); return ResponseEntity.status(status).body(errorData);
} }
private void logError(Exception ex, TaskanaErrorData errorData) { private void logError(Exception ex, TaskanaErrorData errorData) {

View File

@ -9,7 +9,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedResources; import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
@ -25,7 +24,7 @@ import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.ldap.LdapClient; import pro.taskana.ldap.LdapClient;
import pro.taskana.rest.resource.WorkbasketAccessItemResource; import pro.taskana.rest.resource.WorkbasketAccessItemPaginatedListResource;
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler; import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
/** /**
@ -33,7 +32,7 @@ import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
*/ */
@RestController @RestController
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL) @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 { public class WorkbasketAccessItemController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketAccessItemController.class); 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. * 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. * @return all WorkbasketAccesItemResource.
* @throws NotAuthorizedException if the user is not authorized. * @throws NotAuthorizedException
* @throws InvalidArgumentException if some argument is invalid. * if the user is not authorized.
* @throws InvalidArgumentException
* if some argument is invalid.
*/ */
@GetMapping @GetMapping
public ResponseEntity<PagedResources<WorkbasketAccessItemResource>> getWorkbasketAccessItems( public ResponseEntity<WorkbasketAccessItemPaginatedListResource> getWorkbasketAccessItems(
@RequestParam MultiValueMap<String, String> params) @RequestParam MultiValueMap<String, String> params)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -81,13 +83,11 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
PagedResources.PageMetadata pageMetadata = getPageMetadata(params, query); PagedResources.PageMetadata pageMetadata = getPageMetadata(params, query);
List<WorkbasketAccessItem> workbasketAccessItems = getQueryList(query, pageMetadata); List<WorkbasketAccessItem> workbasketAccessItems = getQueryList(query, pageMetadata);
PagedResources<WorkbasketAccessItemResource> pagedResources = workbasketAccessItemResourceAssembler.toResources( WorkbasketAccessItemPaginatedListResource pagedResources = workbasketAccessItemResourceAssembler.toResources(
workbasketAccessItems, workbasketAccessItems,
pageMetadata pageMetadata);
);
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(pagedResources, ResponseEntity<WorkbasketAccessItemPaginatedListResource> response = ResponseEntity.ok(pagedResources);
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", response); 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. * 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. * @return ResponseEntity if the user is not authorized.
* @throws NotAuthorizedException if the user is not authorized. * @throws NotAuthorizedException
* @throws InvalidArgumentException if some argument is invalid. * if the user is not authorized.
* @throws InvalidArgumentException
* if some argument is invalid.
*/ */
@DeleteMapping @DeleteMapping
public ResponseEntity<Void> removeWorkbasketAccessItems( 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"); 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); LOGGER.debug("Exit from removeWorkbasketAccessItems(), returning {}", response);
return response; return response;
} }

View File

@ -6,7 +6,6 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.PagedResources.PageMetadata; import org.springframework.hateoas.PagedResources.PageMetadata;
import org.springframework.hateoas.Resources; import org.springframework.hateoas.Resources;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
@ -41,13 +40,15 @@ import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketInUseException; import pro.taskana.exceptions.WorkbasketInUseException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.util.LoggerUtils; import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.rest.resource.DistributionTargetListResource;
import pro.taskana.rest.resource.DistributionTargetResource; import pro.taskana.rest.resource.DistributionTargetResource;
import pro.taskana.rest.resource.DistributionTargetResourceAssembler; import pro.taskana.rest.resource.DistributionTargetResourceAssembler;
import pro.taskana.rest.resource.WorkbasketAccessItemListResource;
import pro.taskana.rest.resource.WorkbasketAccessItemResource; import pro.taskana.rest.resource.WorkbasketAccessItemResource;
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler; import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
import pro.taskana.rest.resource.WorkbasketResource; import pro.taskana.rest.resource.WorkbasketResource;
import pro.taskana.rest.resource.WorkbasketResourceAssembler; import pro.taskana.rest.resource.WorkbasketResourceAssembler;
import pro.taskana.rest.resource.WorkbasketSummaryResource; import pro.taskana.rest.resource.WorkbasketSummaryListResource;
import pro.taskana.rest.resource.WorkbasketSummaryResourceAssembler; import pro.taskana.rest.resource.WorkbasketSummaryResourceAssembler;
/** /**
@ -55,7 +56,7 @@ import pro.taskana.rest.resource.WorkbasketSummaryResourceAssembler;
*/ */
@RestController @RestController
@EnableHypermediaSupport(type = HypermediaType.HAL) @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 { public class WorkbasketController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketController.class); private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketController.class);
@ -100,7 +101,7 @@ public class WorkbasketController extends AbstractPagingController {
@GetMapping @GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<PagedResources<WorkbasketSummaryResource>> getWorkbaskets( public ResponseEntity<WorkbasketSummaryListResource> getWorkbaskets(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException { @RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getWorkbaskets(params= {})", params); LOGGER.debug("Entry to getWorkbaskets(params= {})", params);
@ -112,11 +113,11 @@ public class WorkbasketController extends AbstractPagingController {
PageMetadata pageMetadata = getPageMetadata(params, query); PageMetadata pageMetadata = getPageMetadata(params, query);
List<WorkbasketSummary> workbasketSummaries = getQueryList(query, pageMetadata); List<WorkbasketSummary> workbasketSummaries = getQueryList(query, pageMetadata);
PagedResources<WorkbasketSummaryResource> pagedResources = workbasketSummaryResourceAssembler.toResources(workbasketSummaries, WorkbasketSummaryListResource pagedResources = workbasketSummaryResourceAssembler.toResources(
workbasketSummaries,
pageMetadata); pageMetadata);
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = new ResponseEntity<>(pagedResources, ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity.ok(pagedResources);
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbaskets(), returning {}", response); LOGGER.debug("Exit from getWorkbaskets(), returning {}", response);
} }
@ -131,7 +132,7 @@ public class WorkbasketController extends AbstractPagingController {
LOGGER.debug("Entry to getWorkbasket(workbasketId= {})", workbasketId); LOGGER.debug("Entry to getWorkbasket(workbasketId= {})", workbasketId);
ResponseEntity<WorkbasketResource> result; ResponseEntity<WorkbasketResource> result;
Workbasket workbasket = workbasketService.getWorkbasket(workbasketId); Workbasket workbasket = workbasketService.getWorkbasket(workbasketId);
result = new ResponseEntity<>(workbasketResourceAssembler.toResource(workbasket), HttpStatus.OK); result = ResponseEntity.ok(workbasketResourceAssembler.toResource(workbasket));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbasket(), returning {}", result); LOGGER.debug("Exit from getWorkbasket(), returning {}", result);
} }
@ -145,8 +146,7 @@ public class WorkbasketController extends AbstractPagingController {
throws NotAuthorizedException, InvalidArgumentException, throws NotAuthorizedException, InvalidArgumentException,
WorkbasketNotFoundException, WorkbasketInUseException { WorkbasketNotFoundException, WorkbasketInUseException {
LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId); LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId);
ResponseEntity<?> response = new ResponseEntity<>(workbasketService.deleteWorkbasket(workbasketId), ResponseEntity<?> response = ResponseEntity.accepted().body(workbasketService.deleteWorkbasket(workbasketId));
HttpStatus.ACCEPTED);
LOGGER.debug("Exit from markWorkbasketForDeletion(), returning {}", LOGGER.debug("Exit from markWorkbasketForDeletion(), returning {}",
response); response);
return response; return response;
@ -163,8 +163,8 @@ public class WorkbasketController extends AbstractPagingController {
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource); Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource);
workbasket = workbasketService.createWorkbasket(workbasket); workbasket = workbasketService.createWorkbasket(workbasket);
ResponseEntity<WorkbasketResource> response = new ResponseEntity<>( ResponseEntity<WorkbasketResource> response = ResponseEntity.status(HttpStatus.CREATED)
workbasketResourceAssembler.toResource(workbasket), HttpStatus.CREATED); .body(workbasketResourceAssembler.toResource(workbasket));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createWorkbasket(), returning {}", response); LOGGER.debug("Exit from createWorkbasket(), returning {}", response);
} }
@ -200,15 +200,14 @@ public class WorkbasketController extends AbstractPagingController {
@GetMapping(path = "/{workbasketId}/workbasketAccessItems") @GetMapping(path = "/{workbasketId}/workbasketAccessItems")
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<Resources<WorkbasketAccessItemResource>> getWorkbasketAccessItems( public ResponseEntity<WorkbasketAccessItemListResource> getWorkbasketAccessItems(
@PathVariable(value = "workbasketId") String workbasketId) @PathVariable(value = "workbasketId") String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug("Entry to getWorkbasketAccessItems(workbasketId= {})", workbasketId); LOGGER.debug("Entry to getWorkbasketAccessItems(workbasketId= {})", workbasketId);
ResponseEntity<Resources<WorkbasketAccessItemResource>> result; ResponseEntity<WorkbasketAccessItemListResource> result;
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(workbasketId); List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(workbasketId);
result = new ResponseEntity<>(workbasketAccessItemResourceAssembler result = ResponseEntity.ok(workbasketAccessItemResourceAssembler.toResources(workbasketId, accessItems));
.toResources(workbasketId, accessItems), HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result); LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result);
} }
@ -218,7 +217,7 @@ public class WorkbasketController extends AbstractPagingController {
@PutMapping(value = "/{workbasketId}/workbasketAccessItems") @PutMapping(value = "/{workbasketId}/workbasketAccessItems")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<Resources<WorkbasketAccessItemResource>> setWorkbasketAccessItems( public ResponseEntity<WorkbasketAccessItemListResource> setWorkbasketAccessItems(
@PathVariable(value = "workbasketId") String workbasketId, @PathVariable(value = "workbasketId") String workbasketId,
@RequestBody List<WorkbasketAccessItemResource> workbasketAccessResourceItems) @RequestBody List<WorkbasketAccessItemResource> workbasketAccessResourceItems)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
@ -233,9 +232,8 @@ public class WorkbasketController extends AbstractPagingController {
workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems); workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems);
List<WorkbasketAccessItem> updatedWbAccessItems = workbasketService.getWorkbasketAccessItems(workbasketId); List<WorkbasketAccessItem> updatedWbAccessItems = workbasketService.getWorkbasketAccessItems(workbasketId);
ResponseEntity<Resources<WorkbasketAccessItemResource>> response = new ResponseEntity<>( ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity.ok(
workbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler.toResources(workbasketId, updatedWbAccessItems));
.toResources(workbasketId, updatedWbAccessItems), HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response); LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response);
} }
@ -245,16 +243,15 @@ public class WorkbasketController extends AbstractPagingController {
@GetMapping(path = "/{workbasketId}/distribution-targets") @GetMapping(path = "/{workbasketId}/distribution-targets")
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<Resources<DistributionTargetResource>> getDistributionTargets( public ResponseEntity<DistributionTargetListResource> getDistributionTargets(
@PathVariable(value = "workbasketId") String workbasketId) @PathVariable(value = "workbasketId") String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId); LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId);
ResponseEntity<Resources<DistributionTargetResource>> result;
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasketId); List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasketId);
Resources<DistributionTargetResource> distributionTargetListResource = distributionTargetResourceAssembler DistributionTargetListResource distributionTargetListResource = distributionTargetResourceAssembler
.toResources(workbasketId, distributionTargets); .toResources(workbasketId, distributionTargets);
result = new ResponseEntity<>(distributionTargetListResource, HttpStatus.OK); ResponseEntity<DistributionTargetListResource> result = ResponseEntity.ok(distributionTargetListResource);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getDistributionTargets(), returning {}", result); LOGGER.debug("Exit from getDistributionTargets(), returning {}", result);
} }
@ -264,7 +261,7 @@ public class WorkbasketController extends AbstractPagingController {
@PutMapping(path = "/{workbasketId}/distribution-targets") @PutMapping(path = "/{workbasketId}/distribution-targets")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<Resources<DistributionTargetResource>> setDistributionTargetsForWorkbasketId( public ResponseEntity<DistributionTargetListResource> setDistributionTargetsForWorkbasketId(
@PathVariable(value = "workbasketId") String sourceWorkbasketId, @PathVariable(value = "workbasketId") String sourceWorkbasketId,
@RequestBody List<String> targetWorkbasketIds) throws WorkbasketNotFoundException, NotAuthorizedException { @RequestBody List<String> targetWorkbasketIds) throws WorkbasketNotFoundException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -276,9 +273,8 @@ public class WorkbasketController extends AbstractPagingController {
workbasketService.setDistributionTargets(sourceWorkbasketId, targetWorkbasketIds); workbasketService.setDistributionTargets(sourceWorkbasketId, targetWorkbasketIds);
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(sourceWorkbasketId); List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(sourceWorkbasketId);
ResponseEntity<Resources<DistributionTargetResource>> response = new ResponseEntity<>( ResponseEntity<DistributionTargetListResource> response = ResponseEntity.ok(
distributionTargetResourceAssembler distributionTargetResourceAssembler.toResources(sourceWorkbasketId, distributionTargets));
.toResources(sourceWorkbasketId, distributionTargets), HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response); LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
} }
@ -297,7 +293,7 @@ public class WorkbasketController extends AbstractPagingController {
workbasketService.removeDistributionTarget(source.getId(), targetWorkbasketId); 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); LOGGER.debug("Exit from removeDistributionTargetForWorkbasketId(), returning {}", response);
return response; return response;
} }

View File

@ -12,7 +12,6 @@ import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -47,7 +46,7 @@ import pro.taskana.rest.resource.WorkbasketResource;
* Controller for all {@link WorkbasketDefinitionResource} related endpoints. * Controller for all {@link WorkbasketDefinitionResource} related endpoints.
*/ */
@RestController @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 { public class WorkbasketDefinitionController {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketDefinitionController.class); private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketDefinitionController.class);
@ -58,8 +57,7 @@ public class WorkbasketDefinitionController {
WorkbasketDefinitionController( WorkbasketDefinitionController(
WorkbasketService workbasketService, WorkbasketService workbasketService,
WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler) {
) {
this.workbasketService = workbasketService; this.workbasketService = workbasketService;
this.workbasketDefinitionAssembler = workbasketDefinitionAssembler; this.workbasketDefinitionAssembler = workbasketDefinitionAssembler;
} }
@ -80,8 +78,7 @@ public class WorkbasketDefinitionController {
basketExports.add(workbasketDefinitionAssembler.toResource(workbasket)); basketExports.add(workbasketDefinitionAssembler.toResource(workbasket));
} }
ResponseEntity<List<WorkbasketDefinitionResource>> response = new ResponseEntity<>(basketExports, ResponseEntity<List<WorkbasketDefinitionResource>> response = ResponseEntity.ok(basketExports);
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from exportWorkbaskets(), returning {}", response); 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 * This method imports a <b>list of {@link WorkbasketDefinitionResource}</b>. This does not exactly match the REST
* we want to have an option to import all settings at once. When a logical equal (key and domain are equal) * norm, but we want to have an option to import all settings at once. When a logical equal (key and domain are
* workbasket already exists an update will be executed. Otherwise a new workbasket will be created. * 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 * @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 * existing id's) 401 - not authorized
* @throws IOException if multipart file cannot be parsed. * @throws IOException
* @throws NotAuthorizedException if the user is not authorized. * if multipart file cannot be parsed.
* @throws DomainNotFoundException if domain information is incorrect. * @throws NotAuthorizedException
* @throws InvalidWorkbasketException if workbasket has invalid information. * if the user is not authorized.
* @throws WorkbasketAlreadyExistException if workbasket already exists when trying to create a new one. * @throws DomainNotFoundException
* @throws WorkbasketNotFoundException if do not exists a workbasket in the system with the used id. * if domain information is incorrect.
* @throws InvalidArgumentException if authorization information in workbaskets definitions 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 @PostMapping
@Transactional(rollbackFor = Exception.class) @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, throws IOException, NotAuthorizedException, DomainNotFoundException, InvalidWorkbasketException,
WorkbasketAlreadyExistException, WorkbasketNotFoundException, InvalidArgumentException { WorkbasketAlreadyExistException, WorkbasketNotFoundException, InvalidArgumentException {
LOGGER.debug("Entry to importWorkbaskets()"); LOGGER.debug("Entry to importWorkbaskets()");
@ -172,7 +177,7 @@ public class WorkbasketDefinitionController {
// no verification necessary since the workbasket was already imported in step 1. // no verification necessary since the workbasket was already imported in step 1.
idConversion.get(definition.getWorkbasket().getWorkbasketId()), distributionTargets); 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); LOGGER.debug("Exit from importWorkbaskets(), returning {}", response);
return response; return response;
} }
@ -195,7 +200,8 @@ public class WorkbasketDefinitionController {
} }
} }
if (!duplicates.isEmpty()) { 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());
} }
} }

View File

@ -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();
}
}

View File

@ -44,8 +44,8 @@ public class ClassificationSummaryResourceAssembler
} }
@PageLinks(ClassificationController.class) @PageLinks(ClassificationController.class)
public PagedResources<ClassificationSummaryResource> toResources(Collection<ClassificationSummary> entities, public ClassificationSummaryListResource toResources(Collection<ClassificationSummary> entities,
PagedResources.PageMetadata pageMetadata) { PagedResources.PageMetadata pageMetadata) {
return new PagedResources<>(toResources(entities), pageMetadata); return new ClassificationSummaryListResource(toResources(entities), pageMetadata);
} }
} }

View File

@ -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();
}
}

View File

@ -5,7 +5,6 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.util.List; import java.util.List;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -29,9 +28,11 @@ public class DistributionTargetResourceAssembler extends
return new DistributionTargetResource(summary); return new DistributionTargetResource(summary);
} }
public Resources<DistributionTargetResource> toResources(String workbasketId, public DistributionTargetListResource toResources(String workbasketId,
List<WorkbasketSummary> distributionTargets) throws WorkbasketNotFoundException, NotAuthorizedException { List<WorkbasketSummary> distributionTargets) throws WorkbasketNotFoundException, NotAuthorizedException {
Resources<DistributionTargetResource> distributionTargetListResource = new Resources<>(super.toResources(distributionTargets));
DistributionTargetListResource distributionTargetListResource = new DistributionTargetListResource(
toResources(distributionTargets));
distributionTargetListResource distributionTargetListResource
.add(linkTo(methodOn(WorkbasketController.class).getDistributionTargets(workbasketId)) .add(linkTo(methodOn(WorkbasketController.class).getDistributionTargets(workbasketId))
.withSelfRel()); .withSelfRel());

View File

@ -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);
};
}

View File

@ -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();
}
}

View File

@ -35,9 +35,9 @@ public class TaskSummaryResourceAssembler
} }
@PageLinks(TaskController.class) @PageLinks(TaskController.class)
public PagedResources<TaskSummaryResource> toResources(List<TaskSummary> taskSummaries, public TaskSummaryListResource toResources(List<TaskSummary> taskSummaries,
PagedResources.PageMetadata pageMetadata) { PagedResources.PageMetadata pageMetadata) {
return new PagedResources<>(toResources(taskSummaries), pageMetadata); return new TaskSummaryListResource(toResources(taskSummaries), pageMetadata);
} }
} }

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -8,7 +8,6 @@ import java.util.List;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedResources; import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -31,11 +30,11 @@ public class WorkbasketAccessItemResourceAssembler extends
@Autowired @Autowired
private WorkbasketService workbasketService; private WorkbasketService workbasketService;
public WorkbasketAccessItemResourceAssembler() { public WorkbasketAccessItemResourceAssembler() {
super(WorkbasketController.class, WorkbasketAccessItemResource.class); super(WorkbasketController.class, WorkbasketAccessItemResource.class);
} }
public WorkbasketAccessItemResource toResource(WorkbasketAccessItem wbAccItem) { public WorkbasketAccessItemResource toResource(WorkbasketAccessItem wbAccItem) {
return new WorkbasketAccessItemResource(wbAccItem); return new WorkbasketAccessItemResource(wbAccItem);
} }
@ -49,16 +48,18 @@ public class WorkbasketAccessItemResourceAssembler extends
return wbAccItemModel; return wbAccItemModel;
} }
@PageLinks(WorkbasketAccessItemController.class) @PageLinks(WorkbasketAccessItemController.class)
public PagedResources<WorkbasketAccessItemResource> toResources(List<WorkbasketAccessItem> entities, public WorkbasketAccessItemPaginatedListResource toResources(
List<WorkbasketAccessItem> entities,
PagedResources.PageMetadata pageMetadata) { 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 { throws NotAuthorizedException, WorkbasketNotFoundException {
Resources<WorkbasketAccessItemResource> accessItemListResource = new Resources<>(super.toResources(entities)); WorkbasketAccessItemListResource accessItemListResource = new WorkbasketAccessItemListResource(
super.toResources(entities));
accessItemListResource accessItemListResource
.add(linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(workbasketId)) .add(linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(workbasketId))
.withSelfRel()); .withSelfRel());

View File

@ -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();
}
}

View File

@ -34,9 +34,9 @@ public class WorkbasketSummaryResourceAssembler
} }
@PageLinks(WorkbasketController.class) @PageLinks(WorkbasketController.class)
public PagedResources<WorkbasketSummaryResource> toResources(List<WorkbasketSummary> entities, public WorkbasketSummaryListResource toResources(List<WorkbasketSummary> entities,
PagedResources.PageMetadata pageMetadata) { PagedResources.PageMetadata pageMetadata) {
return new PagedResources<>(toResources(entities), pageMetadata); return new WorkbasketSummaryListResource(toResources(entities), pageMetadata);
} }
public WorkbasketSummary toModel(WorkbasketSummaryResource resource) { public WorkbasketSummary toModel(WorkbasketSummaryResource resource) {

View File

@ -131,7 +131,7 @@ export class AccessItemsManagementComponent implements OnInit, OnDestroy {
this.sortModel, this.sortModel,
true) true)
.subscribe((accessItemsResource: AccessItemsWorkbasketResource) => { .subscribe((accessItemsResource: AccessItemsWorkbasketResource) => {
this.setAccessItemsGroups(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []); this.setAccessItemsGroups(accessItemsResource ? accessItemsResource.accessItems : []);
this.requestInProgressService.setRequestInProgress(false); this.requestInProgressService.setRequestInProgress(false);
}, },
error => { error => {

View File

@ -47,12 +47,11 @@ describe('AccessItemsComponent', () => {
workbasketService = TestBed.get(WorkbasketService); workbasketService = TestBed.get(WorkbasketService);
alertService = TestBed.get(AlertService); alertService = TestBed.get(AlertService);
spyOn(workbasketService, 'getWorkBasketAccessItems').and.returnValue(of(new WorkbasketAccessItemsResource( spyOn(workbasketService, 'getWorkBasketAccessItems').and.returnValue(of(new WorkbasketAccessItemsResource(
{ new Array<WorkbasketAccessItems>(
'accessItems': new Array<WorkbasketAccessItems>(
new WorkbasketAccessItems('id1', '1', 'accessID1', '', false, false, false, false, false, false, false, false, new WorkbasketAccessItems('id1', '1', 'accessID1', '', false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false), false, false, false, false, false, false, false, false, false),
new WorkbasketAccessItems('id2', '1', 'accessID2')) new WorkbasketAccessItems('id2', '1', 'accessID2'))
}, new Links({ 'href': 'someurl' }) , new Links({ 'href': 'someurl' })
))); )));
spyOn(workbasketService, 'updateWorkBasketAccessItem').and.returnValue(of(true)), spyOn(workbasketService, 'updateWorkBasketAccessItem').and.returnValue(of(true)),
spyOn(alertService, 'triggerAlert').and.returnValue(of(true)), spyOn(alertService, 'triggerAlert').and.returnValue(of(true)),

View File

@ -106,9 +106,9 @@ export class AccessItemsComponent implements OnChanges, OnDestroy {
this.accessItemsubscription = this.workbasketService.getWorkBasketAccessItems(this.workbasket._links.accessItems.href) this.accessItemsubscription = this.workbasketService.getWorkBasketAccessItems(this.workbasket._links.accessItems.href)
.subscribe((accessItemsResource: WorkbasketAccessItemsResource) => { .subscribe((accessItemsResource: WorkbasketAccessItemsResource) => {
this.accessItemsResource = accessItemsResource; this.accessItemsResource = accessItemsResource;
this.setAccessItemsGroups(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []); this.setAccessItemsGroups(accessItemsResource.accessItems);
this.accessItemsClone = this.cloneAccessItems(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []); this.accessItemsClone = this.cloneAccessItems(accessItemsResource.accessItems);
this.accessItemsResetClone = this.cloneAccessItems(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []); this.accessItemsResetClone = this.cloneAccessItems(accessItemsResource.accessItems);
this.requestInProgress = false; this.requestInProgress = false;
}) })
this.savingAccessItemsSubscription = this.savingWorkbaskets.triggeredAccessItemsSaving() this.savingAccessItemsSubscription = this.savingWorkbaskets.triggeredAccessItemsSaving()

View File

@ -25,118 +25,118 @@ import { configureTests } from 'app/app.test.configuration';
import { InfiniteScrollModule } from 'ngx-infinite-scroll'; import { InfiniteScrollModule } from 'ngx-infinite-scroll';
describe('DistributionTargetsComponent', () => { describe('DistributionTargetsComponent', () => {
let component: DistributionTargetsComponent; let component: DistributionTargetsComponent;
let fixture: ComponentFixture<DistributionTargetsComponent>; let fixture: ComponentFixture<DistributionTargetsComponent>;
let workbasketService; let workbasketService;
const workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '', const workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '',
new Links({ 'href': 'someurl' }, { 'href': 'someurl' }, { 'href': 'someurl' })); new Links({ 'href': 'someurl' }, { 'href': 'someurl' }, { 'href': 'someurl' }));
beforeEach(done => { beforeEach(done => {
const configure = (testBed: TestBed) => { const configure = (testBed: TestBed) => {
testBed.configureTestingModule({ testBed.configureTestingModule({
imports: [AngularSvgIconModule, HttpClientModule, InfiniteScrollModule], imports: [AngularSvgIconModule, HttpClientModule, InfiniteScrollModule],
declarations: [DistributionTargetsComponent, DualListComponent], declarations: [DistributionTargetsComponent, DualListComponent],
providers: [WorkbasketService, AlertService, SavingWorkbasketService, GeneralModalService, RequestInProgressService, providers: [WorkbasketService, AlertService, SavingWorkbasketService, GeneralModalService, RequestInProgressService,
] ]
}) })
}; };
configureTests(configure).then(testBed => { configureTests(configure).then(testBed => {
fixture = TestBed.createComponent(DistributionTargetsComponent); fixture = TestBed.createComponent(DistributionTargetsComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.workbasket = workbasket; component.workbasket = workbasket;
workbasketService = TestBed.get(WorkbasketService); workbasketService = TestBed.get(WorkbasketService);
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => { spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => {
return of(new WorkbasketSummaryResource( return of(new WorkbasketSummaryResource(
{ new Array<WorkbasketSummary>(
'workbaskets': new Array<WorkbasketSummary>( new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })), new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })), new WorkbasketSummary('id3', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
new WorkbasketSummary('id3', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))) , new LinksWorkbasketSummary({ 'href': 'someurl' })))
}, new LinksWorkbasketSummary({ 'href': 'someurl' }))) })
}) spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => {
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => { return of(new WorkbasketDistributionTargetsResource(
return of(new WorkbasketDistributionTargetsResource( new Array<WorkbasketSummary>(
{ new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
'distributionTargets': new Array<WorkbasketSummary>( , new LinksWorkbasketSummary({ 'href': 'someurl' })))
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))) })
}, new LinksWorkbasketSummary({ 'href': 'someurl' }))) component.ngOnChanges({
}) active: new SimpleChange(undefined, 'distributionTargets', true)
component.ngOnChanges({ });
active: new SimpleChange(undefined, 'distributionTargets', true) fixture.detectChanges();
}); done();
fixture.detectChanges(); });
done(); });
});
});
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
it('should clone distribution target selected on init', () => { it('should clone distribution target selected on init', () => {
expect(component.distributionTargetsClone).toBeDefined(); expect(component.distributionTargetsClone).toBeDefined();
}); });
it('should clone distribution target left and distribution target right lists on init', () => { it('should clone distribution target left and distribution target right lists on init', () => {
expect(component.distributionTargetsLeft).toBeDefined(); expect(component.distributionTargetsLeft).toBeDefined();
expect(component.distributionTargetsRight).toBeDefined(); expect(component.distributionTargetsRight).toBeDefined();
}); });
it('should have two list with differents elements onInit', () => { it('should have two list with differents elements onInit', () => {
let repeteadElemens = false; let repeteadElemens = false;
expect(component.distributionTargetsLeft.length).toBe(2); expect(component.distributionTargetsLeft.length).toBe(2);
expect(component.distributionTargetsRight.length).toBe(1); expect(component.distributionTargetsRight.length).toBe(1);
component.distributionTargetsLeft.forEach(leftElement => { component.distributionTargetsLeft.forEach(leftElement => {
component.distributionTargetsRight.forEach(rightElement => { component.distributionTargetsRight.forEach(rightElement => {
if (leftElement.workbasketId === rightElement.workbasketId) { repeteadElemens = true }; if (leftElement.workbasketId === rightElement.workbasketId) { repeteadElemens = true };
}) })
}) })
expect(repeteadElemens).toBeFalsy(); expect(repeteadElemens).toBeFalsy();
}); });
it('should filter left list and keep selected elements as selected', () => { it('should filter left list and keep selected elements as selected', () => {
component.performFilter({ filterBy: new FilterModel({ component.performFilter({
name: 'someName', owner: 'someOwner', description: 'someDescription', key: 'someKey'}), side: Side.LEFT }); filterBy: new FilterModel({
component.distributionTargetsLeft = new Array<WorkbasketSummary>( name: 'someName', owner: 'someOwner', description: 'someDescription', key: 'someKey'
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })) }), side: Side.LEFT
) });
expect(component.distributionTargetsLeft.length).toBe(1); component.distributionTargetsLeft = new Array<WorkbasketSummary>(
expect(component.distributionTargetsLeft[0].workbasketId).toBe('id1'); new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))
expect(component.distributionTargetsRight.length).toBe(1); )
expect(component.distributionTargetsRight[0].workbasketId).toBe('id2'); 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', () => { it('should reset distribution target and distribution target selected on reset', () => {
component.distributionTargetsLeft.push( component.distributionTargetsLeft.push(
new WorkbasketSummary('id4', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))); new WorkbasketSummary('id4', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })));
component.distributionTargetsRight.push( component.distributionTargetsRight.push(
new WorkbasketSummary('id5', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))); new WorkbasketSummary('id5', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })));
expect(component.distributionTargetsLeft.length).toBe(3); expect(component.distributionTargetsLeft.length).toBe(3);
expect(component.distributionTargetsRight.length).toBe(2); expect(component.distributionTargetsRight.length).toBe(2);
component.onClear(); component.onClear();
fixture.detectChanges(); fixture.detectChanges();
expect(component.distributionTargetsLeft.length).toBe(2); expect(component.distributionTargetsLeft.length).toBe(2);
expect(component.distributionTargetsRight.length).toBe(1) expect(component.distributionTargetsRight.length).toBe(1)
}); });
it('should save distribution targets selected and update Clone objects.', () => { it('should save distribution targets selected and update Clone objects.', () => {
expect(component.distributionTargetsSelected.length).toBe(1); expect(component.distributionTargetsSelected.length).toBe(1);
expect(component.distributionTargetsSelectedClone.length).toBe(1); expect(component.distributionTargetsSelectedClone.length).toBe(1);
spyOn(workbasketService, 'updateWorkBasketsDistributionTargets').and.callFake(() => { spyOn(workbasketService, 'updateWorkBasketsDistributionTargets').and.callFake(() => {
return of(new WorkbasketDistributionTargetsResource( return of(new WorkbasketDistributionTargetsResource(
{ new Array<WorkbasketSummary>(
'distributionTargets': new Array<WorkbasketSummary>( new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })), new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))) , new LinksWorkbasketSummary({ 'href': 'someurl' })))
}, new LinksWorkbasketSummary({ 'href': 'someurl' }))) })
}) component.onSave();
component.onSave(); fixture.detectChanges();
fixture.detectChanges(); expect(component.distributionTargetsSelected.length).toBe(2);
expect(component.distributionTargetsSelected.length).toBe(2); expect(component.distributionTargetsSelectedClone.length).toBe(2);
expect(component.distributionTargetsSelectedClone.length).toBe(2); expect(component.distributionTargetsLeft.length).toBe(1);
expect(component.distributionTargetsLeft.length).toBe(1);
}); });
}); });

View File

@ -113,7 +113,7 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
this.workbasketService.updateWorkBasketsDistributionTargets( this.workbasketService.updateWorkBasketsDistributionTargets(
this.distributionTargetsSelectedResource._links.self.href, this.getSeletedIds()).subscribe(response => { this.distributionTargetsSelectedResource._links.self.href, this.getSeletedIds()).subscribe(response => {
this.requestInProgressService.setRequestInProgress(false); this.requestInProgressService.setRequestInProgress(false);
this.distributionTargetsSelected = response._embedded ? response._embedded.distributionTargets : []; this.distributionTargetsSelected = response.distributionTargets;
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected); this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
this.distributionTargetsClone = Object.assign([], this.distributionTargetsLeft); this.distributionTargetsClone = Object.assign([], this.distributionTargetsLeft);
this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, 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.owner, dualListFilter.filterBy.filterParams.type, undefined,
dualListFilter.filterBy.filterParams.key, undefined, true).subscribe(resultList => { dualListFilter.filterBy.filterParams.key, undefined, true).subscribe(resultList => {
(dualListFilter.side === Side.RIGHT) ? (dualListFilter.side === Side.RIGHT) ?
this.distributionTargetsRight = (resultList._embedded ? resultList._embedded.workbaskets : []) : this.distributionTargetsRight = (resultList.workbaskets) :
this.distributionTargetsLeft = (resultList._embedded ? resultList._embedded.workbaskets : []); this.distributionTargetsLeft = (resultList.workbaskets);
this.onRequest(dualListFilter.side, true); this.onRequest(dualListFilter.side, true);
}); });
} }
@ -168,8 +168,7 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
this.workbasket._links.distributionTargets.href).subscribe( this.workbasket._links.distributionTargets.href).subscribe(
(distributionTargetsSelectedResource: WorkbasketDistributionTargetsResource) => { (distributionTargetsSelectedResource: WorkbasketDistributionTargetsResource) => {
this.distributionTargetsSelectedResource = distributionTargetsSelectedResource; this.distributionTargetsSelectedResource = distributionTargetsSelectedResource;
this.distributionTargetsSelected = distributionTargetsSelectedResource._embedded ? this.distributionTargetsSelected = distributionTargetsSelectedResource.distributionTargets;
distributionTargetsSelectedResource._embedded.distributionTargets : [];
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected); this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
TaskanaQueryParameters.page = 1; TaskanaQueryParameters.page = 1;
this.calculateNumberItemsList(); this.calculateNumberItemsList();
@ -223,13 +222,13 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
this.page = distributionTargetsAvailable.page; this.page = distributionTargetsAvailable.page;
} }
if (side === this.side.LEFT) { if (side === this.side.LEFT) {
this.distributionTargetsLeft.push(...distributionTargetsAvailable._embedded.workbaskets); this.distributionTargetsLeft.push(...distributionTargetsAvailable.workbaskets);
} else if (side === this.side.RIGHT) { } else if (side === this.side.RIGHT) {
this.distributionTargetsRight = Object.assign([], distributionTargetsAvailable._embedded.workbaskets); this.distributionTargetsRight = Object.assign([], distributionTargetsAvailable.workbaskets);
} else { } else {
this.distributionTargetsLeft.push(...distributionTargetsAvailable._embedded.workbaskets); this.distributionTargetsLeft.push(...distributionTargetsAvailable.workbaskets);
this.distributionTargetsRight = Object.assign([], distributionTargetsAvailable._embedded.workbaskets); this.distributionTargetsRight = Object.assign([], distributionTargetsAvailable.workbaskets);
this.distributionTargetsClone = Object.assign([], distributionTargetsAvailable._embedded.workbaskets); this.distributionTargetsClone = Object.assign([], distributionTargetsAvailable.workbaskets);
} }
this.onRequest(undefined, true); this.onRequest(undefined, true);
}); });

View File

@ -34,76 +34,75 @@ import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { ImportExportService } from 'app/administration/services/import-export/import-export.service'; import { ImportExportService } from 'app/administration/services/import-export/import-export.service';
@Component({ @Component({
selector: 'taskana-dummy-detail', selector: 'taskana-dummy-detail',
template: 'dummydetail' template: 'dummydetail'
}) })
export class DummyDetailComponent { export class DummyDetailComponent {
} }
describe('WorkbasketDetailsComponent', () => { describe('WorkbasketDetailsComponent', () => {
let component: WorkbasketDetailsComponent; let component: WorkbasketDetailsComponent;
let fixture: ComponentFixture<WorkbasketDetailsComponent>; let fixture: ComponentFixture<WorkbasketDetailsComponent>;
let debugElement; let debugElement;
let masterAndDetailService; let masterAndDetailService;
let workbasketService; let workbasketService;
let router; let router;
const workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '', const workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '',
new Links({ 'href': 'someurl' }, { 'href': 'someurl' }, { 'href': 'someurl' })); new Links({ 'href': 'someurl' }, { 'href': 'someurl' }, { 'href': 'someurl' }));
const routes: Routes = [ const routes: Routes = [
{ path: '*', component: DummyDetailComponent } { path: '*', component: DummyDetailComponent }
]; ];
beforeEach(done => { beforeEach(done => {
const configure = (testBed: TestBed) => { const configure = (testBed: TestBed) => {
testBed.configureTestingModule({ testBed.configureTestingModule({
imports: [RouterTestingModule.withRoutes(routes), FormsModule, AngularSvgIconModule, HttpClientModule, ReactiveFormsModule, imports: [RouterTestingModule.withRoutes(routes), FormsModule, AngularSvgIconModule, HttpClientModule, ReactiveFormsModule,
InfiniteScrollModule], InfiniteScrollModule],
declarations: [WorkbasketDetailsComponent, WorkbasketInformationComponent, declarations: [WorkbasketDetailsComponent, WorkbasketInformationComponent,
AccessItemsComponent, AccessItemsComponent,
DistributionTargetsComponent, DualListComponent, DummyDetailComponent], DistributionTargetsComponent, DualListComponent, DummyDetailComponent],
providers: [WorkbasketService, MasterAndDetailService, GeneralModalService, RequestInProgressService, providers: [WorkbasketService, MasterAndDetailService, GeneralModalService, RequestInProgressService,
AlertService, SavingWorkbasketService, CustomFieldsService, ImportExportService] AlertService, SavingWorkbasketService, CustomFieldsService, ImportExportService]
}) })
}; };
configureTests(configure).then(testBed => { configureTests(configure).then(testBed => {
fixture = TestBed.createComponent(WorkbasketDetailsComponent); fixture = TestBed.createComponent(WorkbasketDetailsComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
debugElement = fixture.debugElement.nativeElement; debugElement = fixture.debugElement.nativeElement;
router = TestBed.get(Router) router = TestBed.get(Router)
fixture.detectChanges(); fixture.detectChanges();
masterAndDetailService = TestBed.get(MasterAndDetailService); masterAndDetailService = TestBed.get(MasterAndDetailService);
workbasketService = TestBed.get(WorkbasketService); workbasketService = TestBed.get(WorkbasketService);
spyOn(masterAndDetailService, 'getShowDetail').and.callFake(() => { return of(true) }) spyOn(masterAndDetailService, 'getShowDetail').and.callFake(() => { return of(true) })
spyOn(workbasketService, 'getSelectedWorkBasket').and.callFake(() => { return of('id1') }) spyOn(workbasketService, 'getSelectedWorkBasket').and.callFake(() => { return of('id1') })
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => { spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => {
return of(new WorkbasketSummaryResource( return of(new WorkbasketSummaryResource(
{ new Array<WorkbasketSummary>(
'workbaskets': new Array<WorkbasketSummary>( new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '',
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
false, new Links({ 'href': 'someurl' }))) , new LinksWorkbasketSummary({ 'href': 'someurl' })))
}, new LinksWorkbasketSummary({ 'href': 'someurl' }))) })
})
spyOn(workbasketService, 'getWorkBasket').and.callFake(() => { return of(workbasket) }) spyOn(workbasketService, 'getWorkBasket').and.callFake(() => { return of(workbasket) })
spyOn(workbasketService, 'getWorkBasketAccessItems').and.callFake(() => { spyOn(workbasketService, 'getWorkBasketAccessItems').and.callFake(() => {
return of(new WorkbasketAccessItemsResource( return of(new WorkbasketAccessItemsResource(
{ 'accessItems': new Array<WorkbasketAccessItems>() }, new Links({ 'href': 'url' }))) new Array<WorkbasketAccessItems>(), new Links({ 'href': 'url' })))
}) })
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => { spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => {
return of(new WorkbasketSummaryResource( return of(new WorkbasketSummaryResource(
{ 'workbaskets': new Array<WorkbasketSummary>() }, new LinksWorkbasketSummary({ 'href': 'url' }))) new Array<WorkbasketSummary>(), new LinksWorkbasketSummary({ 'href': 'url' })))
}) })
done(); done();
}); });
}); });
afterEach(() => { afterEach(() => {
document.body.removeChild(debugElement); document.body.removeChild(debugElement);
}); });
it('should be created', () => { it('should be created', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
}); });

View File

@ -25,150 +25,150 @@ import { Page } from 'app/models/page';
import { ImportExportService } from 'app/administration/services/import-export/import-export.service'; import { ImportExportService } from 'app/administration/services/import-export/import-export.service';
@Component({ @Component({
selector: 'taskana-dummy-detail', selector: 'taskana-dummy-detail',
template: 'dummydetail' template: 'dummydetail'
}) })
class DummyDetailComponent { class DummyDetailComponent {
} }
@Component({ @Component({
selector: 'taskana-pagination', selector: 'taskana-pagination',
template: 'dummydetail' template: 'dummydetail'
}) })
class PaginationComponent { class PaginationComponent {
@Input() @Input()
page: Page; page: Page;
@Output() @Output()
workbasketsResourceChange = new EventEmitter<any>(); workbasketsResourceChange = new EventEmitter<any>();
@Output() changePage = new EventEmitter<any>(); @Output() changePage = new EventEmitter<any>();
} }
const workbasketSummaryResource: WorkbasketSummaryResource = new WorkbasketSummaryResource({ const workbasketSummaryResource: WorkbasketSummaryResource = new WorkbasketSummaryResource(
'workbaskets': new Array<WorkbasketSummary>( new Array<WorkbasketSummary>(
new WorkbasketSummary('1', 'key1', 'NAME1', 'description 1', 'owner 1', '', '', 'PERSONAL', '', '', '', ''), new WorkbasketSummary('1', 'key1', 'NAME1', 'description 1', 'owner 1', '', '', 'PERSONAL', '', '', '', ''),
new WorkbasketSummary('2', 'key2', 'NAME2', 'description 2', 'owner 2', '', '', 'GROUP', '', '', '', '')) new WorkbasketSummary('2', 'key2', 'NAME2', 'description 2', 'owner 2', '', '', 'GROUP', '', '', '', ''))
}, new LinksWorkbasketSummary({ 'href': 'url' })); , new LinksWorkbasketSummary({ 'href': 'url' }));
describe('WorkbasketListComponent', () => { describe('WorkbasketListComponent', () => {
let component: WorkbasketListComponent; let component: WorkbasketListComponent;
let fixture: ComponentFixture<WorkbasketListComponent>; let fixture: ComponentFixture<WorkbasketListComponent>;
let debugElement: any = undefined; let debugElement: any = undefined;
let workbasketService: WorkbasketService; let workbasketService: WorkbasketService;
let workbasketSummarySpy; let workbasketSummarySpy;
const routes: Routes = [ const routes: Routes = [
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' }, { path: ':id', component: DummyDetailComponent, outlet: 'detail' },
{ path: 'workbaskets', component: DummyDetailComponent } { path: 'workbaskets', component: DummyDetailComponent }
]; ];
beforeEach(done => { beforeEach(done => {
const configure = (testBed: TestBed) => { const configure = (testBed: TestBed) => {
testBed.configureTestingModule({ testBed.configureTestingModule({
declarations: [ declarations: [
WorkbasketListComponent, WorkbasketListComponent,
DummyDetailComponent, DummyDetailComponent,
WorkbasketListToolbarComponent, WorkbasketListToolbarComponent,
ImportExportComponent ImportExportComponent
], ],
imports: [ imports: [
AngularSvgIconModule, AngularSvgIconModule,
HttpClientModule, HttpClientModule,
RouterTestingModule.withRoutes(routes) RouterTestingModule.withRoutes(routes)
], ],
providers: [ providers: [
WorkbasketService, WorkbasketService,
WorkbasketDefinitionService, WorkbasketDefinitionService,
ClassificationDefinitionService, ClassificationDefinitionService,
OrientationService, OrientationService,
ImportExportService ImportExportService
] ]
}); });
}; };
configureTests(configure).then(testBed => { configureTests(configure).then(testBed => {
fixture = TestBed.createComponent(WorkbasketListComponent); fixture = TestBed.createComponent(WorkbasketListComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
debugElement = fixture.debugElement.nativeElement; debugElement = fixture.debugElement.nativeElement;
workbasketService = TestBed.get(WorkbasketService); workbasketService = TestBed.get(WorkbasketService);
const orientationService = TestBed.get(OrientationService); const orientationService = TestBed.get(OrientationService);
workbasketSummarySpy = spyOn(workbasketService, 'getWorkBasketsSummary').and.returnValue(of(workbasketSummaryResource)); workbasketSummarySpy = spyOn(workbasketService, 'getWorkBasketsSummary').and.returnValue(of(workbasketSummaryResource));
spyOn(workbasketService, 'getSelectedWorkBasket').and.returnValue(of('2')); spyOn(workbasketService, 'getSelectedWorkBasket').and.returnValue(of('2'));
spyOn(orientationService, 'getOrientation').and.returnValue(of(undefined)); spyOn(orientationService, 'getOrientation').and.returnValue(of(undefined));
fixture.detectChanges();
done();
});
fixture.detectChanges();
done();
}); });
}); afterEach(() => {
fixture.detectChanges();
afterEach(() => { document.body.removeChild(debugElement);
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);
}); });
// it('should have two workbasketsummary rows created with the second one selected.', fakeAsync(() => { it('should be created', () => {
// tick(0); expect(component).toBeTruthy();
// 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', it('should call workbasketService.getWorkbasketsSummary method on init', () => {
undefined, 'someName', 'someDescription', undefined, 'someOwner', 'PERSONAL', undefined, 'someKey', undefined]); 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]);
}));
}); });

View File

@ -109,7 +109,7 @@ export class WorkbasketListComponent implements OnInit, OnDestroy {
this.filterBy.filterParams.type, undefined, this.filterBy.filterParams.key, undefined) this.filterBy.filterParams.type, undefined, this.filterBy.filterParams.key, undefined)
.subscribe(resultList => { .subscribe(resultList => {
this.workbasketsResource = resultList; this.workbasketsResource = resultList;
this.workbaskets = resultList._embedded ? resultList._embedded.workbaskets : []; this.workbaskets = resultList.workbaskets;
this.requestInProgress = false; this.requestInProgress = false;
}); });
} }

View File

@ -3,7 +3,7 @@ import { AccessItemWorkbasket } from './access-item-workbasket';
export class AccessItemsWorkbasketResource { export class AccessItemsWorkbasketResource {
constructor( constructor(
public _embedded: { 'accessItems': Array<AccessItemWorkbasket> } = { 'accessItems': [] }, public accessItems: Array<AccessItemWorkbasket> = [],
public _links: Links = undefined public _links: Links = undefined
) { } ) { }
} }

View File

@ -3,9 +3,7 @@ import { Links } from './links';
export class ClassificationResource { export class ClassificationResource {
constructor( constructor(
public _embedded: { public classifications: Array<Classification> = [],
'classificationSummaryResourceList': Array<Classification>
} = { 'classificationSummaryResourceList': [] },
public _links: Links = new Links(), public _links: Links = new Links(),
) { ) {
} }

View File

@ -3,7 +3,7 @@ import { WorkbasketAccessItems } from './workbasket-access-items';
export class WorkbasketAccessItemsResource { export class WorkbasketAccessItemsResource {
constructor( constructor(
public _embedded: { 'accessItems': Array<WorkbasketAccessItems> } = { 'accessItems': [] }, public accessItems: Array<WorkbasketAccessItems> = [],
public _links: Links = undefined public _links: Links = undefined
) { } ) { }
} }

View File

@ -2,7 +2,8 @@ import { WorkbasketSummary } from './workbasket-summary';
import { Links } from './links'; import { Links } from './links';
export class WorkbasketDistributionTargetsResource { export class WorkbasketDistributionTargetsResource {
constructor(public _embedded: { 'distributionTargets': Array<WorkbasketSummary> } = constructor(
{ 'distributionTargets': [] }, public _links: Links = null) { public distributionTargets: Array<WorkbasketSummary> = [],
public _links: Links = null) {
} }
} }

View File

@ -1,7 +1,8 @@
import {Links} from './links'; import { Links } from './links';
import {Workbasket} from './workbasket'; import { Workbasket } from './workbasket';
export class WorkbasketResource { export class WorkbasketResource {
constructor(public _embedded: { 'workbaskets': Array<Workbasket> } = { 'workbaskets': [] }, constructor(
public _links: Links = undefined) {} public workbaskets: Array<Workbasket> = [],
public _links: Links = undefined) { }
} }

View File

@ -4,9 +4,7 @@ import { LinksWorkbasketSummary } from './links-workbasket-summary';
export class WorkbasketSummaryResource { export class WorkbasketSummaryResource {
constructor( constructor(
public _embedded: { public workbaskets: Array<WorkbasketSummary> = [],
'workbaskets': Array<WorkbasketSummary>
} = { 'workbaskets': [] },
public _links: LinksWorkbasketSummary = new LinksWorkbasketSummary(), public _links: LinksWorkbasketSummary = new LinksWorkbasketSummary(),
public page: Page = new Page() public page: Page = new Page()
) { ) {

View File

@ -115,10 +115,10 @@ export class ClassificationsService {
classificationRef, classificationRef,
classificationTypes, classificationTypes,
(classification: any, classificationType) => { (classification: any, classificationType) => {
if (!classification._embedded) { if (!classification.classifications) {
return []; return [];
} }
return this.buildHierarchy(classification._embedded.classificationSummaryResourceList, classificationType); return this.buildHierarchy(classification.classifications, classificationType);
} }
) )
} }

View File

@ -1,3 +1,4 @@
import { throwError as observableThrowError, Observable, Subject } from 'rxjs'; import { throwError as observableThrowError, Observable, Subject } from 'rxjs';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
@ -18,175 +19,176 @@ import { QueryParametersModel } from 'app/models/query-parameters';
@Injectable() @Injectable()
export class WorkbasketService { export class WorkbasketService {
public workBasketSelected = new Subject<string>(); public workBasketSelected = new Subject<string>();
public workBasketSaved = new Subject<number>(); public workBasketSaved = new Subject<number>();
private workbasketSummaryRef: Observable<WorkbasketSummaryResource> = new Observable(); private workbasketSummaryRef: Observable<WorkbasketSummaryResource> = new Observable();
constructor( constructor(
private httpClient: HttpClient, private httpClient: HttpClient,
private domainService: DomainService private domainService: DomainService
) { } ) { }
// #region "REST calls" // #region "REST calls"
// GET // GET
getWorkBasketsSummary(forceRequest: boolean = false, getWorkBasketsSummary(forceRequest: boolean = false,
sortBy: string = TaskanaQueryParameters.parameters.KEY, sortBy: string = TaskanaQueryParameters.parameters.KEY,
order: string = Direction.ASC, order: string = Direction.ASC,
name: string = undefined, name: string = undefined,
nameLike: string = undefined, nameLike: string = undefined,
descLike: string = undefined, descLike: string = undefined,
owner: string = undefined, owner: string = undefined,
ownerLike: string = undefined, ownerLike: string = undefined,
type: string = undefined, type: string = undefined,
key: string = undefined, key: string = undefined,
keyLike: string = undefined, keyLike: string = undefined,
requiredPermission: string = undefined, requiredPermission: string = undefined,
allPages: boolean = false) { allPages: boolean = false) {
if (this.workbasketSummaryRef && !forceRequest) { if (this.workbasketSummaryRef && !forceRequest) {
return this.workbasketSummaryRef; return this.workbasketSummaryRef;
} }
return this.domainService.getSelectedDomain().pipe(mergeMap(domain => { return this.domainService.getSelectedDomain().pipe(mergeMap(domain => {
return this.workbasketSummaryRef = this.httpClient.get<WorkbasketSummaryResource>( return this.workbasketSummaryRef = this.httpClient.get<WorkbasketSummaryResource>(
`${environment.taskanaRestUrl}/v1/workbaskets/${TaskanaQueryParameters.getQueryParameters(this.workbasketParameters(sortBy, order, name, `${environment.taskanaRestUrl}/v1/workbaskets/${TaskanaQueryParameters
nameLike, descLike, owner, ownerLike, type, key, keyLike, requiredPermission, allPages, domain))}`) .getQueryParameters(this.workbasketParameters(sortBy, order, name, nameLike, descLike, owner, ownerLike,
.pipe(tap((workbaskets => { type, key, keyLike, requiredPermission, allPages, domain))}`)
return workbaskets; .pipe(tap((workbaskets => {
}))) return workbaskets;
}), tap(() => { })))
this.domainService.domainChangedComplete(); }), tap(() => {
})); this.domainService.domainChangedComplete();
}));
} }
// GET // GET
getWorkBasket(id: string): Observable<Workbasket> { getWorkBasket(id: string): Observable<Workbasket> {
return this.httpClient.get<Workbasket>(`${environment.taskanaRestUrl}/v1/workbaskets/${id}`); return this.httpClient.get<Workbasket>(`${environment.taskanaRestUrl}/v1/workbaskets/${id}`);
} }
// GET // GET
getAllWorkBaskets(): Observable<WorkbasketResource> { getAllWorkBaskets(): Observable<WorkbasketResource> {
return this.httpClient.get<WorkbasketResource>(`${environment.taskanaRestUrl}/v1/workbaskets?required-permission=OPEN`); return this.httpClient.get<WorkbasketResource>(`${environment.taskanaRestUrl}/v1/workbaskets?required-permission=OPEN`);
} }
// POST // POST
createWorkbasket(workbasket: Workbasket): Observable<Workbasket> { createWorkbasket(workbasket: Workbasket): Observable<Workbasket> {
return this.httpClient return this.httpClient
.post<Workbasket>(`${environment.taskanaRestUrl}/v1/workbaskets`, workbasket); .post<Workbasket>(`${environment.taskanaRestUrl}/v1/workbaskets`, workbasket);
} }
// PUT // PUT
updateWorkbasket(url: string, workbasket: Workbasket): Observable<Workbasket> { updateWorkbasket(url: string, workbasket: Workbasket): Observable<Workbasket> {
return this.httpClient return this.httpClient
.put<Workbasket>(url, workbasket).pipe( .put<Workbasket>(url, workbasket).pipe(
catchError(this.handleError) catchError(this.handleError)
); );
} }
// delete // delete
markWorkbasketForDeletion(url: string): Observable<any> { markWorkbasketForDeletion(url: string): Observable<any> {
return this.httpClient return this.httpClient
.delete<any>(url); .delete<any>(url);
} }
// GET // GET
getWorkBasketAccessItems(url: string): Observable<WorkbasketAccessItemsResource> { getWorkBasketAccessItems(url: string): Observable<WorkbasketAccessItemsResource> {
return this.httpClient.get<WorkbasketAccessItemsResource>(url); return this.httpClient.get<WorkbasketAccessItemsResource>(url);
} }
// POST // POST
createWorkBasketAccessItem(url: string, workbasketAccessItem: WorkbasketAccessItems): Observable<WorkbasketAccessItems> { createWorkBasketAccessItem(url: string, workbasketAccessItem: WorkbasketAccessItems): Observable<WorkbasketAccessItems> {
return this.httpClient.post<WorkbasketAccessItems>(url, workbasketAccessItem); return this.httpClient.post<WorkbasketAccessItems>(url, workbasketAccessItem);
} }
// PUT // PUT
updateWorkBasketAccessItem(url: string, workbasketAccessItem: Array<WorkbasketAccessItems>): Observable<string> { updateWorkBasketAccessItem(url: string, workbasketAccessItem: Array<WorkbasketAccessItems>): Observable<string> {
return this.httpClient.put<string>(url, return this.httpClient.put<string>(url,
workbasketAccessItem); workbasketAccessItem);
} }
// GET // GET
getWorkBasketsDistributionTargets(url: string): Observable<WorkbasketDistributionTargetsResource> { getWorkBasketsDistributionTargets(url: string): Observable<WorkbasketDistributionTargetsResource> {
return this.httpClient.get<WorkbasketDistributionTargetsResource>(url); return this.httpClient.get<WorkbasketDistributionTargetsResource>(url);
} }
// PUT // PUT
updateWorkBasketsDistributionTargets(url: string, distributionTargetsIds: Array<string>): updateWorkBasketsDistributionTargets(url: string, distributionTargetsIds: Array<string>):
Observable<WorkbasketDistributionTargetsResource> { Observable<WorkbasketDistributionTargetsResource> {
return this.httpClient.put<WorkbasketDistributionTargetsResource>(url, distributionTargetsIds); return this.httpClient.put<WorkbasketDistributionTargetsResource>(url, distributionTargetsIds);
} }
// DELETE // DELETE
removeDistributionTarget(url: string) { removeDistributionTarget(url: string) {
return this.httpClient.delete<string>(url); return this.httpClient.delete<string>(url);
} }
// #endregion // #endregion
// #region "Service extras" // #region "Service extras"
selectWorkBasket(id: string) { selectWorkBasket(id: string) {
this.workBasketSelected.next(id); this.workBasketSelected.next(id);
} }
getSelectedWorkBasket(): Observable<string> { getSelectedWorkBasket(): Observable<string> {
return this.workBasketSelected.asObservable(); return this.workBasketSelected.asObservable();
} }
triggerWorkBasketSaved() { triggerWorkBasketSaved() {
this.workBasketSaved.next(Date.now()); this.workBasketSaved.next(Date.now());
} }
workbasketSavedTriggered(): Observable<number> { workbasketSavedTriggered(): Observable<number> {
return this.workBasketSaved.asObservable(); return this.workBasketSaved.asObservable();
} }
// #endregion // #endregion
// #region private // #region private
private handleError(error: Response | any) { private handleError(error: Response | any) {
let errMsg: string; let errMsg: string;
if (error instanceof Response) { if (error instanceof Response) {
const body = error.json() || ''; const body = error.json() || '';
const err = JSON.stringify(body); const err = JSON.stringify(body);
errMsg = `${error.status} - ${error.statusText || ''} ${err}`; errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else { } else {
errMsg = error.message ? error.message : error.toString(); errMsg = error.message ? error.message : error.toString();
} }
console.error(errMsg); console.error(errMsg);
return observableThrowError(errMsg); return observableThrowError(errMsg);
} }
private workbasketParameters( private workbasketParameters(
sortBy: string = TaskanaQueryParameters.parameters.KEY, sortBy: string = TaskanaQueryParameters.parameters.KEY,
order: string = Direction.ASC, order: string = Direction.ASC,
name: string = undefined, name: string = undefined,
nameLike: string = undefined, nameLike: string = undefined,
descLike: string = undefined, descLike: string = undefined,
owner: string = undefined, owner: string = undefined,
ownerLike: string = undefined, ownerLike: string = undefined,
type: string = undefined, type: string = undefined,
key: string = undefined, key: string = undefined,
keyLike: string = undefined, keyLike: string = undefined,
requiredPermission: string = undefined, requiredPermission: string = undefined,
allPages: boolean = false, allPages: boolean = false,
domain: string = ''): QueryParametersModel { domain: string = ''): QueryParametersModel {
const parameters = new QueryParametersModel(); const parameters = new QueryParametersModel();
parameters.SORTBY = sortBy; parameters.SORTBY = sortBy;
parameters.SORTDIRECTION = order; parameters.SORTDIRECTION = order;
parameters.NAME = name; parameters.NAME = name;
parameters.NAMELIKE = nameLike; parameters.NAMELIKE = nameLike;
parameters.DESCLIKE = descLike; parameters.DESCLIKE = descLike;
parameters.OWNER = owner; parameters.OWNER = owner;
parameters.OWNERLIKE = ownerLike; parameters.OWNERLIKE = ownerLike;
parameters.TYPE = type; parameters.TYPE = type;
parameters.KEY = key; parameters.KEY = key;
parameters.KEYLIKE = keyLike; parameters.KEYLIKE = keyLike;
parameters.REQUIREDPERMISSION = requiredPermission; parameters.REQUIREDPERMISSION = requiredPermission;
parameters.DOMAIN = domain; parameters.DOMAIN = domain;
if (allPages) { if (allPages) {
TaskanaQueryParameters.page = undefined; TaskanaQueryParameters.page = undefined;
TaskanaQueryParameters.pageSize = undefined; TaskanaQueryParameters.pageSize = undefined;
} }
return parameters; return parameters;
} }
// #endregion // #endregion
} }

View File

@ -3,7 +3,7 @@ import {Task} from './task';
import { Page } from 'app/models/page'; import { Page } from 'app/models/page';
export class TaskResource { export class TaskResource {
constructor(public _embedded: { 'tasks': Array<Task> } = { 'tasks': [] }, constructor(public tasks: Array<Task>,
public _links: Links = undefined, public _links: Links = undefined,
public page: Page = new Page()) {} public page: Page = new Page()) {}
} }

View File

@ -58,7 +58,7 @@ export class TaskComponent implements OnInit, OnDestroy {
this.requestInProgress = true; this.requestInProgress = true;
this.workbasketService.getAllWorkBaskets().subscribe(workbaskets => { this.workbasketService.getAllWorkBaskets().subscribe(workbaskets => {
this.requestInProgress = false; this.requestInProgress = false;
this.workbaskets = workbaskets._embedded ? workbaskets._embedded.workbaskets : []; this.workbaskets = workbaskets.workbaskets;
let index = -1; let index = -1;
for (let i = 0; i < this.workbaskets.length; i++) { for (let i = 0; i < this.workbaskets.length; i++) {

View File

@ -18,59 +18,58 @@ import { Classification } from 'app/models/classification';
import { Links } from 'app/models/links'; import { Links } from 'app/models/links';
@Component({ @Component({
selector: 'taskana-dummy-detail', selector: 'taskana-dummy-detail',
template: 'dummydetail' template: 'dummydetail'
}) })
export class DummyDetailComponent { export class DummyDetailComponent {
} }
// TODO: test pending to test. Failing random // TODO: test pending to test. Failing random
xdescribe('GeneralComponent', () => { xdescribe('GeneralComponent', () => {
let component: TaskdetailsGeneralFieldsComponent; let component: TaskdetailsGeneralFieldsComponent;
let fixture: ComponentFixture<TaskdetailsGeneralFieldsComponent>; let fixture: ComponentFixture<TaskdetailsGeneralFieldsComponent>;
let classificationsService; let classificationsService;
const routes: Routes = [ const routes: Routes = [
{path: '*', component: DummyDetailComponent} { path: '*', component: DummyDetailComponent }
]; ];
beforeEach(done => { beforeEach(done => {
const configure = (testBed: TestBed) => { const configure = (testBed: TestBed) => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)], imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)],
declarations: [TaskdetailsGeneralFieldsComponent, DummyDetailComponent], declarations: [TaskdetailsGeneralFieldsComponent, DummyDetailComponent],
providers: [HttpClient, ClassificationCategoriesService, CustomFieldsService, providers: [HttpClient, ClassificationCategoriesService, CustomFieldsService,
DomainService, RequestInProgressService, SelectedRouteService, ClassificationsService] DomainService, RequestInProgressService, SelectedRouteService, ClassificationsService]
}) })
}; };
configureTests(configure).then(testBed => { configureTests(configure).then(testBed => {
classificationsService = TestBed.get(ClassificationsService); classificationsService = TestBed.get(ClassificationsService);
spyOn(classificationsService, 'getClassificationsByDomain').and.returnValue(new ClassificationResource( spyOn(classificationsService, 'getClassificationsByDomain').and.returnValue(new ClassificationResource(
{ new Array<Classification>(
'classificationSummaryResourceList': new Array<Classification>( new Classification('id1', '1', 'category', 'type', 'domain_a', 'classification1', 'parentId',
new Classification('id1', '1', 'category', 'type', 'domain_a', 'classification1', 'parentId', 1, 'service', new Links({ 'href': 'someurl' })),
1, 'service', new Links({ 'href': 'someurl' })), new Classification('id2', '2', 'category', 'type', 'domain_a', 'classification2', 'parentId2',
new Classification('id2', '2', 'category', 'type', 'domain_a', 'classification2', 'parentId2', 1, 'service', new Links({ 'href': 'someurl' })))
1, 'service', new Links({ 'href': 'someurl' }))) , new Links({ 'href': 'someurl' })
}, new Links({ 'href': 'someurl' }) ));
)); done();
done(); });
}); });
});
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(TaskdetailsGeneralFieldsComponent); fixture = TestBed.createComponent(TaskdetailsGeneralFieldsComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
it('should call to getClassificationsByDomain', done => { it('should call to getClassificationsByDomain', done => {
component.ngOnInit(); component.ngOnInit();
expect(classificationsService.getClassificationsByDomain).toHaveBeenCalled(); expect(classificationsService.getClassificationsByDomain).toHaveBeenCalled();
done(); done();
}); });
}); });

View File

@ -8,82 +8,82 @@ import { NgForm } from '@angular/forms';
import { DomainService } from 'app/services/domain/domain.service'; import { DomainService } from 'app/services/domain/domain.service';
@Component({ @Component({
selector: 'taskana-task-details-general-fields', selector: 'taskana-task-details-general-fields',
templateUrl: './general-fields.component.html', templateUrl: './general-fields.component.html',
styleUrls: ['./general-fields.component.scss'] styleUrls: ['./general-fields.component.scss']
}) })
export class TaskdetailsGeneralFieldsComponent implements OnInit, OnChanges { export class TaskdetailsGeneralFieldsComponent implements OnInit, OnChanges {
@Input() @Input()
task: Task; task: Task;
@Output() taskChange: EventEmitter<Task> = new EventEmitter<Task>(); @Output() taskChange: EventEmitter<Task> = new EventEmitter<Task>();
@Input() @Input()
saveToggleTriggered: boolean; saveToggleTriggered: boolean;
@Output() formValid: EventEmitter<boolean> = new EventEmitter<boolean>(); @Output() formValid: EventEmitter<boolean> = new EventEmitter<boolean>();
@ViewChild('TaskForm') @ViewChild('TaskForm')
taskForm: NgForm; taskForm: NgForm;
toogleValidationMap = new Map<string, boolean>(); toogleValidationMap = new Map<string, boolean>();
requestInProgress = false; requestInProgress = false;
classifications: Classification[] = undefined; classifications: Classification[] = undefined;
ownerField = this.customFieldsService.getCustomField( ownerField = this.customFieldsService.getCustomField(
'Owner', 'Owner',
'tasks.information.owner' 'tasks.information.owner'
); );
constructor( constructor(
private classificationService: ClassificationsService, private classificationService: ClassificationsService,
private customFieldsService: CustomFieldsService, private customFieldsService: CustomFieldsService,
private formsValidatorService: FormsValidatorService, private formsValidatorService: FormsValidatorService,
private domainService: DomainService) { private domainService: DomainService) {
}
ngOnInit() {
this.getClassificationByDomain();
}
ngOnChanges(changes: SimpleChanges): void {
if (changes.saveToggleTriggered && changes.saveToggleTriggered.currentValue !== changes.saveToggleTriggered.previousValue) {
this.validate();
} }
}
selectClassification(classification: Classification) { ngOnInit() {
this.task.classificationSummaryResource = classification; this.getClassificationByDomain();
}
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() { ngOnChanges(changes: SimpleChanges): void {
this.formsValidatorService.formSubmitAttempt = true; if (changes.saveToggleTriggered && changes.saveToggleTriggered.currentValue !== changes.saveToggleTriggered.previousValue) {
this.formsValidatorService this.validate();
.validateFormInformation(this.taskForm, this.toogleValidationMap)
.then(value => {
if (value) {
this.formValid.emit(true);
} }
}); }
}
private changedClassification(itemSelected: any) { selectClassification(classification: Classification) {
this.task.classificationSummaryResource = itemSelected; this.task.classificationSummaryResource = classification;
} }
private async getClassificationByDomain() { isFieldValid(field: string): boolean {
this.requestInProgress = true; return this.formsValidatorService.isFieldValid(this.taskForm, field);
this.classifications = (await this.classificationService.getClassificationsByDomain(this.domainService.getSelectedDomainValue())) }
._embedded.classificationSummaryResourceList;
this.requestInProgress = false; 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;
}
} }

View File

@ -56,7 +56,7 @@ export class TaskListToolbarComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.workbasketService.getAllWorkBaskets().subscribe(workbaskets => { this.workbasketService.getAllWorkBaskets().subscribe(workbaskets => {
this.workbaskets = workbaskets._embedded ? workbaskets._embedded.workbaskets : []; this.workbaskets = workbaskets.workbaskets;
this.workbaskets.forEach(workbasket => { this.workbaskets.forEach(workbasket => {
this.workbasketNames.push(workbasket.name); this.workbasketNames.push(workbasket.name);
}); });

View File

@ -142,8 +142,8 @@ export class TaskMasterComponent implements OnInit, OnDestroy {
this.objectReference ? this.objectReference.value : undefined) this.objectReference ? this.objectReference.value : undefined)
.subscribe(tasks => { .subscribe(tasks => {
this.requestInProgress = false; this.requestInProgress = false;
if (tasks._embedded) { if (tasks.tasks) {
this.tasks = tasks._embedded.tasks; this.tasks = tasks.tasks;
} else { } else {
this.tasks = []; this.tasks = [];
this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'The selected Workbasket is empty!')); this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'The selected Workbasket is empty!'));

View File

@ -5,6 +5,6 @@
export const environment = { export const environment = {
production: false, production: false,
taskanaRestUrl: 'http://localhost:8080', taskanaRestUrl: 'http://localhost:8080/api',
taskanaLogoutUrl: 'http://localhost:8080/logout' taskanaLogoutUrl: 'http://localhost:8080/logout'
}; };