Exemple #1
0
//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();
        }
Exemple #2
0
//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();
        }
Exemple #3
0
//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);
        }
Exemple #4
0
//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();
        }
Exemple #5
0
//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();
        }
Exemple #6
0
//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();
        }
Exemple #7
0
//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);
        }