org.springframework.hateoas.IanaLinkRelations Java Examples
The following examples show how to use
org.springframework.hateoas.IanaLinkRelations.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskHistoryEventControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test public void testGetAllHistoryEventDescendingOrder() { String parameters = "/api/v1/task-history-event?sort-by=business-process-id&order=desc&page-size=3&page=1"; ResponseEntity<TaskHistoryEventListResource> response = template.exchange( server + port + parameters, HttpMethod.GET, request, ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getContent()).hasSize(3); assertThat( response .getBody() .getRequiredLink(IanaLinkRelations.SELF) .getHref() .endsWith(parameters)) .isTrue(); }
Example #2
Source File: WorkbasketControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetAllWorkbasketsKeepingFilters() { String parameters = "?type=PERSONAL&sort-by=key&order=desc"; ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_WORKBASKET) + parameters, HttpMethod.GET, restHelper.defaultRequest(), WORKBASKET_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat( response .getBody() .getRequiredLink(IanaLinkRelations.SELF) .getHref() .endsWith(parameters)) .isTrue(); }
Example #3
Source File: WorkbasketControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetSecondPageSortedByKey() { String parameters = "?sort-by=key&order=desc&page-size=5&page=2"; ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_WORKBASKET) + parameters, HttpMethod.GET, restHelper.defaultRequest(), 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"); 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(); }
Example #4
Source File: EmployeeController.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@PostMapping("/employees") @ResponseStatus(HttpStatus.CREATED) ResponseEntity<EntityModel<Employee>> newEmployee(@RequestBody Employee employee) { try { Employee savedEmployee = repository.save(employee); EntityModel<Employee> employeeResource = new EntityModel<>(savedEmployee, // linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); return ResponseEntity // .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // .body(employeeResource); } catch (URISyntaxException e) { return ResponseEntity.badRequest().body(null); } }
Example #5
Source File: EmployeeController.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@PostMapping("/employees") ResponseEntity<EntityModel<Employee>> newEmployee(@RequestBody Employee employee) { try { Employee savedEmployee = repository.save(employee); EntityModel<Employee> employeeResource = new EntityModel<>(savedEmployee, // linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); return ResponseEntity // .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // .body(employeeResource); } catch (URISyntaxException e) { return ResponseEntity.badRequest().body(null); } }
Example #6
Source File: WorkbasketAccessItemControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetWorkbasketAccessItemsKeepingFilters() { String parameters = "?sort-by=workbasket-key&order=asc&page-size=9&access-ids=user-1-1&page=1"; ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response = template.exchange( restHelper.toUrl(Mapping.URL_WORKBASKET_ACCESS_ITEMS) + parameters, HttpMethod.GET, restHelper.defaultRequest(), WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat( response .getBody() .getRequiredLink(IanaLinkRelations.SELF) .getHref() .endsWith(parameters)) .isTrue(); }
Example #7
Source File: ClassificationControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetAllClassificationsKeepingFilters() { ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response = template.exchange( restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_A&sort-by=key&order=asc", HttpMethod.GET, restHelper.defaultRequest(), CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat( response .getBody() .getRequiredLink(IanaLinkRelations.SELF) .getHref() .endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc")) .isTrue(); assertThat(response.getBody().getContent()).hasSize(17); assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("A12"); }
Example #8
Source File: ClassificationControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetSecondPageSortedByKey() { ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response = template.exchange( restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_A&sort-by=key&order=asc&page-size=5&page=2", HttpMethod.GET, restHelper.defaultRequest(), CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody().getContent()).hasSize(5); assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050"); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); String href = response.getBody().getRequiredLink(IanaLinkRelations.SELF).getHref(); assertThat( href.endsWith( "/api/v1/classifications?" + "domain=DOMAIN_A&sort-by=key&order=asc&page-size=5&page=2")) .isTrue(); 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(); }
Example #9
Source File: EmployeeController.java From spring-hateoas-examples with Apache License 2.0 | 6 votes |
@PostMapping("/employees") ResponseEntity<?> newEmployee(@RequestBody Employee employee) { try { Employee savedEmployee = repository.save(employee); EntityModel<Employee> employeeResource = new EntityModel<>(savedEmployee, // linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); return ResponseEntity // .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // .body(employeeResource); } catch (URISyntaxException e) { return ResponseEntity.badRequest().body("Unable to create " + employee); } }
Example #10
Source File: EmployeeController.java From spring-hateoas-examples with Apache License 2.0 | 6 votes |
@PutMapping("/employees/{id}") ResponseEntity<?> updateEmployee(@RequestBody Employee employee, @PathVariable long id) { Employee employeeToUpdate = employee; employeeToUpdate.setId(id); Employee updatedEmployee = repository.save(employeeToUpdate); return new EntityModel<>(updatedEmployee, linkTo(methodOn(EmployeeController.class).findOne(updatedEmployee.getId())).withSelfRel() .andAffordance(afford(methodOn(EmployeeController.class).updateEmployee(null, updatedEmployee.getId()))) .andAffordance(afford(methodOn(EmployeeController.class).deleteEmployee(updatedEmployee.getId()))), linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees")).getLink(IanaLinkRelations.SELF) .map(Link::getHref).map(href -> { try { return new URI(href); } catch (URISyntaxException e) { throw new RuntimeException(e); } }) // .map(uri -> ResponseEntity.noContent().location(uri).build()) // .orElse(ResponseEntity.badRequest().body("Unable to update " + employeeToUpdate)); }
Example #11
Source File: EmployeeController.java From spring-hateoas-examples with Apache License 2.0 | 6 votes |
@PostMapping("/employees") ResponseEntity<?> newEmployee(@RequestBody Employee employee) { Employee savedEmployee = repository.save(employee); return new EntityModel<>(savedEmployee, linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel() .andAffordance(afford(methodOn(EmployeeController.class).updateEmployee(null, savedEmployee.getId()))) .andAffordance(afford(methodOn(EmployeeController.class).deleteEmployee(savedEmployee.getId()))), linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees")).getLink(IanaLinkRelations.SELF) .map(Link::getHref) // .map(href -> { try { return new URI(href); } catch (URISyntaxException e) { throw new RuntimeException(e); } }) // .map(uri -> ResponseEntity.noContent().location(uri).build()) .orElse(ResponseEntity.badRequest().body("Unable to create " + employee)); }
Example #12
Source File: TaskControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetAllTasksByWorkbasketIdWithinSinglePlannedTimeInterval() { Instant plannedFromInstant = Instant.now().minus(6, ChronoUnit.DAYS); Instant plannedToInstant = Instant.now().minus(3, ChronoUnit.DAYS); ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-id=WBI:100000000000000000000000000000000001" + "&planned-from=" + plannedFromInstant + "&planned-until=" + plannedToInstant + "&sort-by=planned", HttpMethod.GET, restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat((response.getBody()).getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getContent()).hasSize(3); }
Example #13
Source File: TaskControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetAllTasksByWorkbasketIdWithinSingleIndefinitePlannedTimeInterval() { Instant plannedFromInstant = Instant.now().minus(6, ChronoUnit.DAYS); ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-id=WBI:100000000000000000000000000000000001" + "&planned-from=" + plannedFromInstant + "&sort-by=planned", HttpMethod.GET, restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat((response.getBody()).getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getContent()).hasSize(4); }
Example #14
Source File: TaskControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetAllTasksByWorkbasketIdWithinSingleDueTimeInterval() { Instant dueFromInstant = Instant.now().minus(8, ChronoUnit.DAYS); Instant dueToInstant = Instant.now().minus(3, ChronoUnit.DAYS); ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-id=WBI:100000000000000000000000000000000001" + "&due-from=" + dueFromInstant + "&due-until=" + dueToInstant + "&sort-by=due", HttpMethod.GET, restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat((response.getBody()).getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getContent()).hasSize(9); }
Example #15
Source File: TaskControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test void testGetAllTasksByWorkbasketIdWithinSingleIndefiniteDueTimeInterval() { Instant dueToInstant = Instant.now().minus(1, ChronoUnit.DAYS); ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-id=WBI:100000000000000000000000000000000001" + "&due-until=" + dueToInstant + "&sort-by=due", HttpMethod.GET, restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat((response.getBody()).getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getContent()).hasSize(6); }
Example #16
Source File: TaskHistoryEventControllerIntTest.java From taskana with Apache License 2.0 | 6 votes |
@Test public void should_ReturnSpecificTaskHistoryEventWithoutDetails_When_ListIsQueried() { ResponseEntity<TaskHistoryEventListResource> response = template.exchange( server + port + "/api/v1/task-history-event?business-process-id=BPI:01" + "&sort-by=business-process-id&order=asc&page-size=6&page=1", HttpMethod.GET, request, ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLinks()).isNotNull(); assertThat(response.getBody().getMetadata()).isNotNull(); assertThat(response.getBody().getContent()).hasSize(1); assertThat(response.getBody().getContent().stream().findFirst().get().getDetails()).isNull(); }
Example #17
Source File: DefaultTypeResolverTest.java From bowman with Apache License 2.0 | 5 votes |
@Test public void resolveTypeWithNonRemoteResourceSubtypeThrowsException() { thrown.expect(ClientProxyException.class); thrown.expectMessage(TypeWithNonRemoteResourceSubtypeSubtype.class.getName() + " is not annotated with @RemoteResource"); resolver.resolveType(TypeWithNonRemoteResourceSubtype.class, Links.of(new Link("/", IanaLinkRelations.SELF)), Configuration.build()); }
Example #18
Source File: TaskHistoryEventControllerIntTest.java From taskana with Apache License 2.0 | 5 votes |
@Test public void testGetSecondPageSortedByKey() { String parameters = "/api/v1/task-history-event?sort-by=workbasket-key&order=desc&page=2&page-size=2"; ResponseEntity<TaskHistoryEventListResource> response = template.exchange( server + port + parameters, HttpMethod.GET, request, ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); assertThat(response.getBody().getContent()).hasSize(2); assertThat(response.getBody().getContent().iterator().next().getWorkbasketKey()) .isEqualTo("WBI:100000000000000000000000000000000002"); 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() .getRequiredLink("allTaskHistoryEvent") .getHref() .endsWith("/api/v1/task-history-event")) .isTrue(); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull(); }
Example #19
Source File: JavassistClientProxyFactoryTest.java From bowman with Apache License 2.0 | 5 votes |
@Test public void createWithNullLinkedCollectionReturnsProxyWithLinkedResources() { EntityModel<Entity> resource = new EntityModel<>(new Entity(), new Link("http://www.example.com/association/linked", "nullLinkedCollection")); when(restOperations.getResources(URI.create("http://www.example.com/association/linked"), Entity.class)).thenReturn(new CollectionModel<>(asList(new EntityModel<>(new Entity(), new Link("http://www.example.com/1", IanaLinkRelations.SELF))))); Entity proxy = proxyFactory.create(resource, restOperations); assertThat(proxy.getNullLinkedCollection().get(0).getId(), is(URI.create("http://www.example.com/1"))); }
Example #20
Source File: JavassistClientProxyFactoryTest.java From bowman with Apache License 2.0 | 5 votes |
@Test public void createReturnsProxyWithActive() { Entity entity = new Entity(); entity.setActive(true); EntityModel<Entity> resource = new EntityModel<>(entity, new Link("http://www.example.com/1", IanaLinkRelations.SELF)); Entity proxy = proxyFactory.create(resource, mock(RestOperations.class)); assertThat(proxy.getId(), is(URI.create("http://www.example.com/1"))); assertThat(proxy.isActive(), is(true)); }
Example #21
Source File: TaskHistoryEventControllerIntTest.java From taskana with Apache License 2.0 | 5 votes |
@Test public void testGetHistoryEventOfDate() { String currentTime = LocalDateTime.now().toString(); final String finalCurrentTime = currentTime; ThrowingCallable httpCall = () -> { template.exchange( server + port + "/api/v1/task-history-event?created=" + finalCurrentTime, HttpMethod.GET, request, ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); }; assertThatThrownBy(httpCall) .isInstanceOf(HttpClientErrorException.class) .hasMessageContaining(currentTime) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .isEqualTo(HttpStatus.BAD_REQUEST); // correct Format 'yyyy-MM-dd' currentTime = currentTime.substring(0, 10); ResponseEntity<TaskHistoryEventListResource> response = template.exchange( server + port + "/api/v1/task-history-event?created=" + currentTime, HttpMethod.GET, request, ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getContent()).hasSize(23); }
Example #22
Source File: DefaultTypeResolverTest.java From bowman with Apache License 2.0 | 5 votes |
@Test public void resolveTypeWithSubtypesAndMatchingAbsoluteUriSubtypeReturnsSubtype() { Configuration config = Configuration.builder().setBaseUri("http://x.com").build(); Class<?> type = resolver.resolveType(TypeWithSubtypes.class, Links.of(new Link("http://x.com/2/1", IanaLinkRelations.SELF)), config); assertThat(type, Matchers.<Class<?>>equalTo(TypeWithSubtypesSubtype2.class)); }
Example #23
Source File: TaskHistoryEventControllerIntTest.java From taskana with Apache License 2.0 | 5 votes |
@Test public void should_ReturnSpecificTaskHistoryEventWithDetails_When_SingleEventIsQueried() { ResponseEntity<TaskHistoryEventResource> response = template.exchange( server + port + "/api/v1/task-history-event/45", HttpMethod.GET, request, ParameterizedTypeReference.forType(TaskHistoryEventResource.class)); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLinks()).isNotNull(); assertThat(response.getBody().getDetails()).isNotNull(); }
Example #24
Source File: JavassistClientProxyFactoryTest.java From bowman with Apache License 2.0 | 5 votes |
@Test public void createReturnsProxyWithSettingValuesPossible() { Entity entity = new Entity(); entity.setActive(true); EntityModel<Entity> resource = new EntityModel<>(entity, new Link("http://www.example.com/1", IanaLinkRelations.SELF)); Entity proxy = proxyFactory.create(resource, mock(RestOperations.class)); proxy.setActive(false); assertThat(proxy.isActive(), is(false)); }
Example #25
Source File: JavassistClientProxyFactoryTest.java From bowman with Apache License 2.0 | 5 votes |
@Test public void createWithResourceWithProxiedInterfaceContentReturnsProxyWithLinkedResources() throws Exception { InterfaceTypeResource content = instantiateProxyOfInterfaceType(InterfaceTypeResource.class); when(restOperations.getResources(URI.create("http://www.example.com/association/linked"), Entity.class)).thenReturn(new CollectionModel<>(asList(new EntityModel<>(new Entity(), new Link("http://www.example.com/1", IanaLinkRelations.SELF))))); InterfaceTypeResource resource = proxyFactory.create(new EntityModel<>(content, new Link("http://www.example.com/association/linked", "linked")), restOperations); assertThat(resource.linked().get(0).getId(), is(URI.create("http://www.example.com/1"))); }
Example #26
Source File: ResourceDeserializerTest.java From bowman with Apache License 2.0 | 5 votes |
@Test public void deserializeResolvesType() throws Exception { mapper.readValue("{\"_links\":{\"self\":{\"href\":\"http://x.com/1\"}}}", new TypeReference<EntityModel<DeclaredType>>() { /* generic type reference */ }); verify(typeResolver).resolveType(DeclaredType.class, Links.of(new Link("http://x.com/1", IanaLinkRelations.SELF)), configuration); }
Example #27
Source File: TaskHistoryEventControllerIntTest.java From taskana with Apache License 2.0 | 5 votes |
@Test public void testGetAllHistoryEvent() { ResponseEntity<TaskHistoryEventListResource> response = template.exchange( server + port + "/api/v1/task-history-event", HttpMethod.GET, request, ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getContent()).hasSize(45); }
Example #28
Source File: TaskControllerIntTest.java From taskana with Apache License 2.0 | 5 votes |
@Test void testGetQueryByPorSecondPageSortedByType() { resetDb(); // required because // ClassificationControllerIntTest.testGetQueryByPorSecondPageSortedByType changes // tasks and this test depends on the tasks as they are in sampledata HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersTeamlead_1()); ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?por.company=00&por.system=PASystem&por.instance=00&" + "por.type=VNR&por.value=22334455&sort-by=por.type&" + "order=asc&page-size=5&page=2", HttpMethod.GET, request, TASK_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat(response.getBody().getContent()) .extracting(TaskSummaryRepresentationModel::getTaskId) .containsOnly("TKI:000000000000000000000000000000000013"); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF).getHref()) .endsWith( "/api/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&" + "por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&" + "page-size=5&page=2"); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.PREV)).isNotNull(); }
Example #29
Source File: TaskControllerIntTest.java From taskana with Apache License 2.0 | 5 votes |
@Test void testGetLastPageSortedByDueWithHiddenTasksRemovedFromResult() { resetDb(); // required because // ClassificationControllerIntTest.testGetQueryByPorSecondPageSortedByType changes // tasks and this test depends on the tasks as they are in sampledata HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersTeamlead_1()); ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?sort-by=due&order=desc", HttpMethod.GET, request, TASK_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat((response.getBody()).getContent()).hasSize(25); response = TEMPLATE.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?sort-by=due&order=desc&page-size=5&page=5", HttpMethod.GET, request, TASK_SUMMARY_PAGE_MODEL_TYPE); assertThat(response.getBody()).isNotNull(); assertThat((response.getBody()).getContent()).hasSize(5); assertThat(response.getBody().getRequiredLink(IanaLinkRelations.LAST).getHref()) .contains("page=5"); assertThat("TKI:000000000000000000000000000000000023") .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?sort-by=due&order=desc&page-size=5&page=5"); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.PREV)).isNotNull(); }
Example #30
Source File: JavassistClientProxyFactoryTest.java From bowman with Apache License 2.0 | 5 votes |
@Test public void createReturnsProxyWithLinkedResourceWithCustomRel() { EntityModel<Entity> resource = new EntityModel<>(new Entity(), new Link("http://www.example.com/association/linked", "a:b")); when(restOperations.getResource(URI.create("http://www.example.com/association/linked"), Entity.class)).thenReturn(new EntityModel<>(new Entity(), new Link("http://www.example.com/1", IanaLinkRelations.SELF))); Entity proxy = proxyFactory.create(resource, restOperations); assertThat(proxy.getLinkedWithCustomRel().getId(), is(URI.create("http://www.example.com/1"))); }