private Label[] randomLabels() { List<Label> labels = new ArrayList<>( 3 ); for ( Label label : LABEL_ALPHABET ) { if ( random.nextBoolean() ) { labels.add( label ); } } return labels.toArray( new Label[labels.size()] ); }
private Label[] randomLabels() { List<Label> labels = new ArrayList<>( LABELS.length ); for ( Label label : LABELS ) { if ( random.nextBoolean() ) { labels.add( label ); } } return labels.toArray( new Label[labels.size()] ); }
VisitationOrder( int size ) { for ( Method method : getClass().getDeclaredMethods() ) { if ( method.getName().startsWith( "visit" ) ) { visitMethods.add( method.getName() ); } } assertEquals( "should implement exactly two visit*(...) methods", 2, visitMethods.size() ); do { if ( random.nextBoolean() ) { createEarlyState(); } else { createLateState(); } } while ( size-- > 0 ); }
private Page randomPage( int corruptionPercent, MutableInt totalNumberOfCorruptions ) { int numberOfCorruptions = 0; boolean internal = randomRule.nextBoolean(); if ( randomRule.nextInt( 100 ) < corruptionPercent ) { int maxCorruptions = internal ? possibleCorruptionsInInternal.size() : possibleCorruptionsInLeaf.size(); numberOfCorruptions = randomRule.intBetween( 1, maxCorruptions ); totalNumberOfCorruptions.add( numberOfCorruptions ); } return internal ? randomInternal( numberOfCorruptions ) : randomLeaf( numberOfCorruptions ); }
private long[] randomNodes( Ids[] ids ) { long[] nodeIds = new long[ids.length]; int cursor = 0; for ( Ids id : ids ) { if ( random.nextBoolean() ) { nodeIds[cursor++] = id.node.getId(); } } // If none was selected, then pick just one if ( cursor == 0 ) { nodeIds[cursor++] = random.among( ids ).node.getId(); } return Arrays.copyOf( nodeIds, cursor ); }
int stride = random.nextBoolean() ? 1 : -1; int maxNumberOfSteps = random.nextInt( 10 ) + 1;
@Test public void shouldScanAllInUseRelationships() { // given RelationshipStore relationshipStore = neoStores.getRelationshipStore(); int count = 100; relationshipStore.setHighId( count ); Set<Long> expected = new HashSet<>(); for ( long id = 0; id < count; id++ ) { boolean inUse = random.nextBoolean(); createRelationshipRecord( id, 1, relationshipStore, inUse ); if ( inUse ) { expected.add( id ); } } // when assertSeesRelationships( expected, ANY_RELATIONSHIP_TYPE ); }
@Test public void shouldHandleHolesInIdSequence() { // GIVEN IdMapper mapper = mapper( new LongEncoder(), Radix.LONG, NO_MONITOR ); List<Object> ids = new ArrayList<>(); for ( int i = 0; i < 100; i++ ) { if ( random.nextBoolean() ) { // Skip this one } else { Long id = (long) i; ids.add( id ); mapper.put( id, i, GLOBAL ); } } // WHEN mapper.prepare( values( ids.toArray() ), mock( Collector.class ), NONE ); // THEN for ( Object id : ids ) { assertEquals( ((Long)id).longValue(), mapper.get( id, GLOBAL ) ); } }
@Test public void shouldScanAllInUseRelationshipsOfCertainType() { // given RelationshipStore relationshipStore = neoStores.getRelationshipStore(); int count = 100; relationshipStore.setHighId( count ); Set<Long> expected = new HashSet<>(); int theType = 1; for ( long id = 0; id < count; id++ ) { boolean inUse = random.nextBoolean(); int type = random.nextInt( 3 ); createRelationshipRecord( id, type, relationshipStore, inUse ); if ( inUse && type == theType ) { expected.add( id ); } } // when assertSeesRelationships( expected, theType ); }
private GenericKey genericKeyStateWithSomePreviousState( ValueGenerator valueGenerator ) { GenericKey to = newKeyState(); if ( random.nextBoolean() ) { // Previous value NativeIndexKey.Inclusion inclusion = random.among( NativeIndexKey.Inclusion.values() ); Value value = valueGenerator.next(); to.writeValue( value, inclusion ); } // No previous state return to; }
while ( source1HasNext && source2HasNext ) if ( rnd.nextBoolean() )
propertyKeyIds[i] = propertyKeyId; if ( (filterCount == 0 && i == slots - 1) || random.nextBoolean() ) filterCount++; values[i] = random.nextBoolean() ? NO_VALUE : actualValues[i]; properties.put( propertyKeyId, actualValues[i] );
Generator<R> generator = generatorSupplier.get(); int recordSize = format.getRecordSize( new IntStoreHeader( DATA_SIZE ) ); BatchingIdSequence idSequence = new BatchingIdSequence( random.nextBoolean() ? idSureToBeOnTheNextPage( PAGE_SIZE, recordSize ) : 10 );
@Test void shouldHandleStringPredicates() { for ( int i = 0; i < ITERATIONS; i++ ) { String value = random.nextString(); String other; if ( random.nextBoolean() ) { other = value; } else { other = random.nextString(); } assertConsistent( value, other, TextValue::startsWith ); assertConsistent( value, other, TextValue::endsWith ); assertConsistent( value, other, TextValue::contains ); } }
if ( random.nextBoolean() )
to = tmp; boolean fromInclusive = random.nextBoolean(); boolean toInclusive = random.nextBoolean();
private void markRandomRelsInChainNotInUse( long relId ) { if ( relId != NO_NEXT_RELATIONSHIP.intValue() ) { RelationshipRecord record = getRelRecord( relId ); boolean shouldBeMarked = random.nextBoolean(); if ( shouldBeMarked ) { record.setInUse( false ); update( record ); } markRandomRelsInChainNotInUse( record.getFirstNextRel() ); boolean isLoopRelationship = record.getFirstNextRel() == record.getSecondNextRel(); if ( !isLoopRelationship ) { markRandomRelsInChainNotInUse( record.getSecondNextRel() ); } } }
to = tmp; boolean fromInclusive = random.nextBoolean(); boolean toInclusive = random.nextBoolean();
final long ref = container.add( value ); final ObjectLongPair<Value> pair = pair( value, ref ); if ( rnd.nextBoolean() )
private void createIndexesButDontWaitForThemToFullyPopulate( int i ) { try ( Transaction tx = db.beginTx() ) { db.schema().indexFor( labelA( i ) ).on( keyA( i ) ).create(); if ( random.nextBoolean() ) { db.schema().indexFor( labelB( i ) ).on( keyB( i ) ).create(); } else { db.schema().constraintFor( labelB( i ) ).assertPropertyIsUnique( keyB( i ) ).create(); } tx.success(); } }