use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class TruncatedQuerySnapshotTest method shouldTruncateRelationship.
@Test
void shouldTruncateRelationship() {
// when
TruncatedQuerySnapshot x = new TruncatedQuerySnapshot(null, "", null, map("r", RELATIONSHIP), -1L, -1L, -1L, 100);
// then
AnyValue truncatedRelationship = x.queryParameters.get("r");
assertTrue(truncatedRelationship instanceof RelationshipReference);
assertEquals(RELATIONSHIP.id(), ((RelationshipReference) truncatedRelationship).id());
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class ProceduresTest method shouldMakeContextAvailable.
@Test
void shouldMakeContextAvailable() throws Throwable {
// Given
procs.register(new CallableProcedure.BasicProcedure(signature) {
@Override
public RawIterator<AnyValue[], ProcedureException> apply(Context ctx, AnyValue[] input, ResourceTracker resourceTracker) {
return RawIterator.<AnyValue[], ProcedureException>of(new AnyValue[] { stringValue(ctx.thread().getName()) });
}
});
Context ctx = prepareContext();
ProcedureHandle procedureHandle = procs.procedure(signature.name());
// When
RawIterator<AnyValue[], ProcedureException> result = procs.callProcedure(ctx, procedureHandle.id(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
assertThat(asList(result)).contains(new AnyValue[] { stringValue(Thread.currentThread().getName()) });
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class SplittableRandomValuesTest method nextValue.
@Test
void nextValue() {
assertTimeoutPreemptively(Duration.ofMillis(10_000), () -> {
Set<Class<? extends AnyValue>> all = new HashSet<>(TYPES);
all.add(ArrayValue.class);
Set<Class<? extends AnyValue>> seen = new HashSet<>(all);
while (!seen.isEmpty()) {
Value value = randomValues.nextValue();
assertKnownType(value.getClass(), all);
markSeen(value.getClass(), seen);
}
});
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class AbstractCypherAdapterStreamTest method assertMapEqualsWithDelta.
private static void assertMapEqualsWithDelta(MapValue a, MapValue b, double delta) {
assertThat(a.size()).as("Map should have same size").isEqualTo(b.size());
a.foreach((key, value) -> {
// assertThat( "Missing key", b.get( key ) != Values.NO_VALUE );
AnyValue aValue = value;
AnyValue bValue = b.get(key);
if (aValue instanceof MapValue) {
assertThat(bValue instanceof MapValue).as("Value mismatch").isTrue();
assertMapEqualsWithDelta((MapValue) aValue, (MapValue) bValue, delta);
} else if (aValue instanceof DoubleValue) {
assertThat(((DoubleValue) aValue).doubleValue()).as("Value mismatch").isCloseTo(((DoubleValue) bValue).doubleValue(), offset(delta));
} else {
assertThat(aValue).as("Value mismatch").isEqualTo(bValue);
}
});
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class RecordMessageEncoderTest method shouldEncodeRecordMessage.
@Test
void shouldEncodeRecordMessage() throws Throwable {
// Given
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
RecordMessageEncoder encoder = new RecordMessageEncoder();
// When
encoder.encode(packer, new RecordMessage(new AnyValue[0]));
// Then
verify(packer).packStructHeader(anyInt(), eq(RecordMessage.SIGNATURE));
verify(packer).packListHeader(0);
}
Aggregations