use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class DataStatementArgumentVerificationTest method shouldReturnEmptyIdIteratorFromNodesGetForLabelForNoSuchLabelConstant.
@Test
public void shouldReturnEmptyIdIteratorFromNodesGetForLabelForNoSuchLabelConstant() throws Exception {
// given
ReadOperations statement = stubStatement();
// when
PrimitiveLongIterator nodes = statement.nodesGetForLabel(StatementConstants.NO_SUCH_LABEL);
// then
assertFalse("should not contain any ids", nodes.hasNext());
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class KernelTransactionSecurityContextTest method shouldAllowReadsInWriteMode.
@Test
public void shouldAllowReadsInWriteMode() throws Throwable {
// Given
KernelTransactionImplementation tx = newTransaction(AnonymousContext.write());
// When
ReadOperations reads = tx.acquireStatement().readOperations();
// Then
assertNotNull(reads);
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class CompositeCountsTest method countsForRelationship.
/**
* @param start the label of the start node of relationships to get the number of, or {@code null} for "any".
* @param type the type of the relationships to get the number of, or {@code null} for "any".
* @param end the label of the end node of relationships to get the number of, or {@code null} for "any".
*/
private long countsForRelationship(Label start, RelationshipType type, Label end) {
ReadOperations read = statementSupplier.get().readOperations();
int startId, typeId, endId;
// start
if (start == null) {
startId = ReadOperations.ANY_LABEL;
} else {
if (ReadOperations.NO_SUCH_LABEL == (startId = read.labelGetForName(start.name()))) {
return 0;
}
}
// type
if (type == null) {
typeId = ReadOperations.ANY_RELATIONSHIP_TYPE;
} else {
if (ReadOperations.NO_SUCH_LABEL == (typeId = read.relationshipTypeGetForName(type.name()))) {
return 0;
}
}
// end
if (end == null) {
endId = ReadOperations.ANY_LABEL;
} else {
if (ReadOperations.NO_SUCH_LABEL == (endId = read.labelGetForName(end.name()))) {
return 0;
}
}
return read.countsForRelationship(startId, typeId, endId);
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class LabelCountsTest method countsForNode.
/** @param label the label to get the number of nodes of, or {@code null} to get the total number of nodes. */
private long countsForNode(Label label) {
ReadOperations read = statementSupplier.get().readOperations();
int labelId;
if (label == null) {
labelId = ReadOperations.ANY_LABEL;
} else {
if (ReadOperations.NO_SUCH_LABEL == (labelId = read.labelGetForName(label.name()))) {
return 0;
}
}
return read.countsForNode(labelId);
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class DataStatementArgumentVerificationTest method shouldReturnNoPropertyFromRelationshipGetPropertyWithoutDelegatingForNoSuchPropertyKeyIdConstant.
@Test
public void shouldReturnNoPropertyFromRelationshipGetPropertyWithoutDelegatingForNoSuchPropertyKeyIdConstant() throws Exception {
// given
ReadOperations statement = stubStatement();
// when
Object value = statement.relationshipGetProperty(17, StatementConstants.NO_SUCH_PROPERTY_KEY);
// then
assertNull("should return NoProperty", value);
}
Aggregations