TSK-1544: Throw error for unknown query parameter
This commit is contained in:
parent
518bd29c74
commit
e7ac77cd39
|
@ -4,6 +4,7 @@ import java.beans.ConstructorProperties;
|
|||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -22,6 +23,7 @@ import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
|||
import pro.taskana.common.rest.QueryPagingParameter;
|
||||
import pro.taskana.common.rest.QuerySortBy;
|
||||
import pro.taskana.common.rest.QuerySortParameter;
|
||||
import pro.taskana.common.rest.util.QueryParamsValidator;
|
||||
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
|
||||
import pro.taskana.simplehistory.impl.task.TaskHistoryQuery;
|
||||
import pro.taskana.simplehistory.rest.assembler.TaskHistoryEventRepresentationModelAssembler;
|
||||
|
@ -57,6 +59,7 @@ public class TaskHistoryEventController {
|
|||
* This endpoint retrieves a list of existing Task History Events. Filters can be applied.
|
||||
*
|
||||
* @title Get a list of all Task History Events
|
||||
* @param request the HTTP request
|
||||
* @param filterParameter the filter parameters
|
||||
* @param sortParameter the sort parameters
|
||||
* @param pagingParameter the paging parameters
|
||||
|
@ -65,10 +68,17 @@ public class TaskHistoryEventController {
|
|||
@GetMapping(path = HistoryRestEndpoints.URL_HISTORY_EVENTS, produces = MediaTypes.HAL_JSON_VALUE)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskHistoryEventPagedRepresentationModel> getTaskHistoryEvents(
|
||||
HttpServletRequest request,
|
||||
TaskHistoryQueryFilterParameter filterParameter,
|
||||
TaskHistoryQuerySortParameter sortParameter,
|
||||
QueryPagingParameter<TaskHistoryEvent, TaskHistoryQuery> pagingParameter) {
|
||||
|
||||
QueryParamsValidator.validateParams(
|
||||
request,
|
||||
TaskHistoryQueryFilterParameter.class,
|
||||
QuerySortParameter.class,
|
||||
QueryPagingParameter.class);
|
||||
|
||||
TaskHistoryQuery query = simpleHistoryService.createTaskHistoryQuery();
|
||||
filterParameter.applyToQuery(query);
|
||||
sortParameter.applyToQuery(query);
|
||||
|
|
|
@ -31,6 +31,14 @@ import pro.taskana.simplehistory.rest.models.TaskHistoryEventRepresentationModel
|
|||
@TaskanaSpringBootTest
|
||||
class TaskHistoryEventControllerIntTest {
|
||||
|
||||
private static final ParameterizedTypeReference<TaskHistoryEventPagedRepresentationModel>
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<TaskHistoryEventPagedRepresentationModel>() {};
|
||||
|
||||
private static final ParameterizedTypeReference<TaskHistoryEventRepresentationModel>
|
||||
TASK_HISTORY_EVENT_REPRESENTATION_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<TaskHistoryEventRepresentationModel>() {};
|
||||
|
||||
private final RestHelper restHelper;
|
||||
|
||||
@Autowired
|
||||
|
@ -47,7 +55,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(45);
|
||||
}
|
||||
|
@ -59,7 +67,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
|
||||
.isPresent()
|
||||
|
@ -77,7 +85,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + parameters),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
|
||||
.isPresent()
|
||||
|
@ -95,7 +103,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + parameters),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent())
|
||||
.extracting(TaskHistoryEventRepresentationModel::getBusinessProcessId)
|
||||
|
@ -110,7 +118,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + parameters),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent())
|
||||
.extracting(TaskHistoryEventRepresentationModel::getTaskHistoryId)
|
||||
|
@ -126,7 +134,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + "?invalid=BPI:01"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
|
@ -145,7 +153,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
HistoryRestEndpoints.URL_HISTORY_EVENTS + "?created=" + currentTime),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining(currentTime)
|
||||
|
@ -162,7 +170,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
HistoryRestEndpoints.URL_HISTORY_EVENTS + "?created=" + now + "&created="),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(23);
|
||||
|
@ -182,7 +190,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + parameters),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent())
|
||||
|
@ -237,7 +245,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS_ID, id),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
|
||||
.isPresent()
|
||||
|
@ -256,11 +264,34 @@ class TaskHistoryEventControllerIntTest {
|
|||
"THI:000000000000000000000000000000000000"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventRepresentationModel.class));
|
||||
TASK_HISTORY_EVENT_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getDetails()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_ThrowException_When_ProvidingInvalidFilterParams() {
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS)
|
||||
+ "?domain=DOMAIN_A"
|
||||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=TASK_ID&order=DESCENDING&page-size=5&page=2",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining(
|
||||
"Unkown request parameters found: [anotherIllegalParam, illegalParam]")
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package pro.taskana.classification.rest;
|
|||
import java.beans.ConstructorProperties;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -40,6 +41,7 @@ import pro.taskana.common.rest.QueryPagingParameter;
|
|||
import pro.taskana.common.rest.QuerySortBy;
|
||||
import pro.taskana.common.rest.QuerySortParameter;
|
||||
import pro.taskana.common.rest.RestEndpoints;
|
||||
import pro.taskana.common.rest.util.QueryParamsValidator;
|
||||
|
||||
/** Controller for all {@link Classification} related endpoints. */
|
||||
@RestController
|
||||
|
@ -66,6 +68,7 @@ public class ClassificationController {
|
|||
* This endpoint retrieves a list of existing Classifications. Filters can be applied.
|
||||
*
|
||||
* @title Get a list of all Classifications
|
||||
* @param request the HTTP request
|
||||
* @param filterParameter the filter parameters
|
||||
* @param sortParameter the sort parameters
|
||||
* @param pagingParameter the paging parameters
|
||||
|
@ -74,10 +77,17 @@ public class ClassificationController {
|
|||
@GetMapping(path = RestEndpoints.URL_CLASSIFICATIONS)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<ClassificationSummaryPagedRepresentationModel> getClassifications(
|
||||
HttpServletRequest request,
|
||||
final ClassificationQueryFilterParameter filterParameter,
|
||||
final ClassificationQuerySortParameter sortParameter,
|
||||
final QueryPagingParameter<ClassificationSummary, ClassificationQuery> pagingParameter) {
|
||||
|
||||
QueryParamsValidator.validateParams(
|
||||
request,
|
||||
ClassificationQueryFilterParameter.class,
|
||||
QuerySortParameter.class,
|
||||
QueryPagingParameter.class);
|
||||
|
||||
final ClassificationQuery query = classificationService.createClassificationQuery();
|
||||
filterParameter.applyToQuery(query);
|
||||
sortParameter.applyToQuery(query);
|
||||
|
|
|
@ -13,6 +13,7 @@ public class QuerySortParameter<Q extends BaseQuery<?, ?>, S extends QuerySortBy
|
|||
// the javadoc comment for this field is above its getter. This is done to define the type
|
||||
// parameter S by overriding that getter and allowing spring-auto-rest-docs to properly detect
|
||||
// the type parameter S.
|
||||
@JsonProperty("sort-by")
|
||||
private final List<S> sortBy;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package pro.taskana.common.rest.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class QueryParamsValidator {
|
||||
|
||||
private QueryParamsValidator() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static void validateParams(HttpServletRequest request, Class... filterOrSortingClazz) {
|
||||
|
||||
Set<String> allowedParams =
|
||||
Stream.of(filterOrSortingClazz)
|
||||
.flatMap(clazz -> Stream.of(clazz.getDeclaredFields()))
|
||||
.map(
|
||||
field ->
|
||||
Optional.ofNullable(field.getDeclaredAnnotation(JsonProperty.class))
|
||||
.map(JsonProperty::value)
|
||||
.orElseGet(field::getName))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<String> providedParams = new HashSet<>(request.getParameterMap().keySet());
|
||||
|
||||
providedParams.removeIf(allowedParams::contains);
|
||||
|
||||
if (!providedParams.isEmpty()) {
|
||||
throw new IllegalArgumentException("Unkown request parameters found: " + providedParams);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.beans.ConstructorProperties;
|
|||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -31,6 +32,7 @@ import pro.taskana.common.rest.QueryPagingParameter;
|
|||
import pro.taskana.common.rest.QuerySortBy;
|
||||
import pro.taskana.common.rest.QuerySortParameter;
|
||||
import pro.taskana.common.rest.RestEndpoints;
|
||||
import pro.taskana.common.rest.util.QueryParamsValidator;
|
||||
import pro.taskana.task.api.TaskQuery;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
|
||||
|
@ -72,6 +74,7 @@ public class TaskController {
|
|||
* This endpoint retrieves a list of existing Tasks. Filters can be applied.
|
||||
*
|
||||
* @title Get a list of all Tasks
|
||||
* @param request the HTTP request
|
||||
* @param filterParameter the filter parameters
|
||||
* @param sortParameter the sort parameters
|
||||
* @param pagingParameter the paging parameters
|
||||
|
@ -80,10 +83,17 @@ public class TaskController {
|
|||
@GetMapping(path = RestEndpoints.URL_TASKS)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskSummaryPagedRepresentationModel> getTasks(
|
||||
HttpServletRequest request,
|
||||
TaskQueryFilterParameter filterParameter,
|
||||
TaskQuerySortParameter sortParameter,
|
||||
QueryPagingParameter<TaskSummary, TaskQuery> pagingParameter) {
|
||||
|
||||
QueryParamsValidator.validateParams(
|
||||
request,
|
||||
TaskQueryFilterParameter.class,
|
||||
QuerySortParameter.class,
|
||||
QueryPagingParameter.class);
|
||||
|
||||
TaskQuery query = taskService.createTaskQuery();
|
||||
|
||||
filterParameter.applyToQuery(query);
|
||||
|
|
|
@ -3,6 +3,7 @@ package pro.taskana.workbasket.rest;
|
|||
import java.beans.ConstructorProperties;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -21,6 +22,7 @@ import pro.taskana.common.rest.QuerySortBy;
|
|||
import pro.taskana.common.rest.QuerySortParameter;
|
||||
import pro.taskana.common.rest.RestEndpoints;
|
||||
import pro.taskana.common.rest.ldap.LdapClient;
|
||||
import pro.taskana.common.rest.util.QueryParamsValidator;
|
||||
import pro.taskana.workbasket.api.WorkbasketAccessItemQuery;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
|
||||
|
@ -53,6 +55,7 @@ public class WorkbasketAccessItemController {
|
|||
* This endpoint retrieves a list of existing Workbasket Access Items. Filters can be applied.
|
||||
*
|
||||
* @title Get a list of all Workbasket Access Items
|
||||
* @param request the HTTP request
|
||||
* @param filterParameter the filter parameters
|
||||
* @param sortParameter the sort parameters
|
||||
* @param pagingParameter the paging parameters
|
||||
|
@ -61,11 +64,18 @@ public class WorkbasketAccessItemController {
|
|||
*/
|
||||
@GetMapping(path = RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS)
|
||||
public ResponseEntity<WorkbasketAccessItemPagedRepresentationModel> getWorkbasketAccessItems(
|
||||
HttpServletRequest request,
|
||||
WorkbasketAccessItemQueryFilterParameter filterParameter,
|
||||
WorkbasketAccessItemQuerySortParameter sortParameter,
|
||||
QueryPagingParameter<WorkbasketAccessItem, WorkbasketAccessItemQuery> pagingParameter)
|
||||
throws NotAuthorizedException {
|
||||
|
||||
QueryParamsValidator.validateParams(
|
||||
request,
|
||||
WorkbasketAccessItemQueryFilterParameter.class,
|
||||
QuerySortParameter.class,
|
||||
QueryPagingParameter.class);
|
||||
|
||||
WorkbasketAccessItemQuery query = workbasketService.createWorkbasketAccessItemQuery();
|
||||
filterParameter.applyToQuery(query);
|
||||
sortParameter.applyToQuery(query);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.beans.ConstructorProperties;
|
|||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -30,6 +31,7 @@ import pro.taskana.common.rest.QueryPagingParameter;
|
|||
import pro.taskana.common.rest.QuerySortBy;
|
||||
import pro.taskana.common.rest.QuerySortParameter;
|
||||
import pro.taskana.common.rest.RestEndpoints;
|
||||
import pro.taskana.common.rest.util.QueryParamsValidator;
|
||||
import pro.taskana.workbasket.api.WorkbasketQuery;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException;
|
||||
|
@ -82,6 +84,7 @@ public class WorkbasketController {
|
|||
* This endpoint retrieves a list of existing Workbaskets. Filters can be applied.
|
||||
*
|
||||
* @title Get a list of all Workbaskets
|
||||
* @param request the HTTP request
|
||||
* @param filterParameter the filter parameters
|
||||
* @param sortParameter the sort parameters
|
||||
* @param pagingParameter the paging parameters
|
||||
|
@ -90,10 +93,17 @@ public class WorkbasketController {
|
|||
@GetMapping(path = RestEndpoints.URL_WORKBASKET)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketSummaryPagedRepresentationModel> getWorkbaskets(
|
||||
HttpServletRequest request,
|
||||
WorkbasketQueryFilterParameter filterParameter,
|
||||
WorkbasketQuerySortParameter sortParameter,
|
||||
QueryPagingParameter<WorkbasketSummary, WorkbasketQuery> pagingParameter) {
|
||||
|
||||
QueryParamsValidator.validateParams(
|
||||
request,
|
||||
WorkbasketQueryFilterParameter.class,
|
||||
QuerySortParameter.class,
|
||||
QueryPagingParameter.class);
|
||||
|
||||
WorkbasketQuery query = workbasketService.createWorkbasketQuery();
|
||||
filterParameter.applyToQuery(query);
|
||||
sortParameter.applyToQuery(query);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class WorkbasketRepresentationModelAssembler
|
|||
linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(wb.getId()))
|
||||
.withRel("accessItems"));
|
||||
resource.add(
|
||||
linkTo(methodOn(WorkbasketController.class).getWorkbaskets(null, null, null))
|
||||
linkTo(methodOn(WorkbasketController.class).getWorkbaskets(null, null, null, null))
|
||||
.withRel("allWorkbaskets"));
|
||||
resource.add(
|
||||
linkTo(
|
||||
|
|
|
@ -2,6 +2,7 @@ package pro.taskana.classification.rest;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static pro.taskana.common.test.rest.RestHelper.TEMPLATE;
|
||||
|
||||
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -31,6 +32,15 @@ class ClassificationControllerIntTest {
|
|||
private static final ParameterizedTypeReference<ClassificationSummaryPagedRepresentationModel>
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<ClassificationSummaryPagedRepresentationModel>() {};
|
||||
|
||||
private static final ParameterizedTypeReference<ClassificationRepresentationModel>
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<ClassificationRepresentationModel>() {};
|
||||
|
||||
private static final ParameterizedTypeReference<ClassificationSummaryRepresentationModel>
|
||||
CLASSIFICATION_SUMMARY_REPRESENTATION_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<ClassificationSummaryRepresentationModel>() {};
|
||||
|
||||
static RestTemplate template = RestHelper.TEMPLATE;
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
|
@ -42,7 +52,7 @@ class ClassificationControllerIntTest {
|
|||
RestEndpoints.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000002"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType()).isEqualTo(MediaTypes.HAL_JSON);
|
||||
|
@ -128,7 +138,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1()),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
@ -143,7 +153,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1()),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
}
|
||||
|
@ -162,7 +172,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersUser_1_1()),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
|
@ -184,7 +194,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1()),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
@ -204,7 +214,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1()),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
@ -223,7 +233,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1()),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
@ -266,7 +276,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersBusinessAdmin()),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
@ -287,7 +297,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersBusinessAdmin()),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
@ -304,7 +314,7 @@ class ClassificationControllerIntTest {
|
|||
RestEndpoints.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"),
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
|
||||
CLASSIFICATION_SUMMARY_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getName()).isEqualTo("Zustimmungserklärung");
|
||||
}
|
||||
|
@ -320,7 +330,7 @@ class ClassificationControllerIntTest {
|
|||
RestEndpoints.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
|
||||
HttpMethod.DELETE,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
|
||||
CLASSIFICATION_SUMMARY_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
|
@ -331,7 +341,30 @@ class ClassificationControllerIntTest {
|
|||
"CLI:200000000000000000000000000000000004"),
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
|
||||
CLASSIFICATION_SUMMARY_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_ThrowException_When_ProvidingInvalidFilterParams() {
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS)
|
||||
+ "?domain=DOMAIN_A"
|
||||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=NAME&order=DESCENDING&page-size=5&page=2",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining(
|
||||
"Unkown request parameters found: [anotherIllegalParam, illegalParam]")
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -940,6 +940,29 @@ class TaskControllerIntTest {
|
|||
.isEqualTo(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_ThrowException_When_ProvidingInvalidFilterParams() {
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=NAME&order=DESCENDING&page-size=5&page=2",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining(
|
||||
"Unkown request parameters found: [anotherIllegalParam, illegalParam]")
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
private TaskRepresentationModel getTaskResourceSample() {
|
||||
ClassificationSummaryRepresentationModel classificationResource =
|
||||
new ClassificationSummaryRepresentationModel();
|
||||
|
|
|
@ -29,7 +29,7 @@ class TaskControllerRestDocTest extends BaseRestDocTest {
|
|||
@Test
|
||||
void getAllTasksDocTest() throws Exception {
|
||||
mockMvc
|
||||
.perform(get(RestEndpoints.URL_TASKS + "?por.type=VNR&por.value=22334455&sortBy=NAME"))
|
||||
.perform(get(RestEndpoints.URL_TASKS + "?por.type=VNR&por.value=22334455&sort-by=NAME"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,10 @@ import pro.taskana.workbasket.rest.models.WorkbasketAccessItemPagedRepresentatio
|
|||
@TaskanaSpringBootTest
|
||||
class WorkbasketAccessItemControllerIntTest {
|
||||
|
||||
private static final ParameterizedTypeReference<WorkbasketAccessItemPagedRepresentationModel>
|
||||
WORKBASKET_ACCESS_ITEM_PAGED_REPRESENTATION_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<WorkbasketAccessItemPagedRepresentationModel>() {};
|
||||
|
||||
private final RestHelper restHelper;
|
||||
|
||||
@Autowired
|
||||
|
@ -46,7 +50,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemPagedRepresentationModel.class));
|
||||
WORKBASKET_ACCESS_ITEM_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
}
|
||||
|
@ -60,7 +64,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS) + parameters,
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemPagedRepresentationModel.class));
|
||||
WORKBASKET_ACCESS_ITEM_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
|
@ -82,8 +86,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
+ "?sort-by=WORKBASKET_KEY&order=ASCENDING&page=1&page-size=9&invalid=user-1-1",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(
|
||||
WorkbasketAccessItemPagedRepresentationModel.class));
|
||||
WORKBASKET_ACCESS_ITEM_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
|
@ -100,7 +103,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS) + parameters,
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemPagedRepresentationModel.class));
|
||||
WORKBASKET_ACCESS_ITEM_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(1);
|
||||
assertThat(response.getBody().getContent().iterator().next().getAccessId())
|
||||
|
@ -135,6 +138,29 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_ThrowException_When_ProvidingInvalidFilterParams() {
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS)
|
||||
+ "?access-id=teamlead-2"
|
||||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=WORKBASKET_KEY&order=DESCENDING&page-size=5&page=2",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
WORKBASKET_ACCESS_ITEM_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining(
|
||||
"Unkown request parameters found: [anotherIllegalParam, illegalParam]")
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Stream<DynamicTest> should_ReturnBadRequest_When_AccessIdIsInvalid() {
|
||||
List<String> accessIds =
|
||||
|
|
|
@ -34,6 +34,22 @@ import pro.taskana.workbasket.rest.models.WorkbasketSummaryRepresentationModel;
|
|||
@TaskanaSpringBootTest
|
||||
class WorkbasketControllerIntTest {
|
||||
|
||||
private static final ParameterizedTypeReference<WorkbasketRepresentationModel>
|
||||
WORKBASKET_REPRESENTATION_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<WorkbasketRepresentationModel>() {};
|
||||
|
||||
private static final ParameterizedTypeReference<WorkbasketSummaryPagedRepresentationModel>
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<WorkbasketSummaryPagedRepresentationModel>() {};
|
||||
|
||||
private static final ParameterizedTypeReference<WorkbasketAccessItemCollectionRepresentationModel>
|
||||
WORKBASKET_ACCESS_ITEM_COLLECTION_REPRESENTATION_TYPE =
|
||||
new ParameterizedTypeReference<WorkbasketAccessItemCollectionRepresentationModel>() {};
|
||||
|
||||
private static final ParameterizedTypeReference<DistributionTargetsCollectionRepresentationModel>
|
||||
DISTRIBUTION_TARGETS_COLLECTION_REPRESENTATION_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<DistributionTargetsCollectionRepresentationModel>() {};
|
||||
|
||||
private final RestHelper restHelper;
|
||||
|
||||
@Autowired
|
||||
|
@ -48,10 +64,7 @@ class WorkbasketControllerIntTest {
|
|||
RestEndpoints.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000006");
|
||||
ResponseEntity<WorkbasketRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
url,
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
|
||||
url, HttpMethod.GET, restHelper.defaultRequest(), WORKBASKET_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
|
||||
|
@ -66,7 +79,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryPagedRepresentationModel.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
}
|
||||
|
@ -78,7 +91,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + "?required-permission=OPEN",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryPagedRepresentationModel.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(6);
|
||||
|
@ -92,7 +105,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + parameters,
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryPagedRepresentationModel.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
|
@ -113,8 +126,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + "?invalid=PERSONAL",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(
|
||||
WorkbasketSummaryPagedRepresentationModel.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
|
@ -132,7 +144,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ID, workbasketId),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersTeamlead_1()),
|
||||
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
|
||||
WORKBASKET_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
WorkbasketRepresentationModel workbasketRepresentationModel =
|
||||
initialWorkbasketResourceRequestResponse.getBody();
|
||||
|
@ -151,7 +163,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ID, workbasketId),
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(workbasketRepresentationModel, restHelper.getHeadersTeamlead_1()),
|
||||
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
|
||||
WORKBASKET_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.CONFLICT);
|
||||
|
@ -168,7 +180,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ID, workbasketId),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersBusinessAdmin()),
|
||||
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
|
||||
WORKBASKET_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
@ -184,7 +196,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + parameters,
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryPagedRepresentationModel.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(5);
|
||||
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("USER-1-1");
|
||||
|
@ -252,8 +264,7 @@ class WorkbasketControllerIntTest {
|
|||
"WBI:100000000000000000000000000000000002"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(
|
||||
DistributionTargetsCollectionRepresentationModel.class));
|
||||
DISTRIBUTION_TARGETS_COLLECTION_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response2.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(response2.getBody()).isNotNull();
|
||||
assertThat(response2.getBody().getContent())
|
||||
|
@ -270,8 +281,7 @@ class WorkbasketControllerIntTest {
|
|||
"WBI:100000000000000000000000000000000005"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(
|
||||
WorkbasketAccessItemCollectionRepresentationModel.class));
|
||||
WORKBASKET_ACCESS_ITEM_COLLECTION_REPRESENTATION_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType()).isEqualTo(MediaTypes.HAL_JSON);
|
||||
|
@ -287,11 +297,33 @@ class WorkbasketControllerIntTest {
|
|||
"WBI:100000000000000000000000000000000001"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(
|
||||
DistributionTargetsCollectionRepresentationModel.class));
|
||||
DISTRIBUTION_TARGETS_COLLECTION_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType()).isEqualTo(MediaTypes.HAL_JSON);
|
||||
assertThat(response.getBody().getContent()).hasSize(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_ThrowException_When_ProvidingInvalidFilterParams() {
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET)
|
||||
+ "?type=PERSONAL"
|
||||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=KEY&order=DESCENDING&page-size=5&page=2",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining(
|
||||
"Unkown request parameters found: [anotherIllegalParam, illegalParam]")
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue