-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathExample.java
37 lines (27 loc) · 1.19 KB
/
Example.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.mercateo.rest.hateoas.client.example;
import java.util.Optional;
import com.mercateo.rest.hateoas.client.ClientStarter;
import com.mercateo.rest.hateoas.client.ListResponse;
import com.mercateo.rest.hateoas.client.Response;
import lombok.Value;
public class Example {
@Value
public static class IdBean {
String id;
}
public static void main(String[] args) {
Response<Object> rootResource = new ClientStarter().create("http://localhost:9090", Object.class);
Optional<ListResponse<OrderProjectionJson>> collectionResource = rootResource
.prepareNextWithResponse(OrderProjectionJson.class).callListWithRel("orders");
SendBackJson sendBackJson = new SendBackJson("test");
Optional<Response<OrderProjectionJson>> secondListElementResource = collectionResource.get().get(1);
System.out.println(secondListElementResource.get().getResponseObject());
Optional<Response<Void>> sentBack1 = secondListElementResource.get().prepareNextWithResponse(Void.class)
.withRequestObject(sendBackJson).callWithRel("send-back");
if (sentBack1.isPresent()) {
System.out.println("sent back in list");
} else {
System.out.println("no send-back available in list available");
}
}
}