Search in sources :

Example 16 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class AbstractTransactionInitiatingMessage method shouldParseTransactionTimeoutCorrectly.

@Test
void shouldParseTransactionTimeoutCorrectly() throws Throwable {
    // Given
    Map<String, Object> msgMetadata = map("tx_timeout", 123456L);
    MapValue meta = ValueUtils.asMapValue(msgMetadata);
    // When
    TransactionInitiatingMessage beginMessage = createMessage(meta);
    // Then
    assertThat(beginMessage.transactionTimeout().toMillis()).isEqualTo(123456L);
}
Also used : MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test)

Example 17 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class AbstractTransactionInitiatingMessage method shouldParseReadAccessModeCorrectly.

@Test
void shouldParseReadAccessModeCorrectly() throws Throwable {
    // Given
    Map<String, Object> msgMetadata = map("mode", "r");
    MapValue meta = ValueUtils.asMapValue(msgMetadata);
    // When
    TransactionInitiatingMessage beginMessage = createMessage(meta);
    // Then
    assertThat(beginMessage.getAccessMode()).isEqualTo(AccessMode.READ);
}
Also used : MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test)

Example 18 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class AbstractTransactionInitiatingMessage method shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly.

@Test
void shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly() throws Throwable {
    // Given
    Map<String, Object> msgMetadata = map("tx_metadata", "invalid value type");
    MapValue meta = ValueUtils.asMapValue(msgMetadata);
    // When & Then
    BoltIOException exception = assertThrows(BoltIOException.class, () -> createMessage(meta));
    assertThat(exception.getMessage()).startsWith("Expecting transaction metadata value to be a Map value");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test)

Example 19 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class AbstractTransactionInitiatingMessage method shouldParseNoAccessModeCorrectly.

@Test
void shouldParseNoAccessModeCorrectly() throws Throwable {
    // Given
    Map<String, Object> msgMetadata = map();
    MapValue meta = ValueUtils.asMapValue(msgMetadata);
    // When
    TransactionInitiatingMessage beginMessage = createMessage(meta);
    // Then
    assertThat(beginMessage.getAccessMode()).isEqualTo(AccessMode.WRITE);
}
Also used : MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test)

Example 20 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class AbstractTransactionInitiatingMessage method shouldThrowExceptionIfFailedToParseTransactionTimeoutCorrectly.

@Test
void shouldThrowExceptionIfFailedToParseTransactionTimeoutCorrectly() throws Throwable {
    // Given
    Map<String, Object> msgMetadata = map("tx_timeout", "invalid value type");
    MapValue meta = ValueUtils.asMapValue(msgMetadata);
    // When & Then
    BoltIOException exception = assertThrows(BoltIOException.class, () -> createMessage(meta));
    assertThat(exception.getMessage()).startsWith("Expecting transaction timeout value to be a Long value");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test)

Aggregations

MapValue (org.neo4j.values.virtual.MapValue)48 Test (org.junit.jupiter.api.Test)30 AnyValue (org.neo4j.values.AnyValue)7 BoltIOException (org.neo4j.bolt.messaging.BoltIOException)6 QueryExecution (org.neo4j.kernel.impl.query.QueryExecution)6 BoltAdapterSubscriber (org.neo4j.bolt.runtime.statemachine.impl.BoltAdapterSubscriber)5 QueryStatistics (org.neo4j.graphdb.QueryStatistics)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)3 ValueUtils.asMapValue (org.neo4j.kernel.impl.util.ValueUtils.asMapValue)3 Clock (java.time.Clock)2 LocalDate (java.time.LocalDate)2 HashMap (java.util.HashMap)2 SuccessMessage (org.neo4j.bolt.v3.messaging.response.SuccessMessage)2 NotFoundException (org.neo4j.graphdb.NotFoundException)2 RelationshipEntity (org.neo4j.kernel.impl.core.RelationshipEntity)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 DateTimeException (java.time.DateTimeException)1