Search in sources :

Example 1 with ObjectLongPair

use of org.eclipse.collections.api.tuple.primitive.ObjectLongPair in project neo4j by neo4j.

the class AppendOnlyValuesContainerTest method randomizedTest.

@Test
void randomizedTest() {
    final int count = 10000 + rnd.nextInt(1000);
    final List<ObjectLongPair<Value>> valueRefPairs = new ArrayList<>();
    final MutableList<ObjectLongPair<Value>> toRemove = new FastList<>();
    for (int i = 0; i < count; i++) {
        final Value value = rnd.randomValues().nextValue();
        final long ref = container.add(value);
        final ObjectLongPair<Value> pair = pair(value, ref);
        if (rnd.nextBoolean()) {
            toRemove.add(pair);
        } else {
            valueRefPairs.add(pair);
        }
    }
    toRemove.shuffleThis(rnd.random());
    for (final ObjectLongPair<Value> valueRefPair : toRemove) {
        final Value removed = container.remove(valueRefPair.getTwo());
        assertEquals(valueRefPair.getOne(), removed);
        assertThrows(IllegalArgumentException.class, () -> container.remove(valueRefPair.getTwo()));
        assertThrows(IllegalArgumentException.class, () -> container.get(valueRefPair.getTwo()));
    }
    for (final ObjectLongPair<Value> valueRefPair : valueRefPairs) {
        final Value actualValue = container.get(valueRefPair.getTwo());
        assertEquals(valueRefPair.getOne(), actualValue);
    }
}
Also used : ArrayList(java.util.ArrayList) FastList(org.eclipse.collections.impl.list.mutable.FastList) Value(org.neo4j.values.storable.Value) Values.longValue(org.neo4j.values.storable.Values.longValue) LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) TimeValue(org.neo4j.values.storable.TimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) Values.intValue(org.neo4j.values.storable.Values.intValue) Values.pointValue(org.neo4j.values.storable.Values.pointValue) LocalTimeValue(org.neo4j.values.storable.LocalTimeValue) Values.stringValue(org.neo4j.values.storable.Values.stringValue) DateValue(org.neo4j.values.storable.DateValue) ObjectLongPair(org.eclipse.collections.api.tuple.primitive.ObjectLongPair) Point(org.neo4j.graphdb.spatial.Point) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Aggregations

ArrayList (java.util.ArrayList)1 ObjectLongPair (org.eclipse.collections.api.tuple.primitive.ObjectLongPair)1 FastList (org.eclipse.collections.impl.list.mutable.FastList)1 DynamicTest (org.junit.jupiter.api.DynamicTest)1 Test (org.junit.jupiter.api.Test)1 Point (org.neo4j.graphdb.spatial.Point)1 DateTimeValue (org.neo4j.values.storable.DateTimeValue)1 DateValue (org.neo4j.values.storable.DateValue)1 LocalDateTimeValue (org.neo4j.values.storable.LocalDateTimeValue)1 LocalTimeValue (org.neo4j.values.storable.LocalTimeValue)1 TimeValue (org.neo4j.values.storable.TimeValue)1 Value (org.neo4j.values.storable.Value)1 Values.intValue (org.neo4j.values.storable.Values.intValue)1 Values.longValue (org.neo4j.values.storable.Values.longValue)1 Values.pointValue (org.neo4j.values.storable.Values.pointValue)1 Values.stringValue (org.neo4j.values.storable.Values.stringValue)1