Search in sources :

Example 6 with TransactionInfoEvent

use of org.neo4j.server.http.cypher.format.api.TransactionInfoEvent in project neo4j by neo4j.

the class ExecutionResultSerializerTest method shouldSerializeResponseWithCommitUriAndResults.

@Test
void shouldSerializeResponseWithCommitUriAndResults() {
    // given
    var row = Map.of("column1", "value1", "column2", "value2");
    // when
    writeStatementStart(serializer, "column1", "column2");
    writeRecord(serializer, row, "column1", "column2");
    writeStatementEnd(serializer);
    serializer.writeTransactionInfo(new TransactionInfoEvent(TransactionNotificationState.NO_TRANSACTION, URI.create("commit/uri/1"), -1));
    // then
    String result = output.toString(UTF_8);
    assertEquals("{\"results\":[{\"columns\":[\"column1\",\"column2\"]," + "\"data\":[{\"row\":[\"value1\",\"value2\"],\"meta\":[null,null]}]}],\"errors\":[],\"commit\":\"commit/uri/1\"}", result);
}
Also used : TransactionInfoEvent(org.neo4j.server.http.cypher.format.api.TransactionInfoEvent) Test(org.junit.jupiter.api.Test)

Example 7 with TransactionInfoEvent

use of org.neo4j.server.http.cypher.format.api.TransactionInfoEvent in project neo4j by neo4j.

the class LineDelimitedEventSourceJoltSerializer method handleEvent.

@Override
public final void handleEvent(OutputEvent event) {
    switch(event.getType()) {
        case STATEMENT_START:
            StatementStartEvent statementStartEvent = (StatementStartEvent) event;
            InputStatement inputStatement = JsonMessageBodyReader.getInputStatement(parameters, statementStartEvent.getStatement());
            writeStatementStart(statementStartEvent, inputStatement);
            break;
        case RECORD:
            writeRecord((RecordEvent) event);
            break;
        case STATEMENT_END:
            StatementEndEvent statementEndEvent = (StatementEndEvent) event;
            writeStatementEnd(statementEndEvent);
            break;
        case FAILURE:
            FailureEvent failureEvent = (FailureEvent) event;
            writeFailure(failureEvent);
            break;
        case TRANSACTION_INFO:
            TransactionInfoEvent transactionInfoEvent = (TransactionInfoEvent) event;
            writeErrorWrapper();
            writeTransactionInfo(transactionInfoEvent);
            break;
        default:
            throw new IllegalStateException("Unsupported event encountered:" + event.getType());
    }
}
Also used : TransactionInfoEvent(org.neo4j.server.http.cypher.format.api.TransactionInfoEvent) StatementStartEvent(org.neo4j.server.http.cypher.format.api.StatementStartEvent) FailureEvent(org.neo4j.server.http.cypher.format.api.FailureEvent) StatementEndEvent(org.neo4j.server.http.cypher.format.api.StatementEndEvent) InputStatement(org.neo4j.server.http.cypher.format.input.json.InputStatement)

Example 8 with TransactionInfoEvent

use of org.neo4j.server.http.cypher.format.api.TransactionInfoEvent in project neo4j by neo4j.

the class ExecutionResultSerializer method handleEvent.

public final void handleEvent(OutputEvent event) {
    switch(event.getType()) {
        case STATEMENT_START:
            StatementStartEvent statementStartEvent = (StatementStartEvent) event;
            InputStatement inputStatement = JsonMessageBodyReader.getInputStatement(parameters, statementStartEvent.getStatement());
            writeStatementStart(statementStartEvent, inputStatement);
            break;
        case RECORD:
            writeRecord((RecordEvent) event);
            break;
        case STATEMENT_END:
            StatementEndEvent statementEndEvent = (StatementEndEvent) event;
            writeStatementEnd(statementEndEvent);
            break;
        case FAILURE:
            FailureEvent failureEvent = (FailureEvent) event;
            writeFailure(failureEvent);
            break;
        case TRANSACTION_INFO:
            TransactionInfoEvent transactionInfoEvent = (TransactionInfoEvent) event;
            writeTransactionInfo(transactionInfoEvent);
            break;
        default:
            throw new IllegalStateException("Unsupported event encountered:" + event.getType());
    }
}
Also used : TransactionInfoEvent(org.neo4j.server.http.cypher.format.api.TransactionInfoEvent) StatementStartEvent(org.neo4j.server.http.cypher.format.api.StatementStartEvent) FailureEvent(org.neo4j.server.http.cypher.format.api.FailureEvent) StatementEndEvent(org.neo4j.server.http.cypher.format.api.StatementEndEvent) InputStatement(org.neo4j.server.http.cypher.format.input.json.InputStatement)

Example 9 with TransactionInfoEvent

use of org.neo4j.server.http.cypher.format.api.TransactionInfoEvent in project neo4j by neo4j.

the class AbstractEventSourceJoltSerializerTest method writeTransactionInfo.

protected static void writeTransactionInfo(LineDelimitedEventSourceJoltSerializer serializer, String commitUri) {
    serializer.writeErrorWrapper();
    serializer.writeTransactionInfo(new TransactionInfoEvent(TransactionNotificationState.NO_TRANSACTION, URI.create(commitUri), -1));
}
Also used : TransactionInfoEvent(org.neo4j.server.http.cypher.format.api.TransactionInfoEvent)

Example 10 with TransactionInfoEvent

use of org.neo4j.server.http.cypher.format.api.TransactionInfoEvent in project neo4j by neo4j.

the class LineDelimitedEventSourceJoltSerializerTest method shouldSerializeResponseWithCommitUriAndResults.

@Test
void shouldSerializeResponseWithCommitUriAndResults() {
    // given
    var row = Map.of("column1", "value1", "column2", "value2");
    // when
    writeStatementStart(serializer, "column1", "column2");
    writeRecord(serializer, row, "column1", "column2");
    writeStatementEnd(serializer);
    serializer.writeTransactionInfo(new TransactionInfoEvent(TransactionNotificationState.NO_TRANSACTION, URI.create("commit/uri/1"), -1));
    // then
    String result = output.toString(UTF_8);
    assertEquals("{\"header\":{\"fields\":[\"column1\",\"column2\"]}}\n" + "{\"data\":[{\"U\":\"value1\"},{\"U\":\"value2\"}]}\n" + "{\"summary\":{}}\n" + "{\"info\":{\"commit\":\"commit/uri/1\"}}\n", result);
}
Also used : TransactionInfoEvent(org.neo4j.server.http.cypher.format.api.TransactionInfoEvent) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionInfoEvent (org.neo4j.server.http.cypher.format.api.TransactionInfoEvent)10 Test (org.junit.jupiter.api.Test)6 FailureEvent (org.neo4j.server.http.cypher.format.api.FailureEvent)2 StatementEndEvent (org.neo4j.server.http.cypher.format.api.StatementEndEvent)2 StatementStartEvent (org.neo4j.server.http.cypher.format.api.StatementStartEvent)2 InputStatement (org.neo4j.server.http.cypher.format.input.json.InputStatement)2