uk.co.blackpepper:hal-client-test-it

A Java library for accessing a JSON+HAL REST API

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

uk.co.blackpepper
ArtifactId

ArtifactId

hal-client-test-it
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

A Java library for accessing a JSON+HAL REST API
Project Organization

Project Organization

Black Pepper Software

Download hal-client-test-it

How to add to project

<!-- https://jarcasting.com/artifacts/uk.co.blackpepper/hal-client-test-it/ -->
<dependency>
    <groupId>uk.co.blackpepper</groupId>
    <artifactId>hal-client-test-it</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/uk.co.blackpepper/hal-client-test-it/
implementation 'uk.co.blackpepper:hal-client-test-it:0.1.1'
// https://jarcasting.com/artifacts/uk.co.blackpepper/hal-client-test-it/
implementation ("uk.co.blackpepper:hal-client-test-it:0.1.1")
'uk.co.blackpepper:hal-client-test-it:jar:0.1.1'
<dependency org="uk.co.blackpepper" name="hal-client-test-it" rev="0.1.1">
  <artifact name="hal-client-test-it" type="jar" />
</dependency>
@Grapes(
@Grab(group='uk.co.blackpepper', module='hal-client-test-it', version='0.1.1')
)
libraryDependencies += "uk.co.blackpepper" % "hal-client-test-it" % "0.1.1"
[uk.co.blackpepper/hal-client-test-it "0.1.1"]

Dependencies

compile (5)

Group / Artifact Type Version
uk.co.blackpepper : hal-client jar 0.1.1
uk.co.blackpepper : hal-client-test-client jar 0.1.1
org.springframework.boot : spring-boot-starter-logging jar
junit : junit jar 4.12
org.hamcrest : hamcrest-library jar 1.3

Project Modules

There are no modules declared in this project.

Bowman

bowman badge bowman client

Bowman is a Java library for accessing a JSON+HAL REST API.

Features

  • Simplified API consumption via automatic, lazy link traversal on an annotated client-side model

  • Tailor made for Spring Data REST

  • Analogous interface to JPA

  • RESTful CRUD and templated link query support

  • Polymorphic deserialisation

Standing on the shoulders of Spring HATEOAS and Jackson.

Usage Example

Given the following annotated model objects:

@RemoteResource("/people")
public class Person {

  private URI id;
  private String name;

  public Person() {}
  public Person(String name) { this.name = name; }

  @ResourceId public URI getId() { return id; }
  public String getName() { return name; }
}

and

@RemoteResource("/greetings")
public class Greeting {

  private URI id;
  private Person recipient;
  private String message;

  public Greeting() {}
  public Greeting(String message, Person recipient)
    { this.message = message; this.recipient = recipient; }

  @ResourceId public URI getId() { return id; }
  @LinkedResource public Person getRecipient() { return recipient; }
  public String getMessage() { return message; }
}

Client instances can be constructed and used as demonstrated below.

The HTTP requests/responses corresponding to each instruction are shown in a comment beneath.

ClientFactory factory = Configuration.builder().setBaseUri("http://...").build()
    .buildClientFactory();

Client<Person> people = factory.create(Person.class);
Client<Greeting> greetings = factory.create(Greeting.class);

URI id = people.post(new Person("Bob"));
// POST /people {"name": "Bob"}
//  -> Location: http://.../people/1

Person recipient = people.get(id);
// GET /people/1
//  -> {"name": "Bob", "_links": {"self": {"href": "http://.../people/1"}}}

assertThat(recipient.getName(), is("Bob"));

id = greetings.post(new Greeting("hello", recipient));
// POST /greetings {"message": "hello", "recipient": "http://.../people/1"}}
//  -> Location: http://.../greetings/1

Greeting greeting = greetings.get(id);
// GET /greetings/1
//  -> {"message": "hello", "_links": {"self": {"href": "http://.../greetings/1"},
// 			"recipient": {"href": "http://.../people/1"}}}

assertThat(greeting.getMessage(), is("hello"));

recipient = greeting.getRecipient();
// GET /people/1
//  -> {"name": "Bob", "_links": {"self": {"href": {"http://.../people/1"}}}

assertThat(recipient.getName(), is("Bob"));

Contributing

uk.co.blackpepper

Black Pepper Software

An agile software development company focused on providing business value.

Versions

Version
0.1.1
0.1.0