public static LongValue longValue( long value ) { return new LongValue( value ); }
@Override public String toString() { return format( "%s(%d)", getTypeName(), value ); }
static Duration parseTransactionTimeout( MapValue meta ) throws BoltIOException { AnyValue anyValue = meta.get( TX_TIMEOUT_KEY ); if ( anyValue == Values.NO_VALUE ) { return null; } else if ( anyValue instanceof LongValue ) { return Duration.ofMillis( ((LongValue) anyValue).longValue() ); } else { throw new BoltIOException( Status.Request.Invalid, "Expecting transaction timeout value to be a Long value, but got: " + anyValue ); } }
@Test void shouldHandleLargeNanos() { DurationValue duration = DurationValue.duration( 0L, 0L, 0L, Long.MAX_VALUE ); assertEquals( Long.MAX_VALUE, duration.get( "nanoseconds" ).value() ); }
@Test public void nextLongValueBoundedAndShifted() { Set<Value> values = new HashSet<>(); for ( int i = 0; i < ITERATIONS; i++ ) { LongValue value = randomValues.nextLongValue( 1337, 1337 + BOUND ); assertThat( value, notNullValue() ); assertThat( value.compareTo( longValue( 1337 ) ), greaterThanOrEqualTo( 0 ) ); assertThat( value.toString(), value.compareTo( longValue( 1337 + BOUND ) ), lessThanOrEqualTo( 0 ) ); values.add( value ); } assertThat( values.size(), greaterThan( 1 ) ); }
@Test void shouldFailOnOverflowingMultiplication() { assertThrows( ArithmeticException.class, () -> longValue( Long.MAX_VALUE ).times( 2 ) ); }
@Test void shouldFailOnOverflowingAdd() { assertThrows(ArithmeticException.class, () -> longValue( Long.MAX_VALUE ).plus( longValue( 1 ) ) ); }
@Test void shouldFailOnOverflowingSubtraction() { assertThrows( ArithmeticException.class, () -> longValue( Long.MAX_VALUE ).minus( longValue( -1 ) ) ); }
@Test public void shouldBeAbleToCleanlyRunMultipleSessionsInSingleThread() throws Throwable { // Given BoltStateMachine firstMachine = env.newMachine( BOLT_CHANNEL ); firstMachine.process( new InitMessage( USER_AGENT, emptyMap() ), null ); BoltStateMachine secondMachine = env.newMachine( BOLT_CHANNEL ); secondMachine.process( new InitMessage( USER_AGENT, emptyMap() ), null ); // And given I've started a transaction in one session runAndPull( firstMachine, "BEGIN" ); // When I issue a statement in a separate session Object[] stream = runAndPull( secondMachine, "CREATE (a:Person) RETURN id(a)" ); long id = ((LongValue) ((Record) stream[0]).fields()[0]).value(); // And when I roll back that first session transaction runAndPull( firstMachine, "ROLLBACK" ); // Then the two should not have interfered with each other stream = runAndPull( secondMachine, "MATCH (a:Person) WHERE id(a) = " + id + " RETURN COUNT(*)" ); assertThat( ((Record) stream[0]).fields()[0], equalTo( longValue( 1L ) ) ); }
long targetNodeId = randomValues.nextLongValue( totalNodes ).value(); databaseService.getNodeById( targetNodeId ).delete(); break; case 1: long nodeId = randomValues.nextLongValue( totalNodes ).value(); Node node = databaseService.getNodeById( nodeId ); Map<String,Object> allProperties = node.getAllProperties();
@Override public String toString() { return format( "%s(%d)", getTypeName(), value ); }
public static LongValue longValue( long value ) { return new LongValue( value ); }
static Duration parseTransactionTimeout( MapValue meta ) throws BoltIOException { AnyValue anyValue = meta.get( TX_TIMEOUT_KEY ); if ( anyValue == Values.NO_VALUE ) { return null; } else if ( anyValue instanceof LongValue ) { return Duration.ofMillis( ((LongValue) anyValue).longValue() ); } else { throw new BoltIOException( Status.Request.Invalid, "Expecting transaction timeout value to be a Long value, but got: " + anyValue ); } }