@Test
public void testUpdateRoot() throws Exception {
final Instant early = now();
final TriplestoreResourceService svc = new TriplestoreResourceService(
connect(wrap(rdf.createDataset().asJenaDatasetGraph())));
svc.initialize();
final Resource res1 = svc.get(root).toCompletableFuture().join();
assertAll("Check resource", checkResource(res1, root, LDP.BasicContainer, early));
assertAll("Check resource stream", checkResourceStream(res1, 0L, 5L, 0L, 0L, 0L));
final Dataset data = rdf.createDataset();
svc.get(root).thenAccept(res ->
res.stream().filter(q -> !q.getGraphName().filter(Trellis.PreferServerManaged::equals).isPresent())
.forEach(data::add)).toCompletableFuture().join();
data.add(Trellis.PreferUserManaged, root, RDFS.label, rdf.createLiteral("Resource Label"));
data.add(Trellis.PreferUserManaged, root, RDFS.seeAlso, rdf.createIRI("http://example.com"));
data.add(Trellis.PreferUserManaged, root, LDP.inbox, rdf.createIRI("http://ldn.example.com/"));
data.add(Trellis.PreferUserManaged, root, RDF.type, rdf.createLiteral("Some weird type"));
data.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Update);
final Instant later = meanwhile();
assertDoesNotThrow(() -> svc.replace(builder(root).interactionModel(LDP.BasicContainer).build(), data)
.toCompletableFuture().join(), "Unsuccessful replace operation!");
final Resource res2 = svc.get(root).toCompletableFuture().join();
assertAll("Check resource", checkResource(res2, root, LDP.BasicContainer, later));
assertAll("Check resource stream", checkResourceStream(res2, 4L, 5L, 1L, 0L, 0L));
}