Skip to content

Commit

Permalink
Merge Randoms and RandomValues
Browse files Browse the repository at this point in the history
`Randoms` is removed and all its functionality is moved over to
`RandomValues`. This includes the ability for `RandomValues` to be
accessed directly on `RandomRule`. In order to accomodate this
`RandomRule` has moved out of `commons` and into `neo4j-random-values`.
  • Loading branch information
pontusmelke committed May 11, 2018
1 parent ed656b5 commit 28feea7
Show file tree
Hide file tree
Showing 38 changed files with 276 additions and 1,170 deletions.
436 changes: 0 additions & 436 deletions community/common/src/test/java/org/neo4j/test/Randoms.java

This file was deleted.

272 changes: 0 additions & 272 deletions community/common/src/test/java/org/neo4j/test/rule/RandomRule.java

This file was deleted.

6 changes: 6 additions & 0 deletions community/index/pom.xml
Expand Up @@ -75,6 +75,12 @@ the relevant Commercial Agreement.
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-random-values</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId> <groupId>org.neo4j</groupId>
<artifactId>neo4j-collections</artifactId> <artifactId>neo4j-collections</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
Expand Down
Expand Up @@ -39,7 +39,6 @@
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.neo4j.test.Randoms.CSA_LETTERS_AND_DIGITS;


public class LargeDynamicKeysIT public class LargeDynamicKeysIT
{ {
Expand Down Expand Up @@ -72,7 +71,7 @@ public void shouldWriteAndReadKeysOfSizesCloseToTheLimits() throws IOException
String string; String string;
do do
{ {
string = random.string( 3_000, 4_000, CSA_LETTERS_AND_DIGITS ); string = random.nextAlphaNumericString( 3_000, 4_000 );
} }
while ( !generatedStrings.add( string ) ); while ( !generatedStrings.add( string ) );
RawBytes key = new RawBytes(); RawBytes key = new RawBytes();
Expand Down
12 changes: 6 additions & 6 deletions community/kernel/src/test/java/org/neo4j/kernel/RecoveryIT.java
Expand Up @@ -555,7 +555,7 @@ private void produceRandomGraphUpdates( GraphDatabaseService db, int numberOfTra
Node node = db.createNode( random.nextBoolean() ? array( randomLabel() ) : new Label[0] ); Node node = db.createNode( random.nextBoolean() ? array( randomLabel() ) : new Label[0] );
if ( random.nextBoolean() ) if ( random.nextBoolean() )
{ {
node.setProperty( randomKey(), random.propertyValue() ); node.setProperty( randomKey(), random.nextValueAsObject() );
} }
} }
else else
Expand All @@ -566,7 +566,7 @@ private void produceRandomGraphUpdates( GraphDatabaseService db, int numberOfTra
.createRelationshipTo( random.among( nodes ), randomRelationshipType() ); .createRelationshipTo( random.among( nodes ), randomRelationshipType() );
if ( random.nextBoolean() ) if ( random.nextBoolean() )
{ {
relationship.setProperty( randomKey(), random.propertyValue() ); relationship.setProperty( randomKey(), random.nextValueAsObject() );
} }
} }
} }
Expand All @@ -583,12 +583,12 @@ else if ( operation < 0.5 )
} }
else if ( operation < 0.75 ) else if ( operation < 0.75 )
{ // set node property { // set node property
random.among( nodes, node -> node.setProperty( randomKey(), random.propertyValue() ) ); random.among( nodes, node -> node.setProperty( randomKey(), random.nextValueAsObject() ) );
} }
else else
{ // set relationship property { // set relationship property
onRandomRelationship( nodes, onRandomRelationship( nodes,
relationship -> relationship.setProperty( randomKey(), random.propertyValue() ) ); relationship -> relationship.setProperty( randomKey(), random.nextValueAsObject() ) );
} }
} }
else else
Expand Down Expand Up @@ -712,7 +712,7 @@ else if ( operation < 0.3 )
{ {
if ( random.nextBoolean() ) if ( random.nextBoolean() )
{ {
node.setProperty( key, random.propertyValue() ); node.setProperty( key, random.nextValueAsObject() );
} }
} }
nodes.add( node ); nodes.add( node );
Expand All @@ -727,7 +727,7 @@ else if ( operation < 0.6 )
} }
else if ( operation < 0.85 ) else if ( operation < 0.85 )
{ // Set property { // Set property
random.among( nodes, node -> node.setProperty( random.among( keys ), random.propertyValue() ) ); random.among( nodes, node -> node.setProperty( random.among( keys ), random.nextValueAsObject() ) );
} }
else else
{ // Remove property { // Remove property
Expand Down
Expand Up @@ -579,7 +579,7 @@ String randomPropertyKey()


Object randomPropertyValue() Object randomPropertyValue()
{ {
return random.propertyValue(); return random.nextValueAsObject();
} }


int nodeCount() int nodeCount()
Expand Down
Expand Up @@ -28,7 +28,6 @@
import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.api.schema.index.SchemaIndexDescriptor; import org.neo4j.kernel.api.schema.index.SchemaIndexDescriptor;
import org.neo4j.test.Randoms;
import org.neo4j.values.storable.DurationValue; import org.neo4j.values.storable.DurationValue;
import org.neo4j.values.storable.RandomValues; import org.neo4j.values.storable.RandomValues;
import org.neo4j.values.storable.Value; import org.neo4j.values.storable.Value;
Expand All @@ -48,15 +47,6 @@ public class DurationLayoutTestUtil extends LayoutTestUtil<DurationSchemaKey, Na
DurationValue.duration( 0, 0, 0, Long.MAX_VALUE), DurationValue.duration( 0, 0, 0, Long.MAX_VALUE),
}; };


public static DurationValue randomDuration( Randoms random )
{
// not using random.randomDuration, since it cannot mix durations greater and smaller than 1 day
return DurationValue.duration( random.nextLong( -999_999_999L * 12, 999_999_999L * 12),
random.nextLong( -999_999_999L * 12 * 28, 999_999_999L * 12 * 28),
random.nextLong(),
random.nextLong() );
}

DurationLayoutTestUtil( SchemaIndexDescriptor schemaIndexDescriptor ) DurationLayoutTestUtil( SchemaIndexDescriptor schemaIndexDescriptor )
{ {
super( schemaIndexDescriptor ); super( schemaIndexDescriptor );
Expand Down
Expand Up @@ -53,7 +53,7 @@ public void shouldFilterResults()
for ( int i = 0; i < 100; i++ ) for ( int i = 0; i < 100; i++ )
{ {
// duplicates are fine // duplicates are fine
keys.add( random.string() ); keys.add( random.nextString() );
} }


RawCursor<Hit<StringSchemaKey,NativeSchemaValue>,IOException> cursor = new ResultCursor( keys.iterator() ); RawCursor<Hit<StringSchemaKey,NativeSchemaValue>,IOException> cursor = new ResultCursor( keys.iterator() );
Expand Down

0 comments on commit 28feea7

Please sign in to comment.