use of org.junit.experimental.theories.Theory in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method addingTheSameValuesMustProduceEqualCollections.
@Theory
public void addingTheSameValuesMustProduceEqualCollections(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
Value value = values.randomValue();
value.add(a);
value.add(b);
assertEquals(a, b);
}
}
use of org.junit.experimental.theories.Theory in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method capacityDifferencesMustNotInfluenceEquality.
@Theory
public void capacityDifferencesMustNotInfluenceEquality(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
List<Value> tmps = new ArrayList<>();
for (int i = 0; i < 5000; i++) {
Value value = values.randomValue();
value.add(b);
tmps.add(value);
}
Value specificValue = values.randomValue();
specificValue.add(a);
specificValue.add(b);
for (int i = 0; i < 5000; i++) {
Value value = values.randomValue();
value.add(b);
tmps.add(value);
}
Collections.shuffle(tmps);
for (Value value : tmps) {
value.remove(b);
}
assertEquals(a, b);
}
}
use of org.junit.experimental.theories.Theory in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method emptyCollectionsAreEqual.
@Theory
public void emptyCollectionsAreEqual(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
assertEquals(a, b);
}
}
use of org.junit.experimental.theories.Theory in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method differentButEquivalentMutationsShouldProduceEqualCollections.
@Theory
public void differentButEquivalentMutationsShouldProduceEqualCollections(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
// Note that this test, cute as it is, also verifies that the hashCode implementation is order-invariant :)
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
Value x = values.randomValue();
Value y = values.randomValue();
Value z = values.randomValue();
x.add(a);
z.add(a);
z.add(b);
y.add(b);
x.add(b);
y.remove(b);
assertEquals(a, b);
}
}
use of org.junit.experimental.theories.Theory in project neo4j by neo4j.
the class LegacyIndexIT method shouldNotRejectIndexValueThatIsJustSmallerThanConfiguredSize.
@Theory
public void shouldNotRejectIndexValueThatIsJustSmallerThanConfiguredSize(String uniqueness) throws Exception {
//Given
server.start();
// When
String nodeURI = HTTP.POST(server.baseUri().toString() + "db/data/node").header("Location");
Random r = new Random();
String value = "";
for (int i = 0; i < 4_000; i++) {
value += (char) (r.nextInt(26) + 'a');
}
HTTP.Response response = HTTP.POST(server.baseUri().toString() + "db/data/index/node/favorites?uniqueness=" + uniqueness, quotedJson("{ 'value': '" + value + " ', 'uri':'" + nodeURI + "', 'key': 'some-key' }"));
// Then
assertThat(response.status(), is(201));
}
Aggregations