Search in sources :

Example 16 with PropertyItem

use of org.neo4j.storageengine.api.PropertyItem in project neo4j by neo4j.

the class StorageLayerPropertyTest method should_get_all_node_properties.

@Test
public void should_get_all_node_properties() throws Exception {
    // GIVEN
    String longString = "AlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalong";
    Object[] properties = { longString, createNew(String.class), createNew(long.class), createNew(int.class), createNew(byte.class), createNew(short.class), createNew(boolean.class), createNew(char.class), createNew(float.class), createNew(double.class), array(0, String.class), array(0, long.class), array(0, int.class), array(0, byte.class), array(0, short.class), array(0, boolean.class), array(0, char.class), array(0, float.class), array(0, double.class), array(1, String.class), array(1, long.class), array(1, int.class), array(1, byte.class), array(1, short.class), array(1, boolean.class), array(1, char.class), array(1, float.class), array(1, double.class), array(256, String.class), array(256, long.class), array(256, int.class), array(256, byte.class), array(256, short.class), array(256, boolean.class), array(256, char.class), array(256, float.class), array(256, double.class) };
    int propKey = disk.propertyKeyGetOrCreateForName("prop");
    StorageStatement statement = state.getStoreStatement();
    for (Object value : properties) {
        // given
        long nodeId = createLabeledNode(db, singletonMap("prop", value), label1).getId();
        // when
        try (Cursor<NodeItem> node = statement.acquireSingleNodeCursor(nodeId)) {
            node.next();
            Lock lock = node.get().lock();
            try (Cursor<PropertyItem> props = statement.acquireSinglePropertyCursor(node.get().nextPropertyId(), propKey, lock)) {
                if (props.next()) {
                    Object propVal = props.get().value();
                    //then
                    assertTrue(propVal + ".valueEquals(" + value + ")", Property.property(propKey, propVal).valueEquals(value));
                } else {
                    fail();
                }
            }
        }
    }
}
Also used : NodeItem(org.neo4j.storageengine.api.NodeItem) StorageStatement(org.neo4j.storageengine.api.StorageStatement) PropertyItem(org.neo4j.storageengine.api.PropertyItem) Lock(org.neo4j.kernel.impl.locking.Lock) Test(org.junit.Test)

Example 17 with PropertyItem

use of org.neo4j.storageengine.api.PropertyItem in project neo4j by neo4j.

the class StateOperationsAutoIndexingTest method shouldSignalRelationshipPropertyChangedToAutoIndex.

@Test
public void shouldSignalRelationshipPropertyChangedToAutoIndex() throws Exception {
    // Given
    int propertyKeyId = 1;
    DefinedProperty property = property(propertyKeyId, "Hello!");
    PropertyItem existingProperty = mock(PropertyItem.class);
    when(existingProperty.propertyKeyId()).thenReturn(property.propertyKeyId());
    when(existingProperty.value()).thenReturn("Goodbye!");
    RelationshipItem relationship = mock(RelationshipItem.class);
    when(storeStmt.acquireSingleRelationshipCursor(1337)).thenReturn(cursor(relationship));
    when(storeLayer.relationshipGetProperty(storeStmt, relationship, propertyKeyId)).thenReturn(cursor(existingProperty));
    // When
    context.relationshipSetProperty(stmt, 1337, property);
    // Then
    verify(relOps).propertyChanged(eq(writeOps), eq(1337L), any(Property.class), eq(property));
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyItem(org.neo4j.storageengine.api.PropertyItem) Property(org.neo4j.kernel.api.properties.Property) DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) RelationshipItem(org.neo4j.storageengine.api.RelationshipItem) Test(org.junit.Test)

Example 18 with PropertyItem

use of org.neo4j.storageengine.api.PropertyItem in project neo4j by neo4j.

the class StateOperationsAutoIndexingTest method shouldSignalNodePropertyRemovedToAutoIndex.

@Test
public void shouldSignalNodePropertyRemovedToAutoIndex() throws Exception {
    // Given
    PropertyItem existingProperty = mock(PropertyItem.class);
    when(existingProperty.propertyKeyId()).thenReturn(1);
    when(existingProperty.value()).thenReturn("Goodbye!");
    int propertyKeyId = existingProperty.propertyKeyId();
    NodeItem node = mock(NodeItem.class);
    when(storeLayer.nodeGetProperty(eq(storeStmt), any(NodeItem.class), eq(propertyKeyId))).thenReturn(cursor(existingProperty));
    when(node.labels()).thenReturn(PrimitiveIntCollections.emptySet());
    when(storeStmt.acquireSingleNodeCursor(1337)).thenReturn(cursor(node));
    // When
    context.nodeRemoveProperty(stmt, 1337, propertyKeyId);
    // Then
    verify(nodeOps).propertyRemoved(writeOps, 1337L, propertyKeyId);
}
Also used : NodeItem(org.neo4j.storageengine.api.NodeItem) PropertyItem(org.neo4j.storageengine.api.PropertyItem) Test(org.junit.Test)

Aggregations

PropertyItem (org.neo4j.storageengine.api.PropertyItem)18 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)8 NodeItem (org.neo4j.storageengine.api.NodeItem)8 RelationshipItem (org.neo4j.storageengine.api.RelationshipItem)6 Test (org.junit.Test)5 DataWriteOperations (org.neo4j.kernel.api.DataWriteOperations)4 Property (org.neo4j.kernel.api.properties.Property)4 Lock (org.neo4j.kernel.impl.locking.Lock)4 HashMap (java.util.HashMap)3 PropertyKeyIdNotFoundKernelException (org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)3 StorageProperty (org.neo4j.storageengine.api.StorageProperty)3 NotFoundException (org.neo4j.graphdb.NotFoundException)2 Statement (org.neo4j.kernel.api.Statement)2 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)2 PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)2 PrimitiveIntSet (org.neo4j.collection.primitive.PrimitiveIntSet)1 Relationship (org.neo4j.graphdb.Relationship)1 LabelNotFoundKernelException (org.neo4j.kernel.api.exceptions.LabelNotFoundKernelException)1 ExactPredicate (org.neo4j.kernel.api.schema_new.IndexQuery.ExactPredicate)1 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)1