//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleNullInIndexSeek() throws org.neo4j.internal.kernel.api.exceptions.KernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleNullInIndexSeek() { // GIVEN Read read = mock(typeof(Read)); IndexReference index = mock(typeof(IndexReference)); when(index.Properties()).thenReturn(new int[] { 42 }); // WHEN NodeValueIndexCursor cursor = CompiledIndexUtils.IndexSeek(mock(typeof(Read)), mock(typeof(CursorFactory)), index, null); // THEN verify(read, never()).nodeIndexSeek(any(), any(), any(), anyBoolean()); assertFalse(cursor.Next()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHoldSharedIndexLockIfNodeIsExists() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHoldSharedIndexLockIfNodeIsExists() { // given NodeValueIndexCursor cursor = mock(typeof(NodeValueIndexCursor)); when(cursor.Next()).thenReturn(true); when(cursor.NodeReference()).thenReturn(42L); // when long nodeId = LockingNodeUniqueIndexSeek.Apply(_locks, LockTracer.NONE, () => cursor, _uniqueNodeIndexSeeker, _read, _index, _predicate); // then assertEquals(42L, nodeId); verify(_locks).acquireShared(LockTracer.NONE, INDEX_ENTRY, _resourceId); verifyNoMoreInteractions(_locks); verify(cursor).close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAllowConcurrentViolationOfConstraint() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAllowConcurrentViolationOfConstraint() { // Given GraphDatabaseAPI graphDb = Db.GraphDatabaseAPI; System.Func <KernelTransaction> ktxSupplier = () => graphDb.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); Label label = label("Foo"); string propertyKey = "bar"; string conflictingValue = "baz"; // a constraint using (Transaction tx = graphDb.BeginTx()) { graphDb.Schema().constraintFor(label).assertPropertyIsUnique(propertyKey).create(); tx.Success(); } // When using (Transaction tx = graphDb.BeginTx()) { KernelTransaction ktx = ktxSupplier(); int labelId = ktx.TokenRead().nodeLabel(label.Name()); int propertyKeyId = ktx.TokenRead().propertyKey(propertyKey); IndexDescriptor index = TestIndexDescriptorFactory.uniqueForLabel(labelId, propertyKeyId); Read read = ktx.DataRead(); using (NodeValueIndexCursor cursor = ktx.Cursors().allocateNodeValueIndexCursor()) { read.NodeIndexSeek(ktx.SchemaRead().index(labelId, propertyKeyId), cursor, IndexOrder.NONE, false, IndexQuery.exact(index.Schema().PropertyId, "The value is irrelevant, we just want to perform some sort of lookup against this " + "index")); } // then let another thread come in and create a node Threads.execute(Db => { using (Transaction transaction = Db.beginTx()) { Db.createNode(label).setProperty(propertyKey, conflictingValue); transaction.success(); } return(null); }, graphDb).get(); // before we create a node with the same property ourselves - using the same statement that we have // already used for lookup against that very same index long node = ktx.DataWrite().nodeCreate(); ktx.DataWrite().nodeAddLabel(node, labelId); try { ktx.DataWrite().nodeSetProperty(node, propertyKeyId, Values.of(conflictingValue)); fail("exception expected"); } // Then catch (UniquePropertyValueValidationException e) { assertEquals(ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKeyId), e.Constraint()); IndexEntryConflictException conflict = Iterators.single(e.Conflicts().GetEnumerator()); assertEquals(Values.stringValue(conflictingValue), conflict.SinglePropertyValue); } tx.Success(); } }