TSK-1083: Updated HATEOAS from version 0.24.0 to version 1.0.4
This commit is contained in:
parent
cdfaa13401
commit
a8e44dead3
|
@ -198,7 +198,7 @@ public class TaskHistoryEventController extends AbstractPagingController {
|
|||
TaskanaHistoryEvent resultEvent = simpleHistoryService.getHistoryEvent(historyEventId);
|
||||
|
||||
TaskHistoryEventResource taskEventResource =
|
||||
taskHistoryEventResourceAssembler.toResource(resultEvent);
|
||||
taskHistoryEventResourceAssembler.toModel(resultEvent);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package pro.taskana.simplehistory.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.Link;
|
||||
|
||||
import pro.taskana.rest.resource.AbstractRessourcesAssembler;
|
||||
|
@ -17,7 +19,8 @@ public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAss
|
|||
List<HistoryEventImpl> historyEvents, PageMetadata pageMetadata) {
|
||||
|
||||
TaskHistoryEventResourceAssembler assembler = new TaskHistoryEventResourceAssembler();
|
||||
List<TaskHistoryEventResource> resources = assembler.toResources(historyEvents);
|
||||
List<TaskHistoryEventResource> resources =
|
||||
new ArrayList<>(assembler.toCollectionModel(historyEvents).getContent());
|
||||
TaskHistoryEventListResource pagedResources =
|
||||
new TaskHistoryEventListResource(resources, pageMetadata);
|
||||
|
||||
|
@ -26,20 +29,20 @@ public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAss
|
|||
pagedResources.add(linkTo(TaskHistoryEventController.class).withRel("allTaskHistoryEvent"));
|
||||
pagedResources.add(
|
||||
new Link(this.getOriginal().replaceQueryParam("page", 1).toUriString())
|
||||
.withRel(Link.REL_FIRST));
|
||||
.withRel(IanaLinkRelations.FIRST));
|
||||
pagedResources.add(
|
||||
new Link(
|
||||
this.getOriginal()
|
||||
.replaceQueryParam("page", pageMetadata.getTotalPages())
|
||||
.toUriString())
|
||||
.withRel(Link.REL_LAST));
|
||||
.withRel(IanaLinkRelations.LAST));
|
||||
if (pageMetadata.getNumber() > 1) {
|
||||
pagedResources.add(
|
||||
new Link(
|
||||
this.getOriginal()
|
||||
.replaceQueryParam("page", pageMetadata.getNumber() - 1)
|
||||
.toUriString())
|
||||
.withRel(Link.REL_PREVIOUS));
|
||||
.withRel(IanaLinkRelations.PREV));
|
||||
}
|
||||
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
|
||||
pagedResources.add(
|
||||
|
@ -47,7 +50,7 @@ public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAss
|
|||
this.getOriginal()
|
||||
.replaceQueryParam("page", pageMetadata.getNumber() + 1)
|
||||
.toUriString())
|
||||
.withRel(Link.REL_NEXT));
|
||||
.withRel(IanaLinkRelations.NEXT));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package pro.taskana.simplehistory.rest.resource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
|
||||
|
||||
/** Resource class for {@link TaskanaHistoryEvent}. */
|
||||
public class TaskHistoryEventResource extends ResourceSupport {
|
||||
public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEventResource> {
|
||||
|
||||
@NotNull private String taskHistoryEventId;
|
||||
private String businessProcessId;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package pro.taskana.simplehistory.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.simplehistory.impl.HistoryEventImpl;
|
||||
|
@ -14,15 +14,15 @@ import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundExcepti
|
|||
|
||||
/** Transforms any {@link HistoryEventImpl} into its {@link TaskHistoryEventResource}. */
|
||||
public class TaskHistoryEventResourceAssembler
|
||||
extends ResourceAssemblerSupport<TaskanaHistoryEvent, TaskHistoryEventResource> {
|
||||
extends RepresentationModelAssemblerSupport<TaskanaHistoryEvent, TaskHistoryEventResource> {
|
||||
|
||||
public TaskHistoryEventResourceAssembler() {
|
||||
super(HistoryEventImpl.class, TaskHistoryEventResource.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskHistoryEventResource toResource(TaskanaHistoryEvent historyEvent) {
|
||||
TaskHistoryEventResource resource = createResourceWithId(historyEvent.getId(), historyEvent);
|
||||
public TaskHistoryEventResource toModel(TaskanaHistoryEvent historyEvent) {
|
||||
TaskHistoryEventResource resource = createModelWithId(historyEvent.getId(), historyEvent);
|
||||
try {
|
||||
resource.removeLinks();
|
||||
resource.add(
|
||||
|
|
|
@ -15,8 +15,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -58,7 +58,7 @@ public class TaskHistoryEventControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(45);
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,15 @@ public class TaskHistoryEventControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(3);
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF).getHref().endsWith(parameters)).isTrue();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(parameters))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -89,7 +95,7 @@ public class TaskHistoryEventControllerIntTest {
|
|||
request,
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
|
||||
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLinks()).isNotNull();
|
||||
assertThat(response.getBody().getMetadata()).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(1);
|
||||
|
@ -105,7 +111,7 @@ public class TaskHistoryEventControllerIntTest {
|
|||
request,
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventResource.class));
|
||||
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLinks()).isNotNull();
|
||||
assertThat(response.getBody().getDetails()).isNotNull();
|
||||
}
|
||||
|
@ -153,7 +159,7 @@ public class TaskHistoryEventControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(23);
|
||||
}
|
||||
|
||||
|
@ -171,18 +177,24 @@ public class TaskHistoryEventControllerIntTest {
|
|||
assertThat(response.getBody().getContent()).hasSize(2);
|
||||
assertThat(response.getBody().getContent().iterator().next().getWorkbasketKey())
|
||||
.isEqualTo("WBI:100000000000000000000000000000000002");
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF).getHref().endsWith(parameters)).isTrue();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(parameters))
|
||||
.isTrue();
|
||||
assertThat(response.getBody().getLink("allTaskHistoryEvent")).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getLink("allTaskHistoryEvent")
|
||||
.getRequiredLink("allTaskHistoryEvent")
|
||||
.getHref()
|
||||
.endsWith("/api/v1/task-history-event"))
|
||||
.isTrue();
|
||||
assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,7 +58,7 @@ public class TaskHistoryEventResourceAssemblerTest {
|
|||
historyEvent.setCustom4("custom4");
|
||||
|
||||
TaskHistoryEventResource taskHistoryEventResource =
|
||||
taskHistoryEventResourceAssembler.toResource(historyEvent);
|
||||
taskHistoryEventResourceAssembler.toModel(historyEvent);
|
||||
|
||||
testEquality(historyEvent, taskHistoryEventResource);
|
||||
}
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -57,7 +57,7 @@
|
|||
<version.spring.boot>2.2.6.RELEASE</version.spring.boot>
|
||||
<version.spring.restdocs>2.0.4.RELEASE</version.spring.restdocs>
|
||||
<version.spring.mybatis>2.0.4</version.spring.mybatis>
|
||||
<version.spring.hateos>0.24.0.RELEASE</version.spring.hateos>
|
||||
<version.spring.hateos>1.0.4.RELEASE</version.spring.hateos>
|
||||
<version.spring.ldap>2.3.2.RELEASE</version.spring.ldap>
|
||||
|
||||
<!-- wildfly dependencies -->
|
||||
|
@ -78,7 +78,7 @@
|
|||
<version.archunit>0.13.1</version.archunit>
|
||||
<version.mockito>3.3.3</version.mockito>
|
||||
<version.junit.mockito>3.3.3</version.junit.mockito>
|
||||
<!-- byte buddy 1.9.7+ is needed to solve dependency errors with
|
||||
<!-- byte buddy 1.9.7+ is needed to solve dependency errors with
|
||||
spring mock tests see LdapClientTest -->
|
||||
<version.byte-buddy>1.10.9</version.byte-buddy>
|
||||
<version.byte-buddy-agent>1.10.9</version.byte-buddy-agent>
|
||||
|
@ -250,7 +250,7 @@
|
|||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- This plugin appends version information into the jar, so
|
||||
<!-- This plugin appends version information into the jar, so
|
||||
that it can be extracted from the jar. See TSK-837 for more information -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -71,7 +71,7 @@ class AsyncUpdateJobIntTest {
|
|||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
ClassificationResource classification = response.getBody();
|
||||
assertThat(classification.getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(classification.getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
|
||||
// 2nd step: modify classification and trigger update
|
||||
classification.removeLinks();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>taskana-rest-spring</artifactId>
|
||||
|
||||
|
@ -83,6 +83,11 @@
|
|||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>${version.aspectjweaver}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<groupId>org.springframework</groupId>
|
||||
<version>${version.spring}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
|
@ -198,4 +203,4 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
</project>
|
|
@ -110,7 +110,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
|
||||
ResponseEntity<ClassificationSummaryListResource> response =
|
||||
ResponseEntity.ok(
|
||||
classificationSummaryResourceAssembler.toResources(
|
||||
classificationSummaryResourceAssembler.toCollectionModel(
|
||||
classificationSummaries, pageMetadata));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getClassifications(), returning {}", response);
|
||||
|
@ -119,7 +119,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
return response;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_CLASSIFICATIONS_ID, produces = MediaTypes.HAL_JSON_UTF8_VALUE)
|
||||
@GetMapping(path = Mapping.URL_CLASSIFICATIONS_ID, produces = MediaTypes.HAL_JSON_VALUE)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<ClassificationResource> getClassification(
|
||||
@PathVariable String classificationId) throws ClassificationNotFoundException {
|
||||
|
@ -129,7 +129,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
|
||||
Classification classification = classificationService.getClassification(classificationId);
|
||||
ResponseEntity<ClassificationResource> response =
|
||||
ResponseEntity.ok(classificationResourceAssembler.toResource(classification));
|
||||
ResponseEntity.ok(classificationResourceAssembler.toModel(classification));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getClassification(), returning {}", response);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
|
||||
ResponseEntity<ClassificationResource> response =
|
||||
ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(classificationResourceAssembler.toResource(classification));
|
||||
.body(classificationResourceAssembler.toModel(classification));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createClassification(), returning {}", response);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
if (classificationId.equals(resource.getClassificationId())) {
|
||||
Classification classification = classificationResourceAssembler.toModel(resource);
|
||||
classification = classificationService.updateClassification(classification);
|
||||
result = ResponseEntity.ok(classificationResourceAssembler.toResource(classification));
|
||||
result = ResponseEntity.ok(classificationResourceAssembler.toModel(classification));
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
"ClassificationId ('"
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MonitorController {
|
|||
LOGGER.debug("Entry to getTasksStatusReport()");
|
||||
ResponseEntity<ReportResource> response =
|
||||
ResponseEntity.ok(
|
||||
reportResourceAssembler.toResource(
|
||||
reportResourceAssembler.toModel(
|
||||
monitorService
|
||||
.createTaskStatusReportBuilder()
|
||||
.stateIn(states)
|
||||
|
@ -72,7 +72,7 @@ public class MonitorController {
|
|||
LOGGER.debug("Entry to getTasksWorkbasketReport()");
|
||||
|
||||
ReportResource report =
|
||||
reportResourceAssembler.toResource(
|
||||
reportResourceAssembler.toModel(
|
||||
monitorService
|
||||
.createWorkbasketReportBuilder()
|
||||
.withColumnHeaders(getRangeTimeInterval())
|
||||
|
@ -95,7 +95,7 @@ public class MonitorController {
|
|||
LOGGER.debug("Entry to getTasksWorkbasketPlannedDateReport()");
|
||||
|
||||
ReportResource report =
|
||||
reportResourceAssembler.toResource(
|
||||
reportResourceAssembler.toModel(
|
||||
monitorService
|
||||
.createWorkbasketReportBuilder()
|
||||
.stateIn(states)
|
||||
|
@ -117,7 +117,7 @@ public class MonitorController {
|
|||
LOGGER.debug("Entry to getTasksClassificationReport()");
|
||||
|
||||
ReportResource report =
|
||||
reportResourceAssembler.toResource(
|
||||
reportResourceAssembler.toModel(
|
||||
monitorService
|
||||
.createClassificationReportBuilder()
|
||||
.withColumnHeaders(getRangeTimeInterval())
|
||||
|
@ -140,7 +140,7 @@ public class MonitorController {
|
|||
.collect(Collectors.toList());
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
reportResourceAssembler.toResource(
|
||||
reportResourceAssembler.toModel(
|
||||
monitorService
|
||||
.createTimestampReportBuilder()
|
||||
.withColumnHeaders(columnHeaders)
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TaskCommentController {
|
|||
|
||||
TaskComment taskComment = taskService.getTaskComment(taskCommentId);
|
||||
|
||||
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toResource(taskComment);
|
||||
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toModel(taskComment);
|
||||
|
||||
ResponseEntity<TaskCommentResource> response = ResponseEntity.ok(taskCommentResource);
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class TaskCommentController {
|
|||
TaskComment taskComment = taskCommentResourceAssembler.toModel(taskCommentResource);
|
||||
|
||||
taskComment = taskService.updateTaskComment(taskComment);
|
||||
result = ResponseEntity.ok(taskCommentResourceAssembler.toResource(taskComment));
|
||||
result = ResponseEntity.ok(taskCommentResourceAssembler.toModel(taskComment));
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
String.format(
|
||||
|
@ -165,7 +165,7 @@ public class TaskCommentController {
|
|||
|
||||
result =
|
||||
ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(taskCommentResourceAssembler.toResource(createdTaskComment));
|
||||
.body(taskCommentResourceAssembler.toModel(createdTaskComment));
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createTaskComment(), returning {}", result);
|
||||
|
|
|
@ -119,7 +119,7 @@ public class TaskController extends AbstractPagingController {
|
|||
List<TaskSummary> taskSummaries = getQueryList(query, pageMetadata);
|
||||
|
||||
TaskSummaryListResource pagedResources =
|
||||
taskSummaryResourceAssembler.toResources(taskSummaries, pageMetadata);
|
||||
taskSummaryResourceAssembler.toCollectionModel(taskSummaries, pageMetadata);
|
||||
ResponseEntity<TaskSummaryListResource> response = ResponseEntity.ok(pagedResources);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasks(), returning {}", response);
|
||||
|
@ -134,7 +134,7 @@ public class TaskController extends AbstractPagingController {
|
|||
throws TaskNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug("Entry to getTask(taskId= {})", taskId);
|
||||
Task task = taskService.getTask(taskId);
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toResource(task));
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toModel(task));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTask(), returning {}", result);
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class TaskController extends AbstractPagingController {
|
|||
taskService.claim(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
|
||||
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from claimTask(), returning {}", result);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public class TaskController extends AbstractPagingController {
|
|||
Task updatedTask = taskService.getTask(taskId);
|
||||
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
|
||||
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from cancelClaimTask(), returning {}", result);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public class TaskController extends AbstractPagingController {
|
|||
taskService.forceCompleteTask(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
|
||||
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from completeTask(), returning {}", result);
|
||||
}
|
||||
|
@ -221,8 +221,7 @@ public class TaskController extends AbstractPagingController {
|
|||
Task createdTask = taskService.createTask(fromResource);
|
||||
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(taskResourceAssembler.toResource(createdTask));
|
||||
ResponseEntity.status(HttpStatus.CREATED).body(taskResourceAssembler.toModel(createdTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createTask(), returning {}", result);
|
||||
}
|
||||
|
@ -239,7 +238,7 @@ public class TaskController extends AbstractPagingController {
|
|||
LOGGER.debug("Entry to transferTask(taskId= {}, workbasketId= {})", taskId, workbasketId);
|
||||
Task updatedTask = taskService.transfer(taskId, workbasketId);
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.ok(taskResourceAssembler.toResource(updatedTask));
|
||||
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from transferTask(), returning {}", result);
|
||||
}
|
||||
|
@ -259,7 +258,7 @@ public class TaskController extends AbstractPagingController {
|
|||
if (taskId.equals(taskResource.getTaskId())) {
|
||||
Task task = taskResourceAssembler.toModel(taskResource);
|
||||
task = taskService.updateTask(task);
|
||||
result = ResponseEntity.ok(taskResourceAssembler.toResource(task));
|
||||
result = ResponseEntity.ok(taskResourceAssembler.toModel(task));
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
String.format(
|
||||
|
|
|
@ -74,7 +74,8 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
List<WorkbasketAccessItem> workbasketAccessItems = getQueryList(query, pageMetadata);
|
||||
|
||||
WorkbasketAccessItemListResource pagedResources =
|
||||
workbasketAccessItemResourceAssembler.toResources(workbasketAccessItems, pageMetadata);
|
||||
workbasketAccessItemResourceAssembler.toCollectionModel(
|
||||
workbasketAccessItems, pageMetadata);
|
||||
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity.ok(pagedResources);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.CollectionModel;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.Resources;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -112,7 +112,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<WorkbasketSummary> workbasketSummaries = getQueryList(query, pageMetadata);
|
||||
WorkbasketSummaryListResource pagedResources =
|
||||
workbasketSummaryResourceAssembler.toResources(workbasketSummaries, pageMetadata);
|
||||
workbasketSummaryResourceAssembler.toCollectionModel(workbasketSummaries, pageMetadata);
|
||||
|
||||
ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity.ok(pagedResources);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
@ -122,7 +122,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
return response;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_WORKBASKET_ID, produces = MediaTypes.HAL_JSON_UTF8_VALUE)
|
||||
@GetMapping(path = Mapping.URL_WORKBASKET_ID, produces = MediaTypes.HAL_JSON_VALUE)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketResource> getWorkbasket(
|
||||
@PathVariable(value = "workbasketId") String workbasketId)
|
||||
|
@ -130,7 +130,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
LOGGER.debug("Entry to getWorkbasket(workbasketId= {})", workbasketId);
|
||||
ResponseEntity<WorkbasketResource> result;
|
||||
Workbasket workbasket = workbasketService.getWorkbasket(workbasketId);
|
||||
result = ResponseEntity.ok(workbasketResourceAssembler.toResource(workbasket));
|
||||
result = ResponseEntity.ok(workbasketResourceAssembler.toModel(workbasket));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbasket(), returning {}", result);
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
workbasket = workbasketService.createWorkbasket(workbasket);
|
||||
ResponseEntity<WorkbasketResource> response =
|
||||
ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(workbasketResourceAssembler.toResource(workbasket));
|
||||
.body(workbasketResourceAssembler.toModel(workbasket));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createWorkbasket(), returning {}", response);
|
||||
}
|
||||
|
@ -196,13 +196,13 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
if (workbasketId.equals(workbasketResource.getWorkbasketId())) {
|
||||
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource);
|
||||
workbasket = workbasketService.updateWorkbasket(workbasket);
|
||||
result = ResponseEntity.ok(workbasketResourceAssembler.toResource(workbasket));
|
||||
result = ResponseEntity.ok(workbasketResourceAssembler.toModel(workbasket));
|
||||
} else {
|
||||
throw new InvalidWorkbasketException(
|
||||
"Target-WB-ID('"
|
||||
+ workbasketId
|
||||
+ "') is not identical with the WB-ID of to object which should be updated. ID=('"
|
||||
+ workbasketResource.getId()
|
||||
+ workbasketResource.getWorkbasketId()
|
||||
+ "')");
|
||||
}
|
||||
|
||||
|
@ -213,9 +213,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
return result;
|
||||
}
|
||||
|
||||
@GetMapping(
|
||||
path = Mapping.URL_WORKBASKET_ID_ACCESSITEMS,
|
||||
produces = MediaTypes.HAL_JSON_UTF8_VALUE)
|
||||
@GetMapping(path = Mapping.URL_WORKBASKET_ID_ACCESSITEMS, produces = MediaTypes.HAL_JSON_VALUE)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketAccessItemListResource> getWorkbasketAccessItems(
|
||||
@PathVariable(value = "workbasketId") String workbasketId)
|
||||
|
@ -227,7 +225,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
workbasketService.getWorkbasketAccessItems(workbasketId);
|
||||
result =
|
||||
ResponseEntity.ok(
|
||||
workbasketAccessItemResourceAssembler.toResources(workbasketId, accessItems));
|
||||
workbasketAccessItemResourceAssembler.toCollectionModel(workbasketId, accessItems));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result);
|
||||
}
|
||||
|
@ -256,7 +254,8 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response =
|
||||
ResponseEntity.ok(
|
||||
workbasketAccessItemResourceAssembler.toResources(workbasketId, updatedWbAccessItems));
|
||||
workbasketAccessItemResourceAssembler.toCollectionModel(
|
||||
workbasketId, updatedWbAccessItems));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response);
|
||||
}
|
||||
|
@ -264,9 +263,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
return response;
|
||||
}
|
||||
|
||||
@GetMapping(
|
||||
path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION,
|
||||
produces = MediaTypes.HAL_JSON_UTF8_VALUE)
|
||||
@GetMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION, produces = MediaTypes.HAL_JSON_VALUE)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<DistributionTargetListResource> getDistributionTargets(
|
||||
@PathVariable(value = "workbasketId") String workbasketId)
|
||||
|
@ -276,7 +273,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
List<WorkbasketSummary> distributionTargets =
|
||||
workbasketService.getDistributionTargets(workbasketId);
|
||||
DistributionTargetListResource distributionTargetListResource =
|
||||
distributionTargetResourceAssembler.toResources(workbasketId, distributionTargets);
|
||||
distributionTargetResourceAssembler.toCollectionModel(workbasketId, distributionTargets);
|
||||
ResponseEntity<DistributionTargetListResource> result =
|
||||
ResponseEntity.ok(distributionTargetListResource);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
@ -305,7 +302,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
workbasketService.getDistributionTargets(sourceWorkbasketId);
|
||||
ResponseEntity<DistributionTargetListResource> response =
|
||||
ResponseEntity.ok(
|
||||
distributionTargetResourceAssembler.toResources(
|
||||
distributionTargetResourceAssembler.toCollectionModel(
|
||||
sourceWorkbasketId, distributionTargets));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
|
||||
|
@ -317,7 +314,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
// TODO - schema inconsistent with PUT and GET
|
||||
@DeleteMapping(path = Mapping.URL_WORKBASKET_DISTRIBUTION_ID)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Resources<DistributionTargetResource>>
|
||||
public ResponseEntity<CollectionModel<DistributionTargetResource>>
|
||||
removeDistributionTargetForWorkbasketId(
|
||||
@PathVariable(value = "workbasketId") String targetWorkbasketId)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
|
@ -330,7 +327,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
workbasketService.removeDistributionTarget(source.getId(), targetWorkbasketId);
|
||||
}
|
||||
|
||||
ResponseEntity<Resources<DistributionTargetResource>> response =
|
||||
ResponseEntity<CollectionModel<DistributionTargetResource>> response =
|
||||
ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from removeDistributionTargetForWorkbasketId(), returning {}", response);
|
||||
return response;
|
||||
|
|
|
@ -74,7 +74,7 @@ public class WorkbasketDefinitionController {
|
|||
List<WorkbasketDefinitionResource> basketExports = new ArrayList<>();
|
||||
for (WorkbasketSummary summary : workbasketSummaryList) {
|
||||
Workbasket workbasket = workbasketService.getWorkbasket(summary.getId());
|
||||
basketExports.add(workbasketDefinitionAssembler.toResource(workbasket));
|
||||
basketExports.add(workbasketDefinitionAssembler.toModel(workbasket));
|
||||
}
|
||||
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response = ResponseEntity.ok(basketExports);
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|||
* deprecated, it can be removed after fixing taskana-simple-history references
|
||||
*/
|
||||
// TODO: @Deprecated
|
||||
// TODO: please remove spring-webmvc dependency
|
||||
public abstract class AbstractRessourcesAssembler {
|
||||
|
||||
UriComponentsBuilder original = getBuilderForOriginalUri();
|
||||
|
|
|
@ -2,13 +2,13 @@ package pro.taskana.rest.resource;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.task.api.models.Attachment;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
|
||||
/** Resource class for {@link Attachment}. */
|
||||
public class AttachmentResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link Attachment}. */
|
||||
public class AttachmentResource extends RepresentationModel<AttachmentResource> {
|
||||
|
||||
private String attachmentId;
|
||||
private String taskId;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.rest.AttachmentController;
|
||||
|
@ -14,10 +14,10 @@ import pro.taskana.task.api.TaskService;
|
|||
import pro.taskana.task.api.models.Attachment;
|
||||
import pro.taskana.task.internal.models.AttachmentImpl;
|
||||
|
||||
/** Resource assembler for {@link AttachmentResource}. */
|
||||
/** EntityModel assembler for {@link AttachmentResource}. */
|
||||
@Component
|
||||
public class AttachmentResourceAssembler
|
||||
extends ResourceAssemblerSupport<Attachment, AttachmentResource> {
|
||||
extends RepresentationModelAssemblerSupport<Attachment, AttachmentResource> {
|
||||
|
||||
@Autowired private TaskService taskService;
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class AttachmentResourceAssembler
|
|||
}
|
||||
|
||||
@Override
|
||||
public AttachmentResource toResource(Attachment attachment) {
|
||||
public AttachmentResource toModel(Attachment attachment) {
|
||||
AttachmentResource resource = new AttachmentResource(attachment);
|
||||
resource.add(linkTo(AttachmentController.class).slash(attachment.getId()).withSelfRel());
|
||||
return resource;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.task.api.models.AttachmentSummary;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
|
||||
/** Resource class for {@link AttachmentSummary}. */
|
||||
public class AttachmentSummaryResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link AttachmentSummary}. */
|
||||
public class AttachmentSummaryResource extends RepresentationModel<AttachmentSummaryResource> {
|
||||
|
||||
private String attachmentId;
|
||||
private String taskId;
|
||||
|
|
|
@ -1,28 +1,22 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.rest.AttachmentController;
|
||||
import pro.taskana.task.api.models.AttachmentSummary;
|
||||
|
||||
/** Resource assembler for {@link AttachmentSummaryResource}. */
|
||||
/** EntityModel assembler for {@link AttachmentSummaryResource}. */
|
||||
@Component
|
||||
public class AttachmentSummaryResourceAssembler
|
||||
extends ResourceAssemblerSupport<AttachmentSummary, AttachmentSummaryResource> {
|
||||
extends RepresentationModelAssemblerSupport<AttachmentSummary, AttachmentSummaryResource> {
|
||||
|
||||
public AttachmentSummaryResourceAssembler() {
|
||||
super(AttachmentController.class, AttachmentSummaryResource.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachmentSummaryResource toResource(AttachmentSummary attachmentSummary) {
|
||||
public AttachmentSummaryResource toModel(AttachmentSummary attachmentSummary) {
|
||||
return new AttachmentSummaryResource(attachmentSummary);
|
||||
}
|
||||
|
||||
public List<AttachmentSummaryResource> toResources(List<AttachmentSummary> attachmentSummaries) {
|
||||
List<AttachmentSummaryResource> resources = super.toResources(attachmentSummaries);
|
||||
return resources;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
|
||||
/** Resource class for {@link Classification}. */
|
||||
public class ClassificationResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link Classification}. */
|
||||
public class ClassificationResource extends RepresentationModel<ClassificationResource> {
|
||||
|
||||
@NotNull private String classificationId;
|
||||
@NotNull private String key;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import java.time.Instant;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
|
@ -22,7 +22,7 @@ import pro.taskana.rest.ClassificationController;
|
|||
*/
|
||||
@Component
|
||||
public class ClassificationResourceAssembler
|
||||
extends ResourceAssemblerSupport<Classification, ClassificationResource> {
|
||||
extends RepresentationModelAssemblerSupport<Classification, ClassificationResource> {
|
||||
|
||||
final ClassificationService classificationService;
|
||||
|
||||
|
@ -32,7 +32,14 @@ public class ClassificationResourceAssembler
|
|||
this.classificationService = classificationService;
|
||||
}
|
||||
|
||||
public ClassificationResource toResource(Classification classification) {
|
||||
public ClassificationResource toDefinition(Classification classification) {
|
||||
ClassificationResource resource = new ClassificationResource(classification);
|
||||
resource.add(
|
||||
linkTo(ClassificationController.class).slash(classification.getId()).withSelfRel());
|
||||
return resource;
|
||||
}
|
||||
|
||||
public ClassificationResource toModel(Classification classification) {
|
||||
ClassificationResource resource = new ClassificationResource(classification);
|
||||
try {
|
||||
resource.add(
|
||||
|
@ -44,13 +51,6 @@ public class ClassificationResourceAssembler
|
|||
return resource;
|
||||
}
|
||||
|
||||
public ClassificationResource toDefinition(Classification classification) {
|
||||
ClassificationResource resource = new ClassificationResource(classification);
|
||||
resource.add(
|
||||
linkTo(ClassificationController.class).slash(classification.getId()).withSelfRel());
|
||||
return resource;
|
||||
}
|
||||
|
||||
public Classification toModel(ClassificationResource classificationResource) {
|
||||
ClassificationImpl classification =
|
||||
(ClassificationImpl)
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import java.util.Collection;
|
||||
import org.springframework.hateoas.Link;
|
||||
|
||||
/** Resource class for {@link ClassificationSummaryResource} with Pagination. */
|
||||
/** EntityModel class for {@link ClassificationSummaryResource} with Pagination. */
|
||||
public class ClassificationSummaryListResource
|
||||
extends PagedResources<ClassificationSummaryResource> {
|
||||
|
||||
|
@ -12,13 +12,6 @@ public class 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);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
|
||||
/** Resource class for {@link ClassificationSummary}. */
|
||||
public class ClassificationSummaryResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link ClassificationSummary}. */
|
||||
public class ClassificationSummaryResource
|
||||
extends RepresentationModel<ClassificationSummaryResource> {
|
||||
|
||||
private String classificationId;
|
||||
private String applicationEntryPoint;
|
||||
|
|
|
@ -3,7 +3,7 @@ package pro.taskana.rest.resource;
|
|||
import java.util.Collection;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
|
@ -14,10 +14,11 @@ import pro.taskana.rest.Mapping;
|
|||
import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
||||
import pro.taskana.rest.resource.links.PageLinks;
|
||||
|
||||
/** Resource assembler for {@link ClassificationSummaryResource}. */
|
||||
/** EntityModel assembler for {@link ClassificationSummaryResource}. */
|
||||
@Component
|
||||
public class ClassificationSummaryResourceAssembler
|
||||
extends ResourceAssemblerSupport<ClassificationSummary, ClassificationSummaryResource> {
|
||||
extends RepresentationModelAssemblerSupport<
|
||||
ClassificationSummary, ClassificationSummaryResource> {
|
||||
|
||||
@Autowired private ClassificationService classificationService;
|
||||
|
||||
|
@ -26,7 +27,7 @@ public class ClassificationSummaryResourceAssembler
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClassificationSummaryResource toResource(ClassificationSummary classificationSummary) {
|
||||
public ClassificationSummaryResource toModel(ClassificationSummary classificationSummary) {
|
||||
return new ClassificationSummaryResource(classificationSummary);
|
||||
}
|
||||
|
||||
|
@ -41,8 +42,9 @@ public class ClassificationSummaryResourceAssembler
|
|||
}
|
||||
|
||||
@PageLinks(Mapping.URL_CLASSIFICATIONS)
|
||||
public ClassificationSummaryListResource toResources(
|
||||
public ClassificationSummaryListResource toCollectionModel(
|
||||
Collection<ClassificationSummary> entities, PageMetadata pageMetadata) {
|
||||
return new ClassificationSummaryListResource(toResources(entities), pageMetadata);
|
||||
return new ClassificationSummaryListResource(
|
||||
toCollectionModel(entities).getContent(), pageMetadata);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import java.util.Collection;
|
||||
import org.springframework.hateoas.Link;
|
||||
|
||||
/** Resource class for {@link DistributionTargetResource} with Pagination. */
|
||||
/** EntityModel class for {@link DistributionTargetResource} with Pagination. */
|
||||
public class DistributionTargetListResource extends PagedResources<DistributionTargetResource> {
|
||||
|
||||
public DistributionTargetListResource() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import org.springframework.hateoas.core.Relation;
|
||||
import org.springframework.hateoas.server.core.Relation;
|
||||
|
||||
import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
||||
|
||||
/** Resource class for a distribution target based on {@link WorkbasketSummary}. */
|
||||
/** EntityModel class for a distribution target based on {@link WorkbasketSummary}. */
|
||||
@Relation(collectionRelation = "distributionTargets")
|
||||
public class DistributionTargetResource extends WorkbasketSummaryResource {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
|
@ -18,22 +18,22 @@ import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
|||
*/
|
||||
@Component
|
||||
public class DistributionTargetResourceAssembler
|
||||
extends ResourceAssemblerSupport<WorkbasketSummary, DistributionTargetResource> {
|
||||
extends RepresentationModelAssemblerSupport<WorkbasketSummary, DistributionTargetResource> {
|
||||
|
||||
public DistributionTargetResourceAssembler() {
|
||||
super(WorkbasketController.class, DistributionTargetResource.class);
|
||||
}
|
||||
|
||||
public DistributionTargetResource toResource(WorkbasketSummary summary) {
|
||||
public DistributionTargetResource toModel(WorkbasketSummary summary) {
|
||||
return new DistributionTargetResource(summary);
|
||||
}
|
||||
|
||||
public DistributionTargetListResource toResources(
|
||||
public DistributionTargetListResource toCollectionModel(
|
||||
String workbasketId, List<WorkbasketSummary> distributionTargets)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
|
||||
DistributionTargetListResource distributionTargetListResource =
|
||||
new DistributionTargetListResource(toResources(distributionTargets));
|
||||
new DistributionTargetListResource(toCollectionModel(distributionTargets).getContent());
|
||||
distributionTargetListResource.add(
|
||||
linkTo(methodOn(WorkbasketController.class).getDistributionTargets(workbasketId))
|
||||
.withSelfRel());
|
||||
|
|
|
@ -8,15 +8,15 @@ import java.util.Collections;
|
|||
import java.util.Objects;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base Class for Resources with pagination.
|
||||
* Base Class for CollectionModel with pagination.
|
||||
*
|
||||
* @param <T> The Class of the paginatied content
|
||||
*/
|
||||
public class PagedResources<T> extends ResourceSupport {
|
||||
public class PagedResources<T> extends RepresentationModel<PagedResources<T>> {
|
||||
|
||||
private Collection<T> content;
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ package pro.taskana.rest.resource;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.monitor.api.reports.Report;
|
||||
import pro.taskana.monitor.api.reports.row.SingleRow;
|
||||
|
||||
/** Resource class for {@link Report}. */
|
||||
public class ReportResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link Report}. */
|
||||
public class ReportResource extends RepresentationModel<ReportResource> {
|
||||
|
||||
private MetaInformation meta;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class ReportResource extends ResourceSupport {
|
|||
return sumRow;
|
||||
}
|
||||
|
||||
/** Resource class for {@link SingleRow}. */
|
||||
/** EntityModel class for {@link SingleRow}. */
|
||||
public static class RowResource {
|
||||
|
||||
private int[] cells;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
|
@ -31,7 +31,7 @@ import pro.taskana.task.api.TaskState;
|
|||
@Component
|
||||
public class ReportResourceAssembler {
|
||||
|
||||
public ReportResource toResource(
|
||||
public ReportResource toModel(
|
||||
TaskStatusReport report, List<String> domains, List<TaskState> states)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
|
@ -42,7 +42,7 @@ public class ReportResourceAssembler {
|
|||
return resource;
|
||||
}
|
||||
|
||||
public ReportResource toResource(ClassificationReport report)
|
||||
public ReportResource toModel(ClassificationReport report)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
resource.add(
|
||||
|
@ -52,7 +52,7 @@ public class ReportResourceAssembler {
|
|||
return resource;
|
||||
}
|
||||
|
||||
public ReportResource toResource(WorkbasketReport report, List<TaskState> states)
|
||||
public ReportResource toModel(WorkbasketReport report, List<TaskState> states)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
resource.add(
|
||||
|
@ -62,7 +62,7 @@ public class ReportResourceAssembler {
|
|||
return resource;
|
||||
}
|
||||
|
||||
public ReportResource toResource(WorkbasketReport report, int daysInPast, List<TaskState> states)
|
||||
public ReportResource toModel(WorkbasketReport report, int daysInPast, List<TaskState> states)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
resource.add(
|
||||
|
@ -74,7 +74,7 @@ public class ReportResourceAssembler {
|
|||
return resource;
|
||||
}
|
||||
|
||||
public ReportResource toResource(TimestampReport report)
|
||||
public ReportResource toModel(TimestampReport report)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
resource.add(
|
||||
|
|
|
@ -2,10 +2,10 @@ package pro.taskana.rest.resource;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
/** Resource class for {@link TaskCommentResource} with Pagination. */
|
||||
public class TaskCommentListResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link TaskCommentResource} with Pagination. */
|
||||
public class TaskCommentListResource extends RepresentationModel<TaskCommentListResource> {
|
||||
|
||||
private List<TaskCommentResource> content;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.task.api.models.TaskComment;
|
||||
|
||||
/** Resource class for {@link TaskComment}. */
|
||||
public class TaskCommentResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link TaskComment}. */
|
||||
public class TaskCommentResource extends RepresentationModel<TaskCommentResource> {
|
||||
|
||||
private String taskCommentId;
|
||||
private String taskId;
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
|
@ -22,10 +24,10 @@ import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.task.api.models.TaskComment;
|
||||
import pro.taskana.task.internal.models.TaskCommentImpl;
|
||||
|
||||
/** Resource assembler for {@link TaskCommentResource}. */
|
||||
/** EntityModel assembler for {@link TaskCommentResource}. */
|
||||
@Component
|
||||
public class TaskCommentResourceAssembler
|
||||
extends ResourceAssemblerSupport<TaskComment, TaskCommentResource> {
|
||||
extends RepresentationModelAssemblerSupport<TaskComment, TaskCommentResource> {
|
||||
|
||||
private final TaskService taskService;
|
||||
|
||||
|
@ -35,15 +37,20 @@ public class TaskCommentResourceAssembler
|
|||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
@PageLinks(Mapping.URL_TASK_COMMENTS)
|
||||
public TaskCommentListResource toListResource(List<TaskComment> taskComments) {
|
||||
Collection<TaskCommentResource> col = toCollectionModel(taskComments).getContent();
|
||||
List<TaskCommentResource> resourceList = new ArrayList<>(col);
|
||||
return new TaskCommentListResource(resourceList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskCommentResource toResource(TaskComment taskComment) {
|
||||
public TaskCommentResource toModel(TaskComment taskComment) {
|
||||
|
||||
TaskCommentResource taskCommentResource = new TaskCommentResource(taskComment);
|
||||
try {
|
||||
taskCommentResource.add(
|
||||
linkTo(
|
||||
methodOn(TaskCommentController.class)
|
||||
.getTaskComment(taskComment.getId()))
|
||||
linkTo(methodOn(TaskCommentController.class).getTaskComment(taskComment.getId()))
|
||||
.withSelfRel());
|
||||
} catch (TaskCommentNotFoundException
|
||||
| TaskNotFoundException
|
||||
|
@ -55,11 +62,6 @@ public class TaskCommentResourceAssembler
|
|||
return taskCommentResource;
|
||||
}
|
||||
|
||||
@PageLinks(Mapping.URL_TASK_COMMENTS)
|
||||
public TaskCommentListResource toListResource(List<TaskComment> taskComments) {
|
||||
return new TaskCommentListResource(toResources(taskComments));
|
||||
}
|
||||
|
||||
public TaskComment toModel(TaskCommentResource taskCommentResource) {
|
||||
|
||||
TaskCommentImpl taskComment =
|
||||
|
|
|
@ -4,15 +4,15 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.task.api.TaskState;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
/** Resource class for {@link Task}. */
|
||||
public class TaskResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link Task}. */
|
||||
public class TaskResource extends RepresentationModel<TaskResource> {
|
||||
|
||||
private String taskId;
|
||||
private String externalId;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
|
@ -20,9 +20,9 @@ import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.internal.models.TaskImpl;
|
||||
|
||||
/** Resource assembler for {@link TaskResource}. */
|
||||
/** EntityModel assembler for {@link TaskResource}. */
|
||||
@Component
|
||||
public class TaskResourceAssembler extends ResourceAssemblerSupport<Task, TaskResource> {
|
||||
public class TaskResourceAssembler extends RepresentationModelAssemblerSupport<Task, TaskResource> {
|
||||
|
||||
private final TaskService taskService;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class TaskResourceAssembler extends ResourceAssemblerSupport<Task, TaskRe
|
|||
}
|
||||
|
||||
@Override
|
||||
public TaskResource toResource(Task task) {
|
||||
public TaskResource toModel(Task task) {
|
||||
TaskResource resource;
|
||||
try {
|
||||
resource = new TaskResource(task);
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import java.util.Collection;
|
||||
import org.springframework.hateoas.Link;
|
||||
|
||||
/** Resource class for {@link TaskSummaryResource} with Pagination. */
|
||||
/** EntityModel class for {@link TaskSummaryResource} with Pagination. */
|
||||
public class TaskSummaryListResource extends PagedResources<TaskSummaryResource> {
|
||||
|
||||
public TaskSummaryListResource() {
|
||||
|
|
|
@ -3,8 +3,8 @@ package pro.taskana.rest.resource;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.core.Relation;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.hateoas.server.core.Relation;
|
||||
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.task.api.TaskState;
|
||||
|
@ -12,9 +12,9 @@ import pro.taskana.task.api.models.ObjectReference;
|
|||
import pro.taskana.task.api.models.TaskSummary;
|
||||
import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
||||
|
||||
/** Resource class for {@link WorkbasketSummary}. */
|
||||
/** EntityModel class for {@link WorkbasketSummary}. */
|
||||
@Relation(collectionRelation = "tasks")
|
||||
public class TaskSummaryResource extends ResourceSupport {
|
||||
public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource> {
|
||||
|
||||
private String taskId;
|
||||
private String externalId;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
|
@ -12,17 +12,17 @@ import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
|||
import pro.taskana.rest.resource.links.PageLinks;
|
||||
import pro.taskana.task.api.models.TaskSummary;
|
||||
|
||||
/** Resource assembler for {@link TaskSummaryResource}. */
|
||||
/** EntityModel assembler for {@link TaskSummaryResource}. */
|
||||
@Component
|
||||
public class TaskSummaryResourceAssembler
|
||||
extends ResourceAssemblerSupport<TaskSummary, TaskSummaryResource> {
|
||||
extends RepresentationModelAssemblerSupport<TaskSummary, TaskSummaryResource> {
|
||||
|
||||
public TaskSummaryResourceAssembler() {
|
||||
super(TaskController.class, TaskSummaryResource.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskSummaryResource toResource(TaskSummary taskSummary) {
|
||||
public TaskSummaryResource toModel(TaskSummary taskSummary) {
|
||||
TaskSummaryResource resource;
|
||||
try {
|
||||
resource = new TaskSummaryResource(taskSummary);
|
||||
|
@ -33,8 +33,8 @@ public class TaskSummaryResourceAssembler
|
|||
}
|
||||
|
||||
@PageLinks(Mapping.URL_TASKS)
|
||||
public TaskSummaryListResource toResources(
|
||||
public TaskSummaryListResource toCollectionModel(
|
||||
List<TaskSummary> taskSummaries, PageMetadata pageMetadata) {
|
||||
return new TaskSummaryListResource(toResources(taskSummaries), pageMetadata);
|
||||
return new TaskSummaryListResource(toCollectionModel(taskSummaries).getContent(), pageMetadata);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ package pro.taskana.rest.resource;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.common.api.LoggerUtils;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
|
||||
/** Resource class for user information. */
|
||||
public class TaskanaUserInfoResource extends ResourceSupport {
|
||||
/** EntityModel class for user information. */
|
||||
public class TaskanaUserInfoResource extends RepresentationModel<TaskanaUserInfoResource> {
|
||||
|
||||
private String userId;
|
||||
private List<String> groupIds = new ArrayList<>();
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
/** Resource class for version information. */
|
||||
public class VersionResource extends ResourceSupport {
|
||||
/** EntityModel class for version information. */
|
||||
public class VersionResource extends RepresentationModel<VersionResource> {
|
||||
|
||||
private String version;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import java.util.Collection;
|
||||
import org.springframework.hateoas.Link;
|
||||
|
||||
/** Resource class for {@link WorkbasketAccessItemResource} with Pagination. */
|
||||
/** EntityModel class for {@link WorkbasketAccessItemResource} with Pagination. */
|
||||
public class WorkbasketAccessItemListResource extends PagedResources<WorkbasketAccessItemResource> {
|
||||
|
||||
public WorkbasketAccessItemListResource() {
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.core.Relation;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.hateoas.server.core.Relation;
|
||||
|
||||
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
|
||||
|
||||
/** Resource class for {@link WorkbasketAccessItem}. */
|
||||
/** EntityModel class for {@link WorkbasketAccessItem}. */
|
||||
@Relation(collectionRelation = "accessItems")
|
||||
public class WorkbasketAccessItemResource extends ResourceSupport {
|
||||
public class WorkbasketAccessItemResource
|
||||
extends RepresentationModel<WorkbasketAccessItemResource> {
|
||||
|
||||
private String accessItemId;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
|
@ -25,7 +25,8 @@ import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
|
|||
*/
|
||||
@Component
|
||||
public class WorkbasketAccessItemResourceAssembler
|
||||
extends ResourceAssemblerSupport<WorkbasketAccessItem, WorkbasketAccessItemResource> {
|
||||
extends RepresentationModelAssemblerSupport<
|
||||
WorkbasketAccessItem, WorkbasketAccessItemResource> {
|
||||
|
||||
@Autowired private WorkbasketService workbasketService;
|
||||
|
||||
|
@ -33,7 +34,7 @@ public class WorkbasketAccessItemResourceAssembler
|
|||
super(WorkbasketController.class, WorkbasketAccessItemResource.class);
|
||||
}
|
||||
|
||||
public WorkbasketAccessItemResource toResource(WorkbasketAccessItem wbAccItem) {
|
||||
public WorkbasketAccessItemResource toModel(WorkbasketAccessItem wbAccItem) {
|
||||
return new WorkbasketAccessItemResource(wbAccItem);
|
||||
}
|
||||
|
||||
|
@ -48,16 +49,17 @@ public class WorkbasketAccessItemResourceAssembler
|
|||
}
|
||||
|
||||
@PageLinks(Mapping.URL_WORKBASKETACCESSITEMS)
|
||||
public WorkbasketAccessItemListResource toResources(
|
||||
public WorkbasketAccessItemListResource toCollectionModel(
|
||||
List<WorkbasketAccessItem> entities, PageMetadata pageMetadata) {
|
||||
return new WorkbasketAccessItemListResource(toResources(entities), pageMetadata);
|
||||
return new WorkbasketAccessItemListResource(
|
||||
toCollectionModel(entities).getContent(), pageMetadata);
|
||||
}
|
||||
|
||||
public WorkbasketAccessItemListResource toResources(
|
||||
public WorkbasketAccessItemListResource toCollectionModel(
|
||||
String workbasketId, List<WorkbasketAccessItem> entities)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
WorkbasketAccessItemListResource accessItemListResource =
|
||||
new WorkbasketAccessItemListResource(super.toResources(entities), null);
|
||||
new WorkbasketAccessItemListResource(super.toCollectionModel(entities).getContent(), null);
|
||||
accessItemListResource.add(
|
||||
linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(workbasketId))
|
||||
.withSelfRel());
|
||||
|
|
|
@ -36,7 +36,7 @@ public class WorkbasketDefinitionResourceAssembler {
|
|||
* @throws NotAuthorizedException if the user is not authorized
|
||||
* @throws WorkbasketNotFoundException if {@code basket} is an unknown workbasket
|
||||
*/
|
||||
public WorkbasketDefinitionResource toResource(Workbasket workbasket)
|
||||
public WorkbasketDefinitionResource toModel(Workbasket workbasket)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
|
||||
WorkbasketResourceWithoutLinks basket = new WorkbasketResourceWithoutLinks(workbasket);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.workbasket.api.WorkbasketType;
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
||||
/** Resource class for {@link Workbasket}. */
|
||||
public class WorkbasketResource extends ResourceSupport {
|
||||
/** EntityModel class for {@link Workbasket}. */
|
||||
public class WorkbasketResource extends RepresentationModel<WorkbasketResource> {
|
||||
|
||||
private String workbasketId;
|
||||
@NotNull private String key;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import java.time.Instant;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import pro.taskana.workbasket.internal.models.WorkbasketImpl;
|
|||
*/
|
||||
@Component
|
||||
public class WorkbasketResourceAssembler
|
||||
extends ResourceAssemblerSupport<Workbasket, WorkbasketResource> {
|
||||
extends RepresentationModelAssemblerSupport<Workbasket, WorkbasketResource> {
|
||||
|
||||
private final WorkbasketService workbasketService;
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class WorkbasketResourceAssembler
|
|||
this.workbasketService = workbasketService;
|
||||
}
|
||||
|
||||
public WorkbasketResource toResource(Workbasket wb) {
|
||||
public WorkbasketResource toModel(Workbasket wb) {
|
||||
try {
|
||||
WorkbasketResource resource = new WorkbasketResource(wb);
|
||||
return addLinks(resource, wb);
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
||||
/** Resource class for {@link Workbasket} but without links property. */
|
||||
/** EntityModel class for {@link Workbasket} but without links property. */
|
||||
@JsonIgnoreProperties(value = {"links"})
|
||||
public class WorkbasketResourceWithoutLinks extends WorkbasketResource {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import java.util.Collection;
|
||||
import org.springframework.hateoas.Link;
|
||||
|
||||
/** Resource class for {@link WorkbasketSummaryResource} with Pagination. */
|
||||
/** EntityModel class for {@link WorkbasketSummaryResource} with Pagination. */
|
||||
public class WorkbasketSummaryListResource extends PagedResources<WorkbasketSummaryResource> {
|
||||
|
||||
public WorkbasketSummaryListResource() {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.core.Relation;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.hateoas.server.core.Relation;
|
||||
|
||||
import pro.taskana.workbasket.api.WorkbasketType;
|
||||
import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
||||
|
||||
/** Resource class for {@link WorkbasketSummary}. */
|
||||
/** EntityModel class for {@link WorkbasketSummary}. */
|
||||
@Relation(collectionRelation = "workbaskets")
|
||||
public class WorkbasketSummaryResource extends ResourceSupport {
|
||||
public class WorkbasketSummaryResource extends RepresentationModel<WorkbasketSummaryResource> {
|
||||
|
||||
private String workbasketId;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package pro.taskana.rest.resource;
|
|||
import java.util.List;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.rest.Mapping;
|
||||
|
@ -14,10 +14,10 @@ import pro.taskana.workbasket.api.WorkbasketService;
|
|||
import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
||||
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
|
||||
|
||||
/** Resource assembler for {@link WorkbasketSummaryResource}. */
|
||||
/** EntityModel assembler for {@link WorkbasketSummaryResource}. */
|
||||
@Component
|
||||
public class WorkbasketSummaryResourceAssembler
|
||||
extends ResourceAssemblerSupport<WorkbasketSummary, WorkbasketSummaryResource> {
|
||||
extends RepresentationModelAssemblerSupport<WorkbasketSummary, WorkbasketSummaryResource> {
|
||||
|
||||
@Autowired private WorkbasketService workbasketService;
|
||||
|
||||
|
@ -25,15 +25,16 @@ public class WorkbasketSummaryResourceAssembler
|
|||
super(WorkbasketController.class, WorkbasketSummaryResource.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketSummaryResource toResource(WorkbasketSummary workbasketSummary) {
|
||||
return new WorkbasketSummaryResource(workbasketSummary);
|
||||
@PageLinks(Mapping.URL_WORKBASKET)
|
||||
public WorkbasketSummaryListResource toCollectionModel(
|
||||
List<WorkbasketSummary> entities, PageMetadata pageMetadata) {
|
||||
return new WorkbasketSummaryListResource(
|
||||
toCollectionModel(entities).getContent(), pageMetadata);
|
||||
}
|
||||
|
||||
@PageLinks(Mapping.URL_WORKBASKET)
|
||||
public WorkbasketSummaryListResource toResources(
|
||||
List<WorkbasketSummary> entities, PageMetadata pageMetadata) {
|
||||
return new WorkbasketSummaryListResource(toResources(entities), pageMetadata);
|
||||
@Override
|
||||
public WorkbasketSummaryResource toModel(WorkbasketSummary workbasketSummary) {
|
||||
return new WorkbasketSummaryResource(workbasketSummary);
|
||||
}
|
||||
|
||||
public WorkbasketSummary toModel(WorkbasketSummaryResource resource) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package pro.taskana.rest.resource.links;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
@ -11,8 +11,9 @@ import org.aspectj.lang.annotation.Around;
|
|||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
@ -26,32 +27,35 @@ import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
|||
@Aspect
|
||||
public class PageLinksAspect {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Around("@annotation(pro.taskana.rest.resource.links.PageLinks) && args(data, page, ..)")
|
||||
public ResourceSupport addLinksToPageResource(
|
||||
ProceedingJoinPoint joinPoint, List<?> data, PageMetadata page) throws Throwable {
|
||||
public <T extends RepresentationModel<? extends T> & ProceedingJoinPoint>
|
||||
RepresentationModel<T> addLinksToPageResource(
|
||||
ProceedingJoinPoint joinPoint, List<?> data, PageMetadata page) throws Throwable {
|
||||
HttpServletRequest request =
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
|
||||
PageLinks pageLinks = method.getAnnotation(PageLinks.class);
|
||||
String relativeUrl = pageLinks.value();
|
||||
UriComponentsBuilder original = originalUri(relativeUrl, request);
|
||||
ResourceSupport resourceSupport = (ResourceSupport) joinPoint.proceed();
|
||||
RepresentationModel<T> resourceSupport = (RepresentationModel<T>) joinPoint.proceed();
|
||||
resourceSupport.add(new Link(original.toUriString()).withSelfRel());
|
||||
if (page != null) {
|
||||
resourceSupport.add(
|
||||
new Link(original.replaceQueryParam("page", 1).toUriString()).withRel(Link.REL_FIRST));
|
||||
new Link(original.replaceQueryParam("page", 1).toUriString())
|
||||
.withRel(IanaLinkRelations.FIRST));
|
||||
resourceSupport.add(
|
||||
new Link(original.replaceQueryParam("page", page.getTotalPages()).toUriString())
|
||||
.withRel(Link.REL_LAST));
|
||||
.withRel(IanaLinkRelations.LAST));
|
||||
if (page.getNumber() > 1) {
|
||||
resourceSupport.add(
|
||||
new Link(original.replaceQueryParam("page", page.getNumber() - 1).toUriString())
|
||||
.withRel(Link.REL_PREVIOUS));
|
||||
.withRel(IanaLinkRelations.PREV));
|
||||
}
|
||||
if (page.getNumber() < page.getTotalPages()) {
|
||||
resourceSupport.add(
|
||||
new Link(original.replaceQueryParam("page", page.getNumber() + 1).toUriString())
|
||||
.withRel(Link.REL_NEXT));
|
||||
.withRel(IanaLinkRelations.NEXT));
|
||||
}
|
||||
}
|
||||
return resourceSupport;
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
@ -43,9 +43,9 @@ class ClassificationControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType().toString())
|
||||
.isEqualTo(MediaTypes.HAL_JSON_UTF8_VALUE);
|
||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,7 +56,7 @@ class ClassificationControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -67,7 +67,7 @@ class ClassificationControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(13);
|
||||
}
|
||||
|
||||
|
@ -80,11 +80,11 @@ class ClassificationControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc"))
|
||||
.isTrue();
|
||||
|
@ -103,20 +103,20 @@ class ClassificationControllerIntTest {
|
|||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertThat(response.getBody().getContent()).hasSize(5);
|
||||
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050");
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/api/v1/classifications?"
|
||||
+ "domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5"))
|
||||
.isTrue();
|
||||
assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_NEXT)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_PREVIOUS)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.NEXT)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.PREV)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -216,7 +216,7 @@ class ClassificationControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
boolean foundClassificationCreated = false;
|
||||
for (ClassificationSummaryResource classification : response.getBody().getContent()) {
|
||||
if ("NEW_CLASS_P2".equals(classification.getKey())
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -140,10 +140,8 @@ class TaskCommentControllerIntTest {
|
|||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void should_FailToUpdateTaskComment_When_TaskCommentWasModifiedConcurrently() {
|
||||
|
||||
|
@ -158,7 +156,7 @@ class TaskCommentControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
assertThat(getTaskCommentResponse.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1");
|
||||
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
|
||||
|
||||
|
@ -195,7 +193,7 @@ class TaskCommentControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersUser_1_1()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
assertThat(getTaskCommentResponse.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1");
|
||||
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
|
||||
|
||||
|
@ -258,7 +256,7 @@ class TaskCommentControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
assertThat(getTaskCommentResponse.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1");
|
||||
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
@ -73,7 +73,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(25);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(22);
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(6);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(3);
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(4);
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(6);
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(4);
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(9);
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(6);
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(20);
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(2);
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(73);
|
||||
}
|
||||
|
||||
|
@ -389,11 +389,11 @@ class TaskControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/api/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc"))
|
||||
|
@ -429,24 +429,30 @@ class TaskControllerIntTest {
|
|||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getContent()).hasSize(1);
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=14")).isTrue();
|
||||
assertThat("TKI:100000000000000000000000000000000000")
|
||||
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
|
||||
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getRequiredLink(IanaLinkRelations.LAST)
|
||||
.getHref()
|
||||
.contains("page=14"))
|
||||
.isTrue();
|
||||
assertThat("TKI:100000000000000000000000000000000000")
|
||||
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
|
||||
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/api/v1/tasks?"
|
||||
+ "state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5"))
|
||||
.isTrue();
|
||||
|
||||
assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_PREVIOUS)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.PREV)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -475,22 +481,24 @@ class TaskControllerIntTest {
|
|||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getContent()).hasSize(5);
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=5")).isTrue();
|
||||
assertThat(
|
||||
response.getBody().getRequiredLink(IanaLinkRelations.LAST).getHref().contains("page=5"))
|
||||
.isTrue();
|
||||
assertThat("TKI:000000000000000000000000000000000023")
|
||||
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
|
||||
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith("/api/v1/tasks?sort-by=due&order=desc&page=5&page-size=5"))
|
||||
.isTrue();
|
||||
|
||||
assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_PREVIOUS)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.PREV)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -515,12 +523,12 @@ class TaskControllerIntTest {
|
|||
assertThat("TKI:000000000000000000000000000000000013")
|
||||
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
|
||||
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getLink(Link.REL_SELF)
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/api/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&"
|
||||
|
@ -528,9 +536,9 @@ class TaskControllerIntTest {
|
|||
+ "page=2&page-size=5"))
|
||||
.isTrue();
|
||||
|
||||
assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_PREVIOUS)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.PREV)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -42,7 +42,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -54,8 +54,14 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF).getHref().endsWith(parameters)).isTrue();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(parameters))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -88,10 +94,16 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
assertThat(response.getBody().getContent()).hasSize(1);
|
||||
assertThat(response.getBody().getContent().iterator().next().getAccessId())
|
||||
.isEqualTo("user_1_1");
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF).getHref().endsWith(parameters)).isTrue();
|
||||
assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(parameters))
|
||||
.isTrue();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
assertThat(response.getBody().getMetadata().getSize()).isEqualTo(9);
|
||||
assertThat(response.getBody().getMetadata().getTotalElements()).isEqualTo(1);
|
||||
assertThat(response.getBody().getMetadata().getTotalPages()).isEqualTo(1);
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.junit.jupiter.api.BeforeAll;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
@ -48,9 +48,9 @@ class WorkbasketControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType().toString())
|
||||
.isEqualTo(MediaTypes.HAL_JSON_UTF8_VALUE);
|
||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -61,7 +61,7 @@ class WorkbasketControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -72,7 +72,7 @@ class WorkbasketControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(3);
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,14 @@ class WorkbasketControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF).getHref().endsWith(parameters)).isTrue();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(parameters))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -174,12 +180,18 @@ class WorkbasketControllerIntTest {
|
|||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
assertThat(response.getBody().getContent()).hasSize(5);
|
||||
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("USER_1_1");
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_NEXT)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_PREVIOUS)).isNotNull();
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF).getHref().endsWith(parameters)).isTrue();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.NEXT)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.PREV)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(parameters))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -200,16 +212,16 @@ class WorkbasketControllerIntTest {
|
|||
void statusCode423ShouldBeReturnedIfWorkbasketContainsNonCompletedTasks() {
|
||||
String workbasketWithNonCompletedTasks = "WBI:100000000000000000000000000000000004";
|
||||
|
||||
assertThatThrownBy(() ->
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketWithNonCompletedTasks),
|
||||
HttpMethod.DELETE,
|
||||
new HttpEntity<>(restHelper.getHeadersBusinessAdmin()),
|
||||
Void.class))
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.LOCKED);
|
||||
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketWithNonCompletedTasks),
|
||||
HttpMethod.DELETE,
|
||||
new HttpEntity<>(restHelper.getHeadersBusinessAdmin()),
|
||||
Void.class))
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.LOCKED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -247,9 +259,9 @@ class WorkbasketControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType().toString())
|
||||
.isEqualTo(MediaTypes.HAL_JSON_UTF8_VALUE);
|
||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
||||
assertThat(response.getBody().getContent()).hasSize(3);
|
||||
}
|
||||
|
||||
|
@ -262,9 +274,9 @@ class WorkbasketControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(DistributionTargetListResource.class));
|
||||
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType().toString())
|
||||
.isEqualTo(MediaTypes.HAL_JSON_UTF8_VALUE);
|
||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
||||
assertThat(response.getBody().getContent()).hasSize(4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class ClassificationAssemblerTest {
|
|||
classification.setModified(Instant.parse("2011-11-11T11:00:00Z"));
|
||||
// when
|
||||
ClassificationResource classificationResource =
|
||||
classificationResourceAssembler.toResource(classification);
|
||||
classificationResourceAssembler.toModel(classification);
|
||||
// then
|
||||
testEquality(classification, classificationResource);
|
||||
testLinks(classificationResource);
|
||||
|
@ -92,7 +92,7 @@ class ClassificationAssemblerTest {
|
|||
private void testLinks(ClassificationResource resource) {
|
||||
assertThat(resource.getLinks()).hasSize(1);
|
||||
assertThat(Mapping.URL_CLASSIFICATIONS_ID.replaceAll("\\{.*}", resource.getClassificationId()))
|
||||
.isEqualTo(resource.getLink("self").getHref());
|
||||
.isEqualTo(resource.getRequiredLink("self").getHref());
|
||||
}
|
||||
|
||||
private void testEquality(
|
||||
|
|
|
@ -44,7 +44,7 @@ class ClassificationSummaryAssemblerTest {
|
|||
ClassificationSummary classificationSummary = classification.asSummary();
|
||||
// when
|
||||
ClassificationSummaryResource resource =
|
||||
classificationSummaryResourceAssembler.toResource(classification);
|
||||
classificationSummaryResourceAssembler.toModel(classification);
|
||||
// then
|
||||
testEquality(classificationSummary, resource);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TaskCommentResourceAssemblerTest {
|
|||
taskComment.setCreated(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
taskComment.setModified(Instant.parse("2011-11-11T11:00:00Z"));
|
||||
|
||||
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toResource(taskComment);
|
||||
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toModel(taskComment);
|
||||
|
||||
testEquality(taskComment, taskCommentResource);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ class TaskResourceAssemberTest {
|
|||
task.setCustom14("custom14");
|
||||
task.setCustom15("custom15");
|
||||
// when
|
||||
TaskResource resource = taskResourceAssembler.toResource(task);
|
||||
TaskResource resource = taskResourceAssembler.toModel(task);
|
||||
// then
|
||||
testEquality(task, resource);
|
||||
testLinks(resource);
|
||||
|
@ -228,7 +228,7 @@ class TaskResourceAssemberTest {
|
|||
|
||||
private void testLinks(TaskResource resource) {
|
||||
assertThat(resource.getLinks()).hasSize(1);
|
||||
assertThat(resource.getLink("self").getHref())
|
||||
assertThat(resource.getRequiredLink("self").getHref())
|
||||
.isEqualTo(Mapping.URL_TASKS_ID.replaceAll("\\{.*}", resource.getTaskId()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class TaskSummaryAssemblerTest {
|
|||
task.setCustom14("custom14");
|
||||
task.setCustom15("custom15");
|
||||
TaskSummaryImpl taskSummary = (TaskSummaryImpl) task.asSummary();
|
||||
TaskSummaryResource resource = this.taskSummaryResourceAssembler.toResource(taskSummary);
|
||||
TaskSummaryResource resource = this.taskSummaryResourceAssembler.toModel(taskSummary);
|
||||
this.testEquality(taskSummary, resource);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class WorkbasketAccessItemResourceAssemblerTest {
|
|||
accessItem.setPermCustom12(true);
|
||||
// when
|
||||
WorkbasketAccessItemResource resource =
|
||||
workbasketAccessItemResourceAssembler.toResource(accessItem);
|
||||
workbasketAccessItemResourceAssembler.toModel(accessItem);
|
||||
// then
|
||||
testEquality(accessItem, resource);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class WorkbasketResourceAssemblerTest {
|
|||
((WorkbasketImpl) workbasket).setCreated(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
((WorkbasketImpl) workbasket).setModified(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
// when
|
||||
WorkbasketResource resource = workbasketResourceAssembler.toResource(workbasket);
|
||||
WorkbasketResource resource = workbasketResourceAssembler.toModel(workbasket);
|
||||
// then
|
||||
testEquality(workbasket, resource);
|
||||
verifyLinks(resource);
|
||||
|
@ -101,14 +101,15 @@ class WorkbasketResourceAssemblerTest {
|
|||
|
||||
private void verifyLinks(WorkbasketResource workbasket) {
|
||||
assertThat(workbasket.getLinks()).hasSize(5);
|
||||
assertThat(workbasket.getLink("self").getHref())
|
||||
assertThat(workbasket.getRequiredLink("self").getHref())
|
||||
.isEqualTo(Mapping.URL_WORKBASKET_ID.replaceAll("\\{.*}", workbasket.getWorkbasketId()));
|
||||
assertThat(workbasket.getLink("distributionTargets").getHref())
|
||||
assertThat(workbasket.getRequiredLink("distributionTargets").getHref())
|
||||
.isEqualTo(
|
||||
Mapping.URL_WORKBASKET_ID_DISTRIBUTION.replaceAll(
|
||||
"\\{.*}", workbasket.getWorkbasketId()));
|
||||
assertThat(workbasket.getLink("allWorkbaskets").getHref()).isEqualTo(Mapping.URL_WORKBASKET);
|
||||
assertThat(workbasket.getLink("removeDistributionTargets").getHref())
|
||||
assertThat(workbasket.getRequiredLink("allWorkbaskets").getHref())
|
||||
.isEqualTo(Mapping.URL_WORKBASKET);
|
||||
assertThat(workbasket.getRequiredLink("removeDistributionTargets").getHref())
|
||||
.isEqualTo(
|
||||
Mapping.URL_WORKBASKET_DISTRIBUTION_ID.replaceAll(
|
||||
"\\{.*}", workbasket.getWorkbasketId()));
|
||||
|
|
|
@ -36,7 +36,7 @@ class WorkbasketSummaryAssemblerTest {
|
|||
workbasketSummary.setType(WorkbasketType.PERSONAL);
|
||||
// when
|
||||
WorkbasketSummaryResource workbasketSummaryResource =
|
||||
workbasketSummaryAssembler.toResource(workbasketSummary);
|
||||
workbasketSummaryAssembler.toModel(workbasketSummary);
|
||||
// then
|
||||
Assert.assertEquals(
|
||||
workbasketSummary.getDescription(), workbasketSummaryResource.getDescription());
|
||||
|
|
Loading…
Reference in New Issue