//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeClass public static void given() public static void Given() { // database with an index on `(:Node).prop` using (Transaction tx = Db.beginTx()) { Db.schema().indexFor(label("Node")).on("prop").create(); tx.Success(); } using (Transaction tx = Db.beginTx()) { Db.schema().awaitIndexesOnline(10, SECONDS); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldListUsedIndexes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldListUsedIndexes() { // given string label = "IndexedLabel"; string property = "indexedProperty"; using (Transaction tx = _db.beginTx()) { _db.schema().indexFor(label(label)).on(property).create(); tx.Success(); } EnsureIndexesAreOnline(); ShouldListUsedIndexes(label, property); }
private void CreateIndex(params string[] keys) { using (Transaction tx = Db.beginTx()) { IndexCreator indexCreator = Db.schema().indexFor(LABEL); foreach (string key in keys) { indexCreator = indexCreator.On(key); } indexCreator.Create(); tx.Success(); } using (Transaction tx = Db.beginTx()) { Db.schema().awaitIndexesOnline(10, SECONDS); tx.Success(); } }
private void CreateIndex() { using (Transaction tx = Db.beginTx()) { Db.execute("CREATE INDEX ON " + _indexDefinition); tx.Success(); } using (Transaction tx = Db.beginTx()) { Db.schema().awaitIndexesOnline(5, TimeUnit.SECONDS); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnIndexRuleForLabelAndPropertyComposite() public virtual void ShouldReturnIndexRuleForLabelAndPropertyComposite() { string a = "a"; string b = "b"; string c = "c"; string d = "d"; string e = "e"; string f = "f"; CreateSchema(Db => Db.schema().indexFor(Label.label(LABEL1)).on(a).on(b).on(c).on(d).on(e).on(f).create()); StoreIndexDescriptor rule = _storage.indexGetForSchema(TestIndexDescriptorFactory.forLabel(LabelId(LABEL1), PropId(a), PropId(b), PropId(c), PropId(d), PropId(e), PropId(f))); assertNotNull(rule); assertTrue(SchemaDescriptorPredicates.hasLabel(rule, LabelId(LABEL1))); assertTrue(SchemaDescriptorPredicates.hasProperty(rule, PropId(a))); assertTrue(SchemaDescriptorPredicates.hasProperty(rule, PropId(b))); assertTrue(SchemaDescriptorPredicates.hasProperty(rule, PropId(c))); assertTrue(SchemaDescriptorPredicates.hasProperty(rule, PropId(d))); assertTrue(SchemaDescriptorPredicates.hasProperty(rule, PropId(e))); assertTrue(SchemaDescriptorPredicates.hasProperty(rule, PropId(f))); assertEquals(IndexDescriptor.Type.GENERAL, rule.Type()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldApplyChangesWithIntermediateConstraintViolations() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldApplyChangesWithIntermediateConstraintViolations() { // given using (Transaction tx = Db.beginTx()) { Db.schema().constraintFor(_foo).assertPropertyIsUnique(BAR).create(); tx.Success(); } Node fourtyTwo; Node fourtyOne; using (Transaction tx = Db.beginTx()) { fourtyTwo = Db.createNode(_foo); fourtyTwo.SetProperty(BAR, Value1); fourtyOne = Db.createNode(_foo); fourtyOne.SetProperty(BAR, Value2); tx.Success(); } // when using (Transaction tx = Db.beginTx()) { fourtyOne.Delete(); fourtyTwo.SetProperty(BAR, Value2); tx.Success(); } // then using (Transaction tx = Db.beginTx()) { assertEquals(Value2, fourtyTwo.GetProperty(BAR)); try { fourtyOne.GetProperty(BAR); fail("Should be deleted"); } catch (NotFoundException) { // good } tx.Success(); assertEquals(fourtyTwo, Db.findNode(_foo, BAR, Value2)); assertNull(Db.findNode(_foo, BAR, Value1)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void failedIndexShouldRepairAutomatically() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void FailedIndexShouldRepairAutomatically() { // given using (Transaction tx = Db.beginTx()) { Db.schema().indexFor(_person).on("name").create(); tx.Success(); } AwaitIndexesOnline(5, SECONDS); CreateNamed(_person, "Johan"); // when - we restart the database in a state where the index is not operational Db.restartDatabase(new SabotageNativeIndex(Random.random())); // then - the database should still be operational CreateNamed(_person, "Lars"); AwaitIndexesOnline(5, SECONDS); IndexStateShouldBe(equalTo(ONLINE)); AssertFindsNamed(_person, "Lars"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDropUniquenessConstraintWithBackingIndexNotInUse() public virtual void ShouldDropUniquenessConstraintWithBackingIndexNotInUse() { // given using ( Transaction tx = Db.beginTx() ) { Db.schema().constraintFor(_label).assertPropertyIsUnique(_key).create(); tx.Success(); } // when intentionally breaking the schema by setting the backing index rule to unused RecordStorageEngine storageEngine = Db.DependencyResolver.resolveDependency( typeof( RecordStorageEngine ) ); SchemaStore schemaStore = storageEngine.TestAccessNeoStores().SchemaStore; SchemaRule indexRule = single( filter( rule => rule is StoreIndexDescriptor, schemaStore.LoadAllSchemaRules() ) ); SetSchemaRecordNotInUse( schemaStore, indexRule.Id ); // At this point the SchemaCache doesn't know about this change so we have to reload it storageEngine.LoadSchemaCache(); using ( Transaction tx = Db.beginTx() ) { single( Db.schema().getConstraints(_label).GetEnumerator() ).drop(); tx.Success(); } // then using ( Transaction ignore = Db.beginTx() ) { assertFalse( Db.schema().Constraints.GetEnumerator().hasNext() ); assertFalse( Db.schema().Indexes.GetEnumerator().hasNext() ); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void multiTokenFulltextIndexesMustShowUpInSchemaGetIndexes() public virtual void MultiTokenFulltextIndexesMustShowUpInSchemaGetIndexes() { using (Transaction tx = Db.beginTx()) { Db.execute(format(NODE_CREATE, "nodeIndex", array("Label1", "Label2"), array("prop1", "prop2"))).close(); Db.execute(format(RELATIONSHIP_CREATE, "relIndex", array("RelType1", "RelType2"), array("prop1", "prop2"))).close(); tx.Success(); } using (Transaction tx = Db.beginTx()) { foreach (IndexDefinition index in Db.schema().Indexes) { assertFalse(index.ConstraintIndex); assertTrue(index.MultiTokenIndex); assertTrue(index.CompositeIndex); if (index.NodeIndex) { assertFalse(index.RelationshipIndex); assertThat(index.Labels, containsInAnyOrder(Label.label("Label1"), Label.label("Label2"))); try { index.Label; fail("index.getLabel() on multi-token IndexDefinition should have thrown."); } catch (System.InvalidOperationException) { } try { index.RelationshipTypes; fail("index.getRelationshipTypes() on node IndexDefinition should have thrown."); } catch (System.InvalidOperationException) { } } else { assertTrue(index.RelationshipIndex); assertThat(index.RelationshipTypes, containsInAnyOrder(RelationshipType.withName("RelType1"), RelationshipType.withName("RelType2"))); try { index.RelationshipType; fail("index.getRelationshipType() on multi-token IndexDefinition should have thrown."); } catch (System.InvalidOperationException) { } try { index.Labels; fail("index.getLabels() on node IndexDefinition should have thrown."); } catch (System.InvalidOperationException) { } } } tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void concurrentCreatingOfIndexesShouldNotInterfere() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ConcurrentCreatingOfIndexesShouldNotInterfere() { // WHEN concurrently creating indexes for different labels Race race = new Race(); for (int i = 0; i < _threads; i++) { race.AddContestant(IndexCreate(i), 1); } race.Go(); // THEN they should all be observed as existing in the end using (Transaction tx = Db.beginTx()) { IList <IndexDefinition> indexes = new IList <IndexDefinition> { Db.schema().Indexes }; assertEquals(_threads, indexes.Count); ISet <string> labels = new HashSet <string>(); foreach (IndexDefinition index in indexes) { assertTrue(labels.Add(single(index.Labels).name())); } tx.Success(); } }