Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Oct 18, 2017
1 parent 2acbf53 commit a854a21
Showing 1 changed file with 29 additions and 75 deletions.
Expand Up @@ -54,6 +54,7 @@
import org.neo4j.test.rule.RandomRule; import org.neo4j.test.rule.RandomRule;


import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;


/** /**
Expand Down Expand Up @@ -295,27 +296,7 @@ public void multipleIteratorsNestedInterleavedExists() throws Exception
List<Long> actual2 = new ArrayList<>(); List<Long> actual2 = new ArrayList<>();


// Interleave // Interleave
while ( iter1.hasNext() && iter2.hasNext() ) exhaustInterleaved( iter1, actual1, iter2, actual2 );
{
if ( rnd.nextBoolean() )
{
actual1.add( iter1.next() );
}
else
{
actual2.add( iter2.next() );
}
}

// Empty the rest
while ( iter1.hasNext() )
{
actual1.add( iter1.next() );
}
while ( iter2.hasNext() )
{
actual2.add( iter2.next() );
}


// then // then
indexCoordinator.assertExistsResult( actual1 ); indexCoordinator.assertExistsResult( actual1 );
Expand All @@ -338,27 +319,7 @@ public void multipleIteratorsNestedInterleavedExact() throws Exception
List<Long> actual2 = new ArrayList<>(); List<Long> actual2 = new ArrayList<>();


// Interleave // Interleave
while ( iter1.hasNext() && iter2.hasNext() ) exhaustInterleaved( iter1, actual1, iter2, actual2 );
{
if ( rnd.nextBoolean() )
{
actual1.add( iter1.next() );
}
else
{
actual2.add( iter2.next() );
}
}

// Empty the rest
while ( iter1.hasNext() )
{
actual1.add( iter1.next() );
}
while ( iter2.hasNext() )
{
actual2.add( iter2.next() );
}


// then // then
indexCoordinator.assertExactResult( actual1 ); indexCoordinator.assertExactResult( actual1 );
Expand All @@ -382,27 +343,7 @@ public void multipleIteratorsNestedInterleavedRange() throws Exception
List<Long> actual2 = new ArrayList<>(); List<Long> actual2 = new ArrayList<>();


// Interleave // Interleave
while ( iter1.hasNext() && iter2.hasNext() ) exhaustInterleaved( iter1, actual1, iter2, actual2 );
{
if ( rnd.nextBoolean() )
{
actual1.add( iter1.next() );
}
else
{
actual2.add( iter2.next() );
}
}

// Empty the rest
while ( iter1.hasNext() )
{
actual1.add( iter1.next() );
}
while ( iter2.hasNext() )
{
actual2.add( iter2.next() );
}


// then // then
indexCoordinator.assertRangeResult( actual1 ); indexCoordinator.assertRangeResult( actual1 );
Expand All @@ -411,15 +352,30 @@ public void multipleIteratorsNestedInterleavedRange() throws Exception
} }
} }


// multipleIteratorsNotNestedExists private void exhaustInterleaved( PrimitiveLongIterator source1, List<Long> target1, PrimitiveLongIterator source2, List<Long> target2 )
// multipleIteratorsNotNestedExact {
// multipleIteratorsNotNestedRange while ( source1.hasNext() && source2.hasNext() )
// multipleIteratorsNestedInnerNewExists {
// multipleIteratorsNestedInnerNewExact if ( rnd.nextBoolean() )
// multipleIteratorsNestedInnerNewRange {
// multipleIteratorsNestedInterleavedExists target1.add( source1.next() );
// multipleIteratorsNestedInterleavedExact }
// multipleIteratorsNestedInterleavedRange else
{
target2.add( source2.next() );
}
}

// Empty the rest
while ( source1.hasNext() )
{
target1.add( source1.next() );
}
while ( source2.hasNext() )
{
target2.add( source2.next() );
}
}


private static class StringCompositeIndexCoordinator extends IndexCoordinator private static class StringCompositeIndexCoordinator extends IndexCoordinator
{ {
Expand Down Expand Up @@ -807,9 +763,7 @@ void assertExistsResult( List<Long> actual )


void assertSameContent( List<Long> actual, List<Long> expected ) void assertSameContent( List<Long> actual, List<Long> expected )
{ {
actual.sort( Long::compareTo ); assertThat( actual, is( containsInAnyOrder( expected.toArray() ) ) );
expected.sort( Long::compareTo );
assertThat( actual, is( expected ) );
} }


abstract void assertExactResult( List<Long> result ); abstract void assertExactResult( List<Long> result );
Expand Down

0 comments on commit a854a21

Please sign in to comment.