use of org.neo4j.kernel.impl.api.KernelTransactionImplementation in project neo4j by neo4j.
the class TxStateTransactionDataViewTest method shouldAccessExampleMetaData.
@Test
public void shouldAccessExampleMetaData() {
NodeProxy.NodeActions nodeActions = mock(NodeProxy.NodeActions.class);
final RelationshipProxy.RelationshipActions relActions = mock(RelationshipProxy.RelationshipActions.class);
final KernelTransactionImplementation transaction = mock(KernelTransactionImplementation.class);
when(transaction.getMetaData()).thenReturn(genericMap("username", "Igor"));
TxStateTransactionDataSnapshot transactionDataSnapshot = new TxStateTransactionDataSnapshot(state, nodeActions, relActions, ops, storeStatement, transaction);
assertEquals(1, transactionDataSnapshot.metaData().size());
assertThat("Expected metadata map to contain defined username", transactionDataSnapshot.metaData(), equalTo(genericMap("username", "Igor")));
}
use of org.neo4j.kernel.impl.api.KernelTransactionImplementation in project neo4j by neo4j.
the class TimeoutGuardTest method getKernelStatement.
private KernelStatement getKernelStatement(long transactionTimeout) {
KernelTransactionImplementation transaction = newNotInitializedTransaction();
StatementLocks statementLocks = mock(StatementLocks.class);
transaction.initialize(1L, 2L, statementLocks, KernelTransaction.Type.implicit, AUTH_DISABLED, transactionTimeout);
return transaction.acquireStatement();
}
use of org.neo4j.kernel.impl.api.KernelTransactionImplementation in project neo4j by neo4j.
the class LuceneFulltextIndexTest method completeConfigurationMustInjectMissingConfigurations.
@Test
void completeConfigurationMustInjectMissingConfigurations() throws Exception {
int label;
int propertyKey;
try (Transaction tx = db.beginTx()) {
createNodeIndexableByPropertyValue(tx, LABEL, "bla");
tx.commit();
}
try (KernelTransactionImplementation tx = getKernelTransaction()) {
label = tx.tokenRead().nodeLabel(LABEL.name());
propertyKey = tx.tokenRead().propertyKey(PROP);
tx.success();
}
IndexConfig indexConfig = IndexConfig.with(EVENTUALLY_CONSISTENT, Values.booleanValue(true));
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { label }, new int[] { propertyKey });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor descriptor = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").withIndexConfig(indexConfig).materialise(1));
assertThat((Value) descriptor.getIndexConfig().get(ANALYZER)).isEqualTo(Values.stringValue("standard-no-stop-words"));
assertThat((Value) descriptor.getIndexConfig().get(EVENTUALLY_CONSISTENT)).isEqualTo(Values.booleanValue(true));
assertThat(asList(descriptor.getCapability().behaviours())).containsExactlyInAnyOrder(IndexBehaviour.EVENTUALLY_CONSISTENT, IndexBehaviour.SKIP_AND_LIMIT);
}
use of org.neo4j.kernel.impl.api.KernelTransactionImplementation in project neo4j by neo4j.
the class FulltextIndexProviderTest method createFulltextIndex.
@Test
void createFulltextIndex() throws Exception {
IndexDescriptor fulltextIndex = createIndex(new int[] { labelIdHej, labelIdHa, labelIdHe }, new int[] { propIdHej, propIdHa, propIdHe });
try (KernelTransactionImplementation transaction = getKernelTransaction()) {
IndexDescriptor descriptor = transaction.schemaRead().indexGetForName(NAME);
assertEquals(descriptor.schema(), fulltextIndex.schema());
transaction.success();
}
}
use of org.neo4j.kernel.impl.api.KernelTransactionImplementation in project neo4j by neo4j.
the class FulltextIndexProviderTest method shouldHaveAReasonableDirectoryStructure.
@Test
void shouldHaveAReasonableDirectoryStructure() throws Exception {
createIndex(new int[] { labelIdHej, labelIdHa, labelIdHe }, new int[] { propIdHej, propIdHa, propIdHe });
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(1, TimeUnit.HOURS);
tx.commit();
}
try (KernelTransactionImplementation transaction = getKernelTransaction()) {
IndexDescriptor descriptor = transaction.schemaRead().indexGetForName(NAME);
Path indexDir = Path.of(db.databaseLayout().databaseDirectory().toAbsolutePath().toString(), "schema", "index", descriptor.getIndexProvider().name(), "" + descriptor.getId());
List<Path> listFiles = List.of(requireNonNull(FileUtils.listPaths(indexDir)));
assertTrue(listFiles.contains(indexDir.resolve("failure-message")));
assertTrue(listFiles.contains(indexDir.resolve("1")));
assertTrue(listFiles.contains(indexDir.resolve(indexDir.getFileName() + ".tx")));
}
}
Aggregations