use of org.neo4j.annotations.documented.Documented in project neo4j-documentation by neo4j.
the class AuthenticationDocIT method missing_authorization.
@Test
@Documented("Missing authorization\n" + "\n" + "If an +Authorization+ header is not supplied, the server will reply with an error.")
public void missing_authorization() throws JsonParseException, IOException {
// Given
startServerWithConfiguredUser();
// Document
RESTDocsGenerator.ResponseEntity response = gen.get().noGraph().expectedStatus(401).expectedHeader("WWW-Authenticate", "Basic realm=\"Neo4j\"").payload(simpleCypherRequestBody()).post(txCommitURL());
// Then
JsonNode data = JsonHelper.jsonNode(response.entity());
JsonNode firstError = data.get("errors").get(0);
assertThat(firstError.get("code").asText(), equalTo("Neo.ClientError.Security.Unauthorized"));
assertThat(firstError.get("message").asText(), equalTo("No authentication header supplied."));
}
use of org.neo4j.annotations.documented.Documented in project neo4j-documentation by neo4j.
the class TransactionDocIT method execute_statements_in_an_open_transaction.
@Test
@Documented("Execute statements in an open transaction\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.")
public void execute_statements_in_an_open_transaction() throws JsonParseException {
// Given
String location = POST(txUri()).location();
// Document
ResponseEntity response = gen.get().noGraph().expectedStatus(200).payload(quotedJson("{ 'statements': [ { 'statement': 'CREATE (n) RETURN n' } ] }")).post(location);
// Then
Map<String, Object> result = jsonToMap(response.entity());
assertThat(result, hasKey("transaction"));
assertNoErrors(result);
}
use of org.neo4j.annotations.documented.Documented in project neo4j-documentation by neo4j.
the class TransactionDocIT 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(txUri()).location();
// Document
ResponseEntity response = gen.get().noGraph().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.annotations.documented.Documented in project neo4j-documentation by neo4j.
the class TransactionDocIT method begin_and_commit_a_legacy_transaction_in_one_request.
@Test
@Documented("Begin and commit a legacy 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_legacy_transaction_in_one_request() throws JsonParseException {
// Document
ResponseEntity response = gen.get().noGraph().expectedStatus(200).payload(quotedJson("{ 'statements': [ { 'statement': 'CREATE (n) RETURN id(n)' } ] }")).post(getDatabaseUri() + "data/transaction/commit");
// Then
Map<String, Object> result = jsonToMap(response.entity());
assertNoErrors(result);
Integer id = resultCell(result, 0, 0);
verifyNodeExists(id);
}
use of org.neo4j.annotations.documented.Documented in project neo4j-documentation by neo4j.
the class TransactionDocIT method include_query_statistics.
@Test
@Documented("Include query statistics\n" + "\n" + "By setting `includeStats` to `true` for a statement, query statistics will be returned for it.")
public void include_query_statistics() throws JsonParseException {
// Document
ResponseEntity response = gen.get().noGraph().expectedStatus(200).payload(quotedJson("{ 'statements': [ { 'statement': 'CREATE (n) RETURN id(n)', 'includeStats': true } ] }")).post(txCommitUri());
// Then
Map<String, Object> entity = jsonToMap(response.entity());
assertNoErrors(entity);
Map<String, Object> firstResult = ((List<Map<String, Object>>) entity.get("results")).get(0);
assertThat(firstResult, hasKey("stats"));
Map<String, Object> stats = (Map<String, Object>) firstResult.get("stats");
assertThat((Integer) stats.get("nodes_created"), equalTo(1));
}
Aggregations