//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailTransactionThatIndexesLargePropertyDuringNodeCreation() public virtual void ShouldFailTransactionThatIndexesLargePropertyDuringNodeCreation() { // GIVEN GraphDatabaseService db = DbRule.GraphDatabaseAPI; IndexDefinition index = Neo4jMatchers.createIndex(db, _label, _propertyKey); //We expect this transaction to fail due to the huge property ExpectedException.expect(typeof(TransactionFailureException)); using (Transaction tx = Db.beginTx()) { try { Db.execute("CREATE (n:" + _label + " {name: \"" + _longString + "\"})"); fail("Argument was illegal"); } catch (System.ArgumentException) { //this is expected. } tx.Success(); } //Check that the database is empty. using (Transaction tx = Db.beginTx()) { ResourceIterator <Node> nodes = Db.AllNodes.GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(nodes.hasNext()); } Db.shutdown(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void validateNodePropertiesOnPopulation() internal virtual void ValidateNodePropertiesOnPopulation() { setUp(); Label label = Label.label("populationTestNodeLabel"); string propertyName = "populationTestPropertyName"; using (Transaction transaction = _database.beginTx()) { Node node = _database.createNode(label); node.SetProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1)); transaction.Success(); } IndexDefinition indexDefinition = CreateIndex(label, propertyName); try { using (Transaction ignored = _database.beginTx()) { _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES); } } catch (System.InvalidOperationException) { using (Transaction ignored = _database.beginTx()) { string indexFailure = _database.schema().getIndexFailure(indexDefinition); assertThat(indexFailure, allOf(containsString("java.lang.IllegalArgumentException:"), containsString("Please see index documentation for limitations."))); } } }
private void DropIndex(IndexDefinition index) { using (Transaction tx = _db.beginTx()) { index.Drop(); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addingAnIndexingRuleShouldSucceed() public virtual void AddingAnIndexingRuleShouldSucceed() { // WHEN IndexDefinition index = createIndex(_db, _label, _propertyKey); // THEN assertThat(getIndexes(_db, _label), containsOnly(index)); }
protected internal NodeConstraintDefinition(InternalSchemaActions actions, IndexDefinition indexDefinition) : base(actions, indexDefinition) { if (indexDefinition.MultiTokenIndex) { throw new System.ArgumentException("Node constraints do not support multi-token definitions. That is, they cannot apply to more than one label, " + "but an attempt was made to create a node constraint on the following labels: " + labelNameList(indexDefinition.Labels, "", ".")); } this.LabelConflict = single(indexDefinition.Labels); }
private void AwaitIndexOnline(IndexDefinition definition) { using (Transaction tx = _db.beginTx()) { _db.schema().awaitIndexOnline(definition, 10, TimeUnit.SECONDS); tx.Success(); } }
private void DropIndex(IndexDefinition index, DoubleLatch populationCompletionLatch) { using (Transaction tx = _db.beginTx()) { index.Drop(); populationCompletionLatch.Finish(); tx.Success(); } }
private IndexDefinition CreateIndex() { using (Transaction tx = _db.beginTx()) { IndexDefinition index = _db.schema().indexFor(_myLabel).on("number_of_bananas_owned").create(); tx.Success(); return(index); } }
private static IndexDefinition CreateIndex(GraphDatabaseService db) { using (Transaction tx = Db.beginTx()) { IndexDefinition index = Db.schema().indexFor(LABEL_ONE).on(KEY).create(); tx.Success(); return(index); } }
private IndexDefinition IndexAliensBySpecimen() { using (Transaction tx = _db.beginTx()) { IndexDefinition definition = _db.schema().indexFor(_alien).on(SPECIMEN).create(); tx.Success(); return(definition); } }
private IndexDefinition CreateIndex(Label label, string propertyName) { using (Transaction transaction = _database.beginTx()) { IndexDefinition indexDefinition = _database.schema().indexFor(label).on(propertyName).create(); transaction.Success(); return(indexDefinition); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void droppingExistingIndexRuleShouldSucceed() public virtual void DroppingExistingIndexRuleShouldSucceed() { // GIVEN IndexDefinition index = createIndex(_db, _label, _propertyKey); // WHEN DropIndex(index); // THEN assertThat(getIndexes(_db, _label), Empty); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPopulateIndex() public virtual void ShouldPopulateIndex() { // GIVEN Node node = CreateNode(_db, _propertyKey, "Neo", _label); // create an index IndexDefinition index = createIndex(_db, _label, _propertyKey); waitForIndex(_db, index); // THEN assertThat(findNodesByLabelAndProperty(_label, _propertyKey, "Neo", _db), containsOnly(node)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void awaitingIndexComingOnlineWorks() public virtual void AwaitingIndexComingOnlineWorks() { // GIVEN // WHEN IndexDefinition index = createIndex(_db, _label, _propertyKey); // PASS using (Transaction tx = _db.beginTx()) { _db.schema().awaitIndexOnline(index, 1L, TimeUnit.MINUTES); // THEN assertEquals(Org.Neo4j.Graphdb.schema.Schema_IndexState.Online, _db.schema().getIndexState(index)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addedUncommittedIndexesShouldBeVisibleWithinTheTransaction() public virtual void AddedUncommittedIndexesShouldBeVisibleWithinTheTransaction() { // GIVEN IndexDefinition indexA = createIndex(_db, _label, "a"); CreateUniquenessConstraint(_label, "b"); // WHEN using (Transaction tx = _db.beginTx()) { assertThat(count(_db.schema().getIndexes(_label)), @is(2L)); IndexDefinition indexC = _db.schema().indexFor(_label).on("c").create(); // THEN assertThat(count(_db.schema().getIndexes(_label)), @is(3L)); assertThat(_db.schema().getIndexState(indexA), @is(Org.Neo4j.Graphdb.schema.Schema_IndexState.Online)); assertThat(_db.schema().getIndexState(indexC), @is(Org.Neo4j.Graphdb.schema.Schema_IndexState.Populating)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void droppingAnUnexistingIndexShouldGiveHelpfulExceptionInSeparateTransactions() public virtual void DroppingAnUnexistingIndexShouldGiveHelpfulExceptionInSeparateTransactions() { // GIVEN IndexDefinition index = createIndex(_db, _label, _propertyKey); DropIndex(index); // WHEN try { DropIndex(index); fail("Should not be able to drop index twice"); } catch (ConstraintViolationException e) { assertThat(e.Message, containsString("No such INDEX ON :MY_LABEL(my_property_key).")); } // THEN assertThat("Index should have been deleted", getIndexes(_db, _label), not(contains(index))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRecreateDroppedIndex() public virtual void ShouldRecreateDroppedIndex() { // GIVEN Node node = CreateNode(_db, _propertyKey, "Neo", _label); // create an index IndexDefinition index = createIndex(_db, _label, _propertyKey); waitForIndex(_db, index); // delete the index right away DropIndex(index); // WHEN recreating that index createIndex(_db, _label, _propertyKey); waitForIndex(_db, index); // THEN it should exist and be usable assertThat(getIndexes(_db, _label), contains(index)); assertThat(findNodesByLabelAndProperty(_label, _propertyKey, "Neo", _db), containsOnly(node)); }
/* This is somewhat difficult to test since dropping an index while it's populating forces it to be cancelled * first (and also awaiting cancellation to complete). So this is a best-effort to have the timing as close * as possible. If this proves to be flaky, remove it right away. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToDropIndexWhileItIsPopulating() public virtual void ShouldBeAbleToDropIndexWhileItIsPopulating() { // GIVEN StartDb(); DoubleLatch populationCompletionLatch = _provider.installPopulationJobCompletionLatch(); IndexDefinition index = CreateIndex(); populationCompletionLatch.WaitForAllToStart(); // await population job to start // WHEN DropIndex(index, populationCompletionLatch); // THEN assertThat(getIndexes(_db, _myLabel), inTx(_db, hasSize(0))); try { getIndexState(_db, index); fail("This index should have been deleted"); } catch (NotFoundException e) { assertThat(e.Message, CoreMatchers.containsString(_myLabel.name())); } }
public NodeKeyConstraintDefinition(InternalSchemaActions actions, IndexDefinition indexDefinition) : base(actions, indexDefinition) { }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHaveAvailableOrphanedConstraintIndexIfUniqueConstraintCreationFails() public virtual void ShouldHaveAvailableOrphanedConstraintIndexIfUniqueConstraintCreationFails() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction fs = fileSystemRule.get(); EphemeralFileSystemAbstraction fs = FileSystemRule.get(); fs.Mkdir(new File("/tmp")); File pathToDb = new File("/tmp/bar2"); TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory(); dbFactory.FileSystem = fs; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction[] storeInNeedOfRecovery = new org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction[1]; EphemeralFileSystemAbstraction[] storeInNeedOfRecovery = new EphemeralFileSystemAbstraction[1]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean monitorCalled = new java.util.concurrent.atomic.AtomicBoolean(false); AtomicBoolean monitorCalled = new AtomicBoolean(false); Monitors monitors = new Monitors(); monitors.AddMonitorListener(new MonitorAdapterAnonymousInnerClass(this, fs, storeInNeedOfRecovery, monitorCalled)); dbFactory.Monitors = monitors; // This test relies on behaviour that is specific to the Lucene populator, where uniqueness is controlled // after index has been populated, which is why we're using NATIVE20 and index booleans (they end up in Lucene) _db = ( GraphDatabaseAPI )dbFactory.NewImpermanentDatabaseBuilder(pathToDb).setConfig(default_schema_provider, NATIVE20.providerName()).newGraphDatabase(); using (Transaction tx = _db.beginTx()) { for (int i = 0; i < 2; i++) { _db.createNode(_label).setProperty(KEY, true); } tx.Success(); } try { using (Transaction tx = _db.beginTx()) { _db.schema().constraintFor(_label).assertPropertyIsUnique(KEY).create(); fail("Should have failed with ConstraintViolationException"); tx.Success(); } } catch (ConstraintViolationException) { } _db.shutdown(); assertTrue(monitorCalled.get()); // when dbFactory = new TestGraphDatabaseFactory(); dbFactory.FileSystem = storeInNeedOfRecovery[0]; _db = ( GraphDatabaseAPI )dbFactory.NewImpermanentDatabase(pathToDb); // then using (Transaction ignore = _db.beginTx()) { _db.schema().awaitIndexesOnline(10, TimeUnit.SECONDS); } using (Transaction ignore = _db.beginTx()) { assertEquals(2, Iterables.count(_db.AllNodes)); } using (Transaction ignore = _db.beginTx()) { assertEquals(0, Iterables.count(Iterables.asList(_db.schema().Constraints))); } using (Transaction ignore = _db.beginTx()) { IndexDefinition orphanedConstraintIndex = single(_db.schema().Indexes); assertEquals(_label.name(), single(orphanedConstraintIndex.Labels).name()); assertEquals(KEY, single(orphanedConstraintIndex.PropertyKeys)); } _db.shutdown(); }
public UniquenessConstraintDefinition(InternalSchemaActions actions, IndexDefinition indexDefinition) : base(actions, indexDefinition) { }