//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCreateConstraintThatAlreadyExists() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotCreateConstraintThatAlreadyExists() { { // given SchemaWrite statement = schemaWriteInNewTransaction(); CreateConstraint(statement, Descriptor); commit(); } // when try { SchemaWrite statement = schemaWriteInNewTransaction(); CreateConstraint(statement, Descriptor); fail("Should not have validated"); } // then catch (AlreadyConstrainedException) { // good } commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotRemoveConstraintThatGetsReAdded() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotRemoveConstraintThatGetsReAdded() { // given Constraint constraint; { SchemaWrite statement = schemaWriteInNewTransaction(); constraint = CreateConstraint(statement, Descriptor); commit(); } using (Org.Neo4j.Graphdb.Transaction tx = Db.beginTx()) { // Make sure all schema changes are stable, to avoid any synchronous schema state invalidation Db.schema().awaitIndexesOnline(10, TimeUnit.SECONDS); } SchemaStateCheck schemaState = (new SchemaStateCheck(this)).SetUp(); { SchemaWrite statement = schemaWriteInNewTransaction(); // when DropConstraint(statement, constraint); CreateConstraint(statement, Descriptor); commit(); } { Transaction transaction = newTransaction(); // then assertEquals(singletonList(constraint), asCollection(transaction.SchemaRead().constraintsGetAll())); schemaState.AssertNotCleared(transaction); commit(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotDropConstraintThatDoesNotExist() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotDropConstraintThatDoesNotExist() { // given Constraint constraint = NewConstraintObject(Descriptor); { // when SchemaWrite statement = schemaWriteInNewTransaction(); try { DropConstraint(statement, constraint); fail("Should not have dropped constraint"); } catch (DropConstraintFailureException e) { assertThat(e.InnerException, instanceOf(typeof(NoSuchConstraintException))); } commit(); } { // then Transaction transaction = newTransaction(); assertEquals(emptySet(), asSet(transaction.SchemaRead().indexesGetAll())); commit(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldClearSchemaStateWhenConstraintIsDropped() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldClearSchemaStateWhenConstraintIsDropped() { // given Constraint constraint; SchemaStateCheck schemaState; { SchemaWrite statement = schemaWriteInNewTransaction(); constraint = CreateConstraint(statement, Descriptor); commit(); schemaState = (new SchemaStateCheck(this)).SetUp(); } { SchemaWrite statement = schemaWriteInNewTransaction(); // when DropConstraint(statement, constraint); commit(); } // then schemaState.AssertCleared(newTransaction()); rollback(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailToCreateIndexWhereAConstraintAlreadyExists() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFailToCreateIndexWhereAConstraintAlreadyExists() { { // given SchemaWrite statement = SchemaWriteInNewTransaction(); statement.UniquePropertyConstraintCreate(_descriptor); Commit(); } // when try { SchemaWrite statement = SchemaWriteInNewTransaction(); statement.IndexCreate(_descriptor); Commit(); fail("expected exception"); } // then catch (SchemaKernelException e) { assertEquals("There is a uniqueness constraint on :" + LABEL + "(" + PROPERTY_KEY + "), so an index is " + "already created that matches this.", e.Message); } Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDisallowDroppingIndexThatDoesNotExist() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDisallowDroppingIndexThatDoesNotExist() { // given IndexReference index; { SchemaWrite statement = SchemaWriteInNewTransaction(); index = statement.IndexCreate(_descriptor); Commit(); } { SchemaWrite statement = SchemaWriteInNewTransaction(); statement.IndexDrop(index); Commit(); } // when try { SchemaWrite statement = SchemaWriteInNewTransaction(); statement.IndexDrop(index); Commit(); } // then catch (SchemaKernelException e) { assertEquals("Unable to drop index on :label[" + _labelId + "](property[" + _propertyKeyId + "]): " + "No such INDEX ON :label[" + _labelId + "]uniquetempvar.", e.Message); } Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToRemoveAConstraintIndexWithoutOwner() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToRemoveAConstraintIndexWithoutOwner() { // given NodePropertyAccessor propertyAccessor = mock(typeof(NodePropertyAccessor)); AssertableLogProvider logProvider = new AssertableLogProvider(); ConstraintIndexCreator creator = new ConstraintIndexCreator(() => Kernel, IndexingService, propertyAccessor, logProvider); string defaultProvider = Config.defaults().get(default_schema_provider); IndexDescriptor constraintIndex = creator.CreateConstraintIndex(_descriptor, defaultProvider); // then Transaction transaction = NewTransaction(); assertEquals(emptySet(), asSet(transaction.SchemaRead().constraintsGetForLabel(_labelId))); Commit(); // when SchemaWrite schemaWrite = SchemaWriteInNewTransaction(); schemaWrite.IndexDrop(constraintIndex); Commit(); // then transaction = NewTransaction(); assertEquals(emptySet(), asSet(transaction.SchemaRead().indexesGetForLabel(_labelId))); Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDropConstraint() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDropConstraint() { // given Constraint constraint; { SchemaWrite statement = schemaWriteInNewTransaction(); constraint = CreateConstraint(statement, Descriptor); commit(); } { // when SchemaWrite statement = schemaWriteInNewTransaction(); DropConstraint(statement, constraint); commit(); } { // then Transaction transaction = newTransaction(); // then //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse("should not have any constraints", transaction.SchemaRead().constraintsGetAll().hasNext()); commit(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference createInitialIndex(org.neo4j.internal.kernel.api.schema.SchemaDescriptor descriptor) throws Exception private IndexReference CreateInitialIndex(SchemaDescriptor descriptor) { IndexReference index; using (KernelTransactionImplementation transaction = KernelTransaction) { SchemaWrite schemaWrite = transaction.SchemaWrite(); index = schemaWrite.IndexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), "nodes"); transaction.Success(); } Await(index); return(index); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateAnIndexToGoAlongWithAUniquePropertyConstraint() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCreateAnIndexToGoAlongWithAUniquePropertyConstraint() { // when SchemaWrite schemaWriteOperations = schemaWriteInNewTransaction(); schemaWriteOperations.UniquePropertyConstraintCreate(Descriptor); commit(); // then Transaction transaction = newTransaction(); assertEquals(asSet(_uniqueIndex), asSet(transaction.SchemaRead().indexesGetAll())); commit(); }
private ThrowingAction <Exception> DropAndReCreateIndex(IndexReference descriptor, SchemaDescriptor newDescriptor) { return(() => { _aliceLatch.await(); _bobLatch.await(); using (KernelTransactionImplementation transaction = KernelTransaction) { SchemaWrite schemaWrite = transaction.schemaWrite(); schemaWrite.indexDrop(descriptor); schemaWrite.indexCreate(newDescriptor, FulltextIndexProviderFactory.Descriptor.name(), "nodes"); transaction.success(); } }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldListAll() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldListAll() { // given SchemaWrite schemaWrite = SchemaWriteInNewTransaction(); IndexReference index1 = schemaWrite.IndexCreate(_descriptor); IndexReference index2 = (( IndexBackedConstraintDescriptor )schemaWrite.UniquePropertyConstraintCreate(_descriptor2)).ownedIndexDescriptor(); Commit(); // then/when SchemaRead schemaRead = NewTransaction().schemaRead(); IList <IndexReference> indexes = Iterators.asList(schemaRead.IndexesGetAll()); assertThat(indexes, containsInAnyOrder(index1, index2)); Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void rollBackIndexRuleShouldNotBeCommitted() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RollBackIndexRuleShouldNotBeCommitted() { // GIVEN SchemaWrite schemaWrite = SchemaWriteInNewTransaction(); // WHEN schemaWrite.IndexCreate(_descriptor); // don't mark as success Rollback(); // THEN Transaction transaction = NewTransaction(); assertEquals(emptySet(), asSet(transaction.SchemaRead().indexesGetForLabel(_labelId))); Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void committedConstraintRuleShouldCrossReferenceTheCorrespondingIndexRule() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CommittedConstraintRuleShouldCrossReferenceTheCorrespondingIndexRule() { // when SchemaWrite statement = schemaWriteInNewTransaction(); statement.UniquePropertyConstraintCreate(Descriptor); commit(); // then SchemaStorage schema = new SchemaStorage(NeoStores().SchemaStore); StoreIndexDescriptor indexRule = Schema.indexGetForSchema(TestIndexDescriptorFactory.uniqueForLabel(TypeId, PropertyKeyId)); ConstraintRule constraintRule = Schema.constraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(TypeId, PropertyKeyId)); assertEquals(constraintRule.Id, indexRule.OwningConstraint.Value); assertEquals(indexRule.Id, constraintRule.OwnedIndex); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addIndexRuleInATransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AddIndexRuleInATransaction() { // GIVEN SchemaWrite schemaWriteOperations = SchemaWriteInNewTransaction(); // WHEN IndexReference expectedRule = schemaWriteOperations.IndexCreate(_descriptor); Commit(); // THEN SchemaRead schemaRead = NewTransaction().schemaRead(); assertEquals(asSet(expectedRule), asSet(schemaRead.IndexesGetForLabel(_labelId))); assertEquals(expectedRule, schemaRead.Index(_descriptor.LabelId, _descriptor.PropertyIds)); Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void committedAndTransactionalIndexRulesShouldBeMerged() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CommittedAndTransactionalIndexRulesShouldBeMerged() { // GIVEN SchemaWrite schemaWriteOperations = SchemaWriteInNewTransaction(); IndexReference existingRule = schemaWriteOperations.IndexCreate(_descriptor); Commit(); // WHEN Transaction transaction = NewTransaction(AUTH_DISABLED); IndexReference addedRule = transaction.SchemaWrite().indexCreate(SchemaDescriptorFactory.forLabel(_labelId, 10)); ISet <IndexReference> indexRulesInTx = asSet(transaction.SchemaRead().indexesGetForLabel(_labelId)); Commit(); // THEN assertEquals(asSet(existingRule, addedRule), indexRulesInTx); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.stream.Stream<BuiltInProcedures.SchemaIndexInfo> createIndex(String indexSpecification, String providerName, String statusMessage, IndexCreator indexCreator) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException private Stream <BuiltInProcedures.SchemaIndexInfo> CreateIndex(string indexSpecification, string providerName, string statusMessage, IndexCreator indexCreator) { AssertProviderNameNotNull(providerName); IndexSpecifier index = IndexSpecifier.ByPattern(indexSpecification); int labelId = GetOrCreateLabelId(index.Label()); int[] propertyKeyIds = GetOrCreatePropertyIds(index.Properties()); try { SchemaWrite schemaWrite = _ktx.schemaWrite(); LabelSchemaDescriptor labelSchemaDescriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyIds); indexCreator(schemaWrite, labelSchemaDescriptor, providerName); return(Stream.of(new BuiltInProcedures.SchemaIndexInfo(indexSpecification, providerName, statusMessage))); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ProcedureException(e.status(), e, e.Message); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAbortConstraintCreationWhenDuplicatesExist() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAbortConstraintCreationWhenDuplicatesExist() { // given Transaction transaction = newTransaction(AnonymousContext.writeToken()); // name is not unique for Foo in the existing data int foo = transaction.TokenWrite().labelGetOrCreateForName("Foo"); int name = transaction.TokenWrite().propertyKeyGetOrCreateForName("name"); long node1 = transaction.DataWrite().nodeCreate(); transaction.DataWrite().nodeAddLabel(node1, foo); transaction.DataWrite().nodeSetProperty(node1, name, Values.of("foo")); long node2 = transaction.DataWrite().nodeCreate(); transaction.DataWrite().nodeAddLabel(node2, foo); transaction.DataWrite().nodeSetProperty(node2, name, Values.of("foo")); commit(); // when LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(foo, name); try { SchemaWrite schemaWriteOperations = schemaWriteInNewTransaction(); schemaWriteOperations.UniquePropertyConstraintCreate(descriptor); fail("expected exception"); } // then catch (CreateConstraintFailureException ex) { assertEquals(ConstraintDescriptorFactory.uniqueForSchema(descriptor), ex.Constraint()); Exception cause = ex.InnerException; assertThat(cause, instanceOf(typeof(ConstraintValidationException))); string expectedMessage = string.Format("Both Node({0:D}) and Node({1:D}) have the label `Foo` and property `name` = 'foo'", node1, node2); string actualMessage = UserMessage(( ConstraintValidationException )cause); assertEquals(expectedMessage, actualMessage); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDropConstraintIndexWhenDroppingConstraint() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDropConstraintIndexWhenDroppingConstraint() { // given Transaction transaction = newTransaction(LoginContext.AUTH_DISABLED); ConstraintDescriptor constraint = transaction.SchemaWrite().uniquePropertyConstraintCreate(Descriptor); assertEquals(asSet(_uniqueIndex), asSet(transaction.SchemaRead().indexesGetAll())); commit(); // when SchemaWrite schemaWriteOperations = schemaWriteInNewTransaction(); schemaWriteOperations.ConstraintDrop(constraint); commit(); // then transaction = newTransaction(); assertEquals(emptySet(), asSet(transaction.SchemaRead().indexesGetAll())); commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotPersistConstraintCreatedInAbortedTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotPersistConstraintCreatedInAbortedTransaction() { // given SchemaWrite schemaWriteOperations = schemaWriteInNewTransaction(); CreateConstraint(schemaWriteOperations, Descriptor); // when rollback(); Transaction transaction = newTransaction(); // then //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Iterator<?> constraints = transaction.schemaRead().constraintsGetAll(); IEnumerator <object> constraints = transaction.SchemaRead().constraintsGetAll(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse("should not have any constraints", constraints.hasNext()); commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotDropPropertyExistenceConstraintThatDoesNotExistWhenThereIsAUniquePropertyConstraint() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotDropPropertyExistenceConstraintThatDoesNotExistWhenThereIsAUniquePropertyConstraint() { // given ConstraintDescriptor constraint; { SchemaWrite statement = schemaWriteInNewTransaction(); constraint = statement.UniquePropertyConstraintCreate(Descriptor); commit(); } // when try { SchemaWrite statement = schemaWriteInNewTransaction(); statement.ConstraintDrop(ConstraintDescriptorFactory.existsForSchema(constraint.Schema())); fail("expected exception"); } // then catch (DropConstraintFailureException e) { assertThat(e.InnerException, instanceOf(typeof(NoSuchConstraintException))); } finally { rollback(); } { // then Transaction transaction = newTransaction(); IEnumerator <ConstraintDescriptor> constraints = transaction.SchemaRead().constraintsGetForSchema(Descriptor); assertEquals(constraint, single(constraints)); commit(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToResolveConflictsAndRecreateConstraintAfterFailingToCreateItDueToConflict() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToResolveConflictsAndRecreateConstraintAfterFailingToCreateItDueToConflict() { // given using (Org.Neo4j.Graphdb.Transaction tx = Db.beginTx()) { CreateOffendingDataInRunningTx(db); tx.Success(); } // when try { using (Org.Neo4j.Graphdb.Transaction tx = Db.beginTx()) { CreateConstraintInRunningTx(db, KEY, PROP); tx.Success(); fail("expected failure"); } } catch (QueryExecutionException e) { assertThat(e.Message, startsWith("Unable to create CONSTRAINT")); } using (Org.Neo4j.Graphdb.Transaction tx = Db.beginTx()) { RemoveOffendingDataInRunningTx(db); tx.Success(); } // then - this should not fail SchemaWrite statement = schemaWriteInNewTransaction(); CreateConstraint(statement, Descriptor); commit(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: abstract void dropConstraint(org.neo4j.internal.kernel.api.SchemaWrite writeOps, Constraint constraint) throws Exception; internal abstract void DropConstraint(SchemaWrite writeOps, Constraint constraint);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: abstract Constraint createConstraint(org.neo4j.internal.kernel.api.SchemaWrite writeOps, DESCRIPTOR descriptor) throws Exception; internal abstract Constraint CreateConstraint(SchemaWrite writeOps, DESCRIPTOR descriptor);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: ConstraintDescriptor createConstraint(org.neo4j.internal.kernel.api.SchemaWrite writeOps, org.neo4j.kernel.api.schema.RelationTypeSchemaDescriptor descriptor) throws Exception internal override ConstraintDescriptor CreateConstraint(SchemaWrite writeOps, RelationTypeSchemaDescriptor descriptor) { return(writeOps.RelationshipPropertyExistenceConstraintCreate(descriptor)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: void dropConstraint(org.neo4j.internal.kernel.api.SchemaWrite writeOps, org.neo4j.internal.kernel.api.schema.constraints.ConstraintDescriptor constraint) throws Exception internal override void DropConstraint(SchemaWrite writeOps, ConstraintDescriptor constraint) { writeOps.ConstraintDrop(constraint); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: ConstraintDescriptor createConstraint(org.neo4j.internal.kernel.api.SchemaWrite writeOps, org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor descriptor) throws Exception internal override ConstraintDescriptor CreateConstraint(SchemaWrite writeOps, LabelSchemaDescriptor descriptor) { return(writeOps.NodePropertyExistenceConstraintCreate(descriptor)); }