TSK-1110: Enforce application/hal+json MediaType for classification and

workbasket
This commit is contained in:
Holger Hagen 2020-02-12 08:10:22 +01:00
parent 01545e476e
commit 95495e4894
3 changed files with 20 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package pro.taskana.rest;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.http.HttpStatus;
@ -118,7 +119,7 @@ public class ClassificationController extends AbstractPagingController {
return response;
}
@GetMapping(path = Mapping.URL_CLASSIFICATIONS_ID)
@GetMapping(path = Mapping.URL_CLASSIFICATIONS_ID, produces = MediaTypes.HAL_JSON_UTF8_VALUE)
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ClassificationResource> getClassification(
@PathVariable String classificationId) throws ClassificationNotFoundException {

View File

@ -7,6 +7,7 @@ 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.MediaTypes;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@ -42,6 +43,8 @@ class ClassificationControllerIntTest {
restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationResource.class));
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
assertThat(response.getHeaders().getContentType().toString())
.isEqualTo(MediaTypes.HAL_JSON_UTF8_VALUE);
}
@Test

View File

@ -12,6 +12,7 @@ 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.MediaTypes;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@ -39,6 +40,20 @@ class WorkbasketControllerIntTest {
template = RestHelper.getRestTemplate();
}
@Test
void testGetWorkbasket() {
ResponseEntity<WorkbasketResource> response =
template.exchange(
restHelper.toUrl(
Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000006"),
HttpMethod.GET,
restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketResource.class));
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
assertThat(response.getHeaders().getContentType().toString())
.isEqualTo(MediaTypes.HAL_JSON_UTF8_VALUE);
}
@Test
void testGetAllWorkbaskets() {
ResponseEntity<WorkbasketSummaryListResource> response =