Search in sources :

Example 31 with EntityUpdates

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

the class EntityValueUpdatesTest method shouldNotGenerateUpdatesForEmptyEntityUpdates.

@ParameterizedTest
@EnumSource(Entity.class)
void shouldNotGenerateUpdatesForEmptyEntityUpdates(Entity entity) {
    // When
    EntityUpdates updates = EntityUpdates.forEntity(ENTITY_ID, false).build();
    // Then
    assertThat(updates.valueUpdatesForIndexKeys(entity.indexes(), assertNoLoading(), entity.type(), NULL, INSTANCE)).isEmpty();
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 32 with EntityUpdates

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

the class EntityValueUpdatesTest method shouldGenerateUpdatesForSinglePropertyAdditionWithToken.

@ParameterizedTest
@EnumSource(Entity.class)
void shouldGenerateUpdatesForSinglePropertyAdditionWithToken(Entity entity) {
    // When
    EntityUpdates updates = EntityUpdates.forEntity(ENTITY_ID, false).withTokens(TOKEN).added(PROPERTY_1.propertyKeyId(), PROPERTY_1.value()).build();
    // Then
    assertThat(updates.valueUpdatesForIndexKeys(entity.indexes(), propertyLoader(), entity.type(), NULL, INSTANCE)).contains(IndexEntryUpdate.add(ENTITY_ID, entity.index1(), PROPERTY_1.value()));
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with EntityUpdates

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

the class EntityValueUpdatesTest method shouldGenerateUpdateWhenRemovingOnePropertyForNonSchemaIndex.

@ParameterizedTest
@EnumSource(Entity.class)
void shouldGenerateUpdateWhenRemovingOnePropertyForNonSchemaIndex(Entity entity) {
    // When
    EntityUpdates updates = EntityUpdates.forEntity(ENTITY_ID, false).withTokens(TOKEN).withTokensAfter(TOKEN).removed(PROPERTY_2.propertyKeyId(), PROPERTY_2.value()).build();
    // Then
    assertThat(updates.valueUpdatesForIndexKeys(singleton(entity.nonSchemaIndex()), propertyLoader(PROPERTY_1, PROPERTY_2, PROPERTY_3), entity.type(), NULL, INSTANCE)).contains(IndexEntryUpdate.change(ENTITY_ID, entity.nonSchemaIndex(), VALUES_123, new Value[] { PROPERTY_1.value(), null, PROPERTY_3.value() }));
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) Value(org.neo4j.values.storable.Value) PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with EntityUpdates

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

the class EntityValueUpdatesTest method shouldGenerateUpdatesForLabelAdditionWithExistingProperties.

@Test
void shouldGenerateUpdatesForLabelAdditionWithExistingProperties() {
    // When
    EntityUpdates updates = EntityUpdates.forEntity(ENTITY_ID, false).withTokens(EMPTY).withTokensAfter(TOKEN).existing(PROPERTY_KEY_ID_1, Values.of("Neo")).existing(PROPERTY_KEY_ID_2, Values.of(100L)).existing(PROPERTY_KEY_ID_3, Values.pointValue(CoordinateReferenceSystem.WGS84, 12.3, 45.6)).build();
    // Then
    assertThat(updates.valueUpdatesForIndexKeys(NODE_INDEXES, propertyLoader(PROPERTY_1, PROPERTY_2, PROPERTY_3), EntityType.NODE, NULL, INSTANCE)).contains(IndexEntryUpdate.add(ENTITY_ID, NODE_INDEX_1, PROPERTY_1.value()), IndexEntryUpdate.add(ENTITY_ID, NODE_INDEX_2, PROPERTY_2.value()), IndexEntryUpdate.add(ENTITY_ID, NODE_INDEX_3, PROPERTY_3.value()), IndexEntryUpdate.add(ENTITY_ID, NODE_INDEX_123, VALUES_123));
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with EntityUpdates

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

the class EntityValueUpdatesTest method shouldNotGenerateUpdatesForPropertyAdditionWithNoLabels.

@Test
void shouldNotGenerateUpdatesForPropertyAdditionWithNoLabels() {
    // When
    EntityUpdates updates = EntityUpdates.forEntity(ENTITY_ID, false).added(PROPERTY_1.propertyKeyId(), PROPERTY_1.value()).build();
    // Then
    assertThat(updates.valueUpdatesForIndexKeys(NODE_INDEXES, assertNoLoading(), EntityType.NODE, NULL, INSTANCE)).isEmpty();
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EntityUpdates (org.neo4j.storageengine.api.EntityUpdates)50 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)41 Test (org.junit.jupiter.api.Test)22 EnumSource (org.junit.jupiter.params.provider.EnumSource)21 Value (org.neo4j.values.storable.Value)6 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)4 ArrayList (java.util.ArrayList)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 Transaction (org.neo4j.graphdb.Transaction)3 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)3 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)3 PropertyKeyValue (org.neo4j.storageengine.api.PropertyKeyValue)3 StorageNodeCursor (org.neo4j.storageengine.api.StorageNodeCursor)2 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)1 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)1 StoragePropertyCursor (org.neo4j.storageengine.api.StoragePropertyCursor)1 StorageReader (org.neo4j.storageengine.api.StorageReader)1 ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)1