Skip to content

Instantly share code, notes, and snippets.

@emetsger
Last active April 26, 2016 20:10
Show Gist options
  • Save emetsger/b89d3142174c65306e99cd6006fd9a09 to your computer and use it in GitHub Desktop.
Save emetsger/b89d3142174c65306e99cd6006fd9a09 to your computer and use it in GitHub Desktop.
@Type("nodes")
public class Node {
// other fields
@Id
private String id;
@Relationship(value = "root", resolve = true)
private Node root;
// Getters and Setters
}
public class TestClient {
@Test
public void testFoo() throws Exception {
// blah blah
ResourceConverter converter = new ResourceConverter(objectMapper, Node.class);
converter.setGlobalResolver(relUrl -> {
com.squareup.okhttp.Call req = client.newCall(new Request.Builder().url(relUrl).build());
try {
return req.execute().body().bytes();
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
});
JSONAPIConverterFactory converterFactory = new JSONAPIConverterFactory(converter);
// blah blah
}
}
// The JSON relattionship object
"root": {
"links": {
"related": {
"href": "http://osf:8000/v2/nodes/mrusa/",
"meta": {}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment