Search in sources :

Example 1 with PagedResources

use of org.springframework.hateoas.PagedResources in project taskana by Taskana.

the class WorkbasketControllerIntTest method testGetAllWorkbaskets.

@Test
public void testGetAllWorkbaskets() {
    RestTemplate template = getRestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
    HttpEntity<String> request = new HttpEntity<String>(headers);
    ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange("http://127.0.0.1:" + port + "/v1/workbaskets", HttpMethod.GET, request, new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
    });
    assertNotNull(response.getBody().getLink(Link.REL_SELF));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) PagedResources(org.springframework.hateoas.PagedResources) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with PagedResources

use of org.springframework.hateoas.PagedResources in project taskana by Taskana.

the class WorkbasketControllerIntTest method testGetAllWorkbasketsKeepingFilters.

@Test
public void testGetAllWorkbasketsKeepingFilters() {
    RestTemplate template = getRestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
    HttpEntity<String> request = new HttpEntity<String>(headers);
    ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = template.exchange("http://127.0.0.1:" + port + "/v1/workbaskets?type=PERSONAL&sortBy=key&order=desc", HttpMethod.GET, request, new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
    });
    assertNotNull(response.getBody().getLink(Link.REL_SELF));
    assertTrue(response.getBody().getLink(Link.REL_SELF).getHref().endsWith("/v1/workbaskets?type=PERSONAL&sortBy=key&order=desc"));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) PagedResources(org.springframework.hateoas.PagedResources) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with PagedResources

use of org.springframework.hateoas.PagedResources in project taskana by Taskana.

the class TaskControllerIntTest method testGetQueryByPorSecondPageSortedByType.

@Test
@Ignore
public void testGetQueryByPorSecondPageSortedByType() {
    RestTemplate template = getRestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
    HttpEntity<String> request = new HttpEntity<String>(headers);
    ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange("http://127.0.0.1:" + port + "/v1/tasks?porCompany=00&porSystem=PASystem&porInstance=00&porType=VNR&porValue=22334455&sortBy=porType&order=asc&page=2&pageSize=5", HttpMethod.GET, request, new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
    });
    assertEquals(5, response.getBody().getContent().size());
    assertEquals("USER_1_1", response.getBody().getContent().iterator().next().getTaskId());
    assertNotNull(response.getBody().getLink(Link.REL_SELF));
    assertTrue(response.getBody().getLink(Link.REL_SELF).getHref().endsWith("/v1/tasks?sortBy=due&order=desc&page=2&pageSize=5"));
    assertNotNull(response.getBody().getLink("allTasks"));
    assertTrue(response.getBody().getLink("allTasks").getHref().endsWith("/v1/tasks"));
    assertNotNull(response.getBody().getLink(Link.REL_FIRST));
    assertNotNull(response.getBody().getLink(Link.REL_LAST));
    assertNotNull(response.getBody().getLink(Link.REL_NEXT));
    assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) PagedResources(org.springframework.hateoas.PagedResources) RestTemplate(org.springframework.web.client.RestTemplate) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with PagedResources

use of org.springframework.hateoas.PagedResources in project taskana by Taskana.

the class TaskControllerIntTest method testGetLastPageSortedByDueWithHiddenTasksRemovedFromResult.

@Test
@Ignore
public void testGetLastPageSortedByDueWithHiddenTasksRemovedFromResult() {
    RestTemplate template = getRestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
    HttpEntity<String> request = new HttpEntity<String>(headers);
    ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange("http://127.0.0.1:" + port + "/v1/tasks?sortBy=due&order=desc&page=14&pageSize=5", HttpMethod.GET, request, new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
    });
    assertEquals(2, response.getBody().getContent().size());
    assertTrue(response.getBody().getLink(Link.REL_LAST).getHref().contains("page=14"));
    assertEquals("TKI:000000000000000000000000000000000005", response.getBody().getContent().iterator().next().getTaskId());
    assertNotNull(response.getBody().getLink(Link.REL_SELF));
    assertTrue(response.getBody().getLink(Link.REL_SELF).getHref().endsWith("/v1/tasks?sortBy=due&order=desc&page=2&pageSize=5"));
    assertNotNull(response.getBody().getLink("allTasks"));
    assertTrue(response.getBody().getLink("allTasks").getHref().endsWith("/v1/tasks"));
    assertNotNull(response.getBody().getLink(Link.REL_FIRST));
    assertNotNull(response.getBody().getLink(Link.REL_LAST));
    assertNotNull(response.getBody().getLink(Link.REL_NEXT));
    assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) PagedResources(org.springframework.hateoas.PagedResources) RestTemplate(org.springframework.web.client.RestTemplate) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with PagedResources

use of org.springframework.hateoas.PagedResources in project taskana by Taskana.

the class TaskControllerIntTest method testGetAllTasks.

@Test
public void testGetAllTasks() {
    RestTemplate template = getRestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
    HttpEntity<String> request = new HttpEntity<String>(headers);
    ResponseEntity<PagedResources<TaskSummaryResource>> response = template.exchange("http://127.0.0.1:" + port + "/v1/tasks", HttpMethod.GET, request, new ParameterizedTypeReference<PagedResources<TaskSummaryResource>>() {
    });
    assertNotNull(response.getBody().getLink(Link.REL_SELF));
    assertEquals(22, response.getBody().getContent().size());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) PagedResources(org.springframework.hateoas.PagedResources) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

PagedResources (org.springframework.hateoas.PagedResources)11 Test (org.junit.Test)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 HttpEntity (org.springframework.http.HttpEntity)9 HttpHeaders (org.springframework.http.HttpHeaders)9 RestTemplate (org.springframework.web.client.RestTemplate)9 Ignore (org.junit.Ignore)3 Link (org.springframework.hateoas.Link)2 ServletUriComponentsBuilder (org.springframework.web.servlet.support.ServletUriComponentsBuilder)2 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 MethodParameter (org.springframework.core.MethodParameter)1 Page (org.springframework.data.domain.Page)1 PageRequest (org.springframework.data.domain.PageRequest)1 Pageable (org.springframework.data.domain.Pageable)1 PageMetadata (org.springframework.hateoas.PagedResources.PageMetadata)1 Resource (org.springframework.hateoas.Resource)1