Search in sources :

Example 6 with Notification

use of org.neo4j.graphdb.Notification in project neo4j by neo4j.

the class ResultSubscriber method writeAsStringTo.

@Override
public void writeAsStringTo(PrintWriter writer) {
    ResultStringBuilder stringBuilder = ResultStringBuilder.apply(execution.fieldNames(), context);
    try {
        // paths
        if (this.hasFetchedNext()) {
            stringBuilder.addRow(new ResultRowImpl(this.getNextObject()));
        }
        accept(stringBuilder);
        stringBuilder.result(writer, statistics);
        for (Notification notification : getNotifications()) {
            writer.println(notification.getDescription());
        }
    } catch (Exception e) {
        close();
        throw converted(e);
    }
}
Also used : ResultStringBuilder(org.neo4j.cypher.internal.result.string.ResultStringBuilder) Notification(org.neo4j.graphdb.Notification) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) QueryExecutionException(org.neo4j.graphdb.QueryExecutionException) Neo4jException(org.neo4j.exceptions.Neo4jException) CypherExecutionException(org.neo4j.exceptions.CypherExecutionException)

Example 7 with Notification

use of org.neo4j.graphdb.Notification in project neo4j by neo4j.

the class NotificationCodeTest method shouldConstructNotificationFor_INDEX_HINT_UNFULFILLABLE.

@Test
void shouldConstructNotificationFor_INDEX_HINT_UNFULFILLABLE() {
    NotificationDetail indexDetail = NotificationDetail.Factory.index("Person", "name");
    Notification notification = INDEX_HINT_UNFULFILLABLE.notification(InputPosition.empty, indexDetail);
    assertThat(notification.getTitle()).isEqualTo("The request (directly or indirectly) referred to an index that does not exist.");
    assertThat(notification.getSeverity()).isEqualTo(SeverityLevel.WARNING);
    assertThat(notification.getCode()).isEqualTo("Neo.ClientError.Schema.IndexNotFound");
    assertThat(notification.getPosition()).isEqualTo(InputPosition.empty);
    assertThat(notification.getDescription()).isEqualTo("The hinted index does not exist, please check the schema (hinted index is: index on :Person(name))");
}
Also used : Notification(org.neo4j.graphdb.Notification) Test(org.junit.jupiter.api.Test)

Example 8 with Notification

use of org.neo4j.graphdb.Notification in project neo4j by neo4j.

the class NotificationCodeTest method shouldConstructNotificationsFor_DEPRECATED_PROCEDURE_with_no_newName.

@Test
void shouldConstructNotificationsFor_DEPRECATED_PROCEDURE_with_no_newName() {
    NotificationDetail identifierDetail = NotificationDetail.Factory.deprecatedName("oldName", "");
    Notification notification = DEPRECATED_PROCEDURE.notification(InputPosition.empty, identifierDetail);
    assertThat(notification.getTitle()).isEqualTo("This feature is deprecated and will be removed in future versions.");
    assertThat(notification.getSeverity()).isEqualTo(SeverityLevel.WARNING);
    assertThat(notification.getCode()).isEqualTo("Neo.ClientNotification.Statement.FeatureDeprecationWarning");
    assertThat(notification.getPosition()).isEqualTo(InputPosition.empty);
    assertThat(notification.getDescription()).isEqualTo("The query used a deprecated procedure. ('oldName' is no longer supported)");
}
Also used : Notification(org.neo4j.graphdb.Notification) Test(org.junit.jupiter.api.Test)

Example 9 with Notification

use of org.neo4j.graphdb.Notification in project neo4j by neo4j.

the class NotificationCodeTest method shouldConstructNotificationsFor_DEPRECATED_PROCEDURE.

@Test
void shouldConstructNotificationsFor_DEPRECATED_PROCEDURE() {
    NotificationDetail identifierDetail = NotificationDetail.Factory.deprecatedName("oldName", "newName");
    Notification notification = DEPRECATED_PROCEDURE.notification(InputPosition.empty, identifierDetail);
    assertThat(notification.getTitle()).isEqualTo("This feature is deprecated and will be removed in future versions.");
    assertThat(notification.getSeverity()).isEqualTo(SeverityLevel.WARNING);
    assertThat(notification.getCode()).isEqualTo("Neo.ClientNotification.Statement.FeatureDeprecationWarning");
    assertThat(notification.getPosition()).isEqualTo(InputPosition.empty);
    assertThat(notification.getDescription()).isEqualTo("The query used a deprecated procedure. ('oldName' has been replaced by 'newName')");
}
Also used : Notification(org.neo4j.graphdb.Notification) Test(org.junit.jupiter.api.Test)

Example 10 with Notification

use of org.neo4j.graphdb.Notification in project neo4j by neo4j.

the class NotificationCodeTest method shouldConstructNotificationsFor_JOIN_HINT_UNFULFILLABLE.

@Test
void shouldConstructNotificationsFor_JOIN_HINT_UNFULFILLABLE() {
    List<String> idents = new ArrayList<>();
    idents.add("n");
    idents.add("node2");
    NotificationDetail identifierDetail = NotificationDetail.Factory.joinKey(idents);
    Notification notification = JOIN_HINT_UNFULFILLABLE.notification(InputPosition.empty, identifierDetail);
    assertThat(notification.getTitle()).isEqualTo("The database was unable to plan a hinted join.");
    assertThat(notification.getSeverity()).isEqualTo(SeverityLevel.WARNING);
    assertThat(notification.getCode()).isEqualTo("Neo.ClientNotification.Statement.JoinHintUnfulfillableWarning");
    assertThat(notification.getPosition()).isEqualTo(InputPosition.empty);
    assertThat(notification.getDescription()).isEqualTo("The hinted join was not planned. This could happen because no generated plan contained the join key, " + "please try using a different join key or restructure your query. " + "(hinted join key identifiers are: n, node2)");
}
Also used : ArrayList(java.util.ArrayList) Notification(org.neo4j.graphdb.Notification) Test(org.junit.jupiter.api.Test)

Aggregations

Notification (org.neo4j.graphdb.Notification)21 Test (org.junit.jupiter.api.Test)10 InputPosition (org.neo4j.graphdb.InputPosition)5 Result (org.neo4j.graphdb.Result)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 Neo4jJsonCodecTest (org.neo4j.server.rest.transactional.Neo4jJsonCodecTest)3 ExecutionPlanDescription (org.neo4j.graphdb.ExecutionPlanDescription)2 QueryExecutionType (org.neo4j.graphdb.QueryExecutionType)2 Transaction (org.neo4j.graphdb.Transaction)2 ConnectionException (org.neo4j.server.http.cypher.format.api.ConnectionException)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Config (org.neo4j.configuration.Config)1 ResultStringBuilder (org.neo4j.cypher.internal.result.string.ResultStringBuilder)1 CypherExecutionException (org.neo4j.exceptions.CypherExecutionException)1 Neo4jException (org.neo4j.exceptions.Neo4jException)1 QueryExecutionException (org.neo4j.graphdb.QueryExecutionException)1