use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class TransactionTest method begin_a_transaction.
@Test
@Documented("Begin a transaction\n" + "\n" + "You begin a new transaction by posting zero or more Cypher statements\n" + "to the transaction endpoint. The server will respond with the result of\n" + "your statements, as well as the location of your open transaction.")
public void begin_a_transaction() throws JsonParseException {
// Document
ResponseEntity response = gen.get().expectedStatus(201).payload(quotedJson("{ 'statements': [ { 'statement': 'CREATE (n {props}) RETURN n', " + "'parameters': { 'props': { 'name': 'My Node' } } } ] }")).post(getDataUri() + "transaction");
// Then
Map<String, Object> result = jsonToMap(response.entity());
assertNoErrors(result);
Map<String, Object> node = resultCell(result, 0, 0);
assertThat((String) node.get("name"), equalTo("My Node"));
}
use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class TransactionTest method begin_and_commit_a_transaction_in_one_request.
@Test
@Documented("Begin and commit a transaction in one request\n" + "\n" + "If there is no need to keep a transaction open across multiple HTTP requests, you can begin a transaction,\n" + "execute statements, and commit with just a single HTTP request.")
public void begin_and_commit_a_transaction_in_one_request() throws JsonParseException {
// Document
ResponseEntity response = gen.get().expectedStatus(200).payload(quotedJson("{ 'statements': [ { 'statement': 'CREATE (n) RETURN id(n)' } ] }")).post(getDataUri() + "transaction/commit");
// Then
Map<String, Object> result = jsonToMap(response.entity());
assertNoErrors(result);
Integer id = resultCell(result, 0, 0);
assertThat(GET(getNodeUri(id)).status(), is(200));
}
use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class TransactionTest method commit_an_open_transaction.
@Test
@Documented("Commit an open transaction\n" + "\n" + "Given you have an open transaction, you can send a commit request. Optionally, you submit additional statements\n" + "along with the request that will be executed before committing the transaction.")
public void commit_an_open_transaction() throws JsonParseException {
// Given
String location = POST(getDataUri() + "transaction").location();
// Document
ResponseEntity response = gen.get().expectedStatus(200).payload(quotedJson("{ 'statements': [ { 'statement': 'CREATE (n) RETURN id(n)' } ] }")).post(location + "/commit");
// Then
Map<String, Object> result = jsonToMap(response.entity());
assertNoErrors(result);
Integer id = resultCell(result, 0, 0);
assertThat(GET(getNodeUri(id)).status(), is(200));
}
use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class TransactionTest method execute_statements_in_an_open_transaction_using_REST.
@Test
@Documented("Execute statements in an open transaction in REST format for the return.\n" + "\n" + "Given that you have an open transaction, you can make a number of requests, each of which executes additional\n" + "statements, and keeps the transaction open by resetting the transaction timeout. Specifying the `REST` format will\n" + "give back full Neo4j Rest API representations of the Neo4j Nodes, Relationships and Paths, if returned.")
public void execute_statements_in_an_open_transaction_using_REST() throws JsonParseException {
// Given
String location = POST(getDataUri() + "transaction").location();
// Document
ResponseEntity response = gen.get().expectedStatus(200).payload(quotedJson("{ 'statements': [ { 'statement': 'CREATE (n) RETURN n','resultDataContents':['REST'] } ] }")).post(location);
// Then
Map<String, Object> result = jsonToMap(response.entity());
ArrayList rest = (ArrayList) ((Map) ((ArrayList) ((Map) ((ArrayList) result.get("results")).get(0)).get("data")).get(0)).get("rest");
String selfUri = (String) ((Map) rest.get(0)).get("self");
assertTrue(selfUri.startsWith(getDatabaseUri()));
assertNoErrors(result);
}
use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class TestData method apply.
@Override
public Statement apply(final Statement base, final Description description) {
final Title title = description.getAnnotation(Title.class);
final Documented doc = description.getAnnotation(Documented.class);
GraphDescription.Graph g = description.getAnnotation(GraphDescription.Graph.class);
if (g == null) {
g = description.getTestClass().getAnnotation(GraphDescription.Graph.class);
}
final GraphDescription graph = GraphDescription.create(g);
return new Statement() {
@Override
public void evaluate() throws Throwable {
product.set(create(graph, title == null ? null : title.value(), doc == null ? null : doc.value(), description.getMethodName()));
try {
try {
base.evaluate();
} catch (Throwable err) {
try {
destroy(get(false), false);
} catch (Throwable sub) {
List<Throwable> failures = new ArrayList<Throwable>();
if (err instanceof MultipleFailureException) {
failures.addAll(((MultipleFailureException) err).getFailures());
} else {
failures.add(err);
}
failures.add(sub);
throw new MultipleFailureException(failures);
}
throw err;
}
destroy(get(false), false);
} finally {
product.set(null);
}
}
};
}
Aggregations