private void AssertCorrectIndex(int labelId, int[] propertyKeyIds, bool expectedUnique, IndexReference index) { assertEquals("provider key", "lucene+native", index.ProviderKey()); assertEquals("provider version", "1.0", index.ProviderVersion()); assertEquals(expectedUnique, index.Unique); assertEquals("label id", labelId, index.Schema().EntityTokenIds[0]); for (int i = 0; i < propertyKeyIds.Length; i++) { assertEquals("property key id", propertyKeyIds[i], index.Properties()[i]); } }
private void AssertCorrectProvider(GraphDatabaseAPI db, Label label, string property) { KernelTransaction kernelTransaction = Db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(false); TokenRead tokenRead = kernelTransaction.TokenRead(); int labelId = tokenRead.NodeLabel(label.Name()); int propId = tokenRead.PropertyKey(property); SchemaRead schemaRead = kernelTransaction.SchemaRead(); IndexReference index = schemaRead.Index(labelId, propId); assertEquals("correct provider key", "lucene+native", index.ProviderKey()); assertEquals("correct provider version", "1.0", index.ProviderVersion()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertIndexProvider(org.neo4j.graphdb.GraphDatabaseService db, String expectedProviderIdentifier) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException private void AssertIndexProvider(GraphDatabaseService db, string expectedProviderIdentifier) { GraphDatabaseAPI graphDatabaseAPI = ( GraphDatabaseAPI )db; using (Transaction tx = graphDatabaseAPI.BeginTx()) { KernelTransaction ktx = graphDatabaseAPI.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); TokenRead tokenRead = ktx.TokenRead(); int labelId = tokenRead.NodeLabel(LABEL.name()); int propertyId = tokenRead.PropertyKey(KEY); IndexReference index = ktx.SchemaRead().index(labelId, propertyId); assertEquals("expected IndexProvider.Descriptor", expectedProviderIdentifier, (new IndexProviderDescriptor(index.ProviderKey(), index.ProviderVersion())).name()); tx.Success(); } }
private static string UnexpectedIndexProviderMessage(IndexReference index) { return("Unexpected provider: key=" + index.ProviderKey() + ", version=" + index.ProviderVersion()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void batchInserterShouldUseConfiguredIndexProvider() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void BatchInserterShouldUseConfiguredIndexProvider() { Config config = Config.defaults(stringMap(default_schema_provider.name(), _schemaIndex.providerName())); BatchInserter inserter = NewBatchInserter(config); inserter.CreateDeferredSchemaIndex(TestLabels.LABEL_ONE).on("key").create(); inserter.Shutdown(); GraphDatabaseService db = GraphDatabaseService(config); AwaitIndexesOnline(db); try { using (Transaction tx = Db.beginTx()) { DependencyResolver dependencyResolver = (( GraphDatabaseAPI )db).DependencyResolver; ThreadToStatementContextBridge threadToStatementContextBridge = dependencyResolver.ResolveDependency(typeof(ThreadToStatementContextBridge)); KernelTransaction kernelTransaction = threadToStatementContextBridge.GetKernelTransactionBoundToThisThread(true); TokenRead tokenRead = kernelTransaction.TokenRead(); SchemaRead schemaRead = kernelTransaction.SchemaRead(); int labelId = tokenRead.NodeLabel(TestLabels.LABEL_ONE.name()); int propertyId = tokenRead.PropertyKey("key"); IndexReference index = schemaRead.Index(labelId, propertyId); assertTrue(UnexpectedIndexProviderMessage(index), _schemaIndex.providerName().contains(index.ProviderKey())); assertTrue(UnexpectedIndexProviderMessage(index), _schemaIndex.providerName().contains(index.ProviderVersion())); tx.Success(); } } finally { Db.shutdown(); } }