//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() throws org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Setup() { when(_transaction.tokenRead()).thenReturn(_tokenRead); when(_bridge.get()).thenReturn(_stmt); when(_tokenRead.propertyKeyName(anyInt())).thenAnswer(invocationOnMock => { int id = invocationOnMock.getArgument(0); return(_ops.propertyKeyTokenHolder().getTokenById(id).name()); }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Setup() { _procs.registerComponent(typeof(KernelTransaction), ctx => ctx.get(KERNEL_TRANSACTION), false); _procs.registerComponent(typeof(DependencyResolver), ctx => ctx.get(_dependencyResolver), false); _procs.registerComponent(typeof(GraphDatabaseAPI), ctx => ctx.get(_graphdatabaseapi), false); _procs.registerComponent(typeof(SecurityContext), ctx => ctx.get(SECURITY_CONTEXT), true); _procs.registerComponent(typeof(Log), ctx => ctx.get(_log), false); _procs.registerType(typeof(Node), NTNode); _procs.registerType(typeof(Relationship), NTRelationship); _procs.registerType(typeof(Path), NTPath); (new SpecialBuiltInProcedures("1.3.37", Edition.enterprise.ToString())).accept(_procs); _procs.registerProcedure(typeof(BuiltInProcedures)); _procs.registerProcedure(typeof(BuiltInDbmsProcedures)); when(_tx.acquireStatement()).thenReturn(_statement); when(_tx.tokenRead()).thenReturn(_tokens); when(_tx.dataRead()).thenReturn(_read); when(_tx.schemaRead()).thenReturn(_schemaRead); when(_schemaRead.snapshot()).thenReturn(_schemaReadCore); when(_tokens.propertyKeyGetAllTokens()).thenAnswer(AsTokens(_propKeys)); when(_tokens.labelsGetAllTokens()).thenAnswer(AsTokens(_labels)); when(_tokens.relationshipTypesGetAllTokens()).thenAnswer(AsTokens(_relTypes)); when(_schemaReadCore.indexesGetAll()).thenAnswer(i => Iterators.concat(_indexes.GetEnumerator(), _uniqueIndexes.GetEnumerator())); when(_schemaReadCore.index(any(typeof(SchemaDescriptor)))).thenAnswer((Answer <IndexReference>)invocationOnMock => { SchemaDescriptor schema = invocationOnMock.getArgument(0); int label = Schema.keyId(); int prop = Schema.PropertyId; return(GetIndexReference(label, prop)); }); when(_schemaReadCore.constraintsGetAll()).thenAnswer(i => _constraints.GetEnumerator()); when(_tokens.propertyKeyName(anyInt())).thenAnswer(invocation => _propKeys[invocation.getArgument(0)]); when(_tokens.nodeLabelName(anyInt())).thenAnswer(invocation => _labels[invocation.getArgument(0)]); when(_tokens.relationshipTypeName(anyInt())).thenAnswer(invocation => _relTypes[invocation.getArgument(0)]); when(_indexingService.getIndexId(any(typeof(SchemaDescriptor)))).thenReturn(42L); when(_schemaReadCore.constraintsGetForRelationshipType(anyInt())).thenReturn(emptyIterator()); when(_schemaReadCore.indexesGetForLabel(anyInt())).thenReturn(emptyIterator()); when(_schemaReadCore.indexesGetForRelationshipType(anyInt())).thenReturn(emptyIterator()); when(_schemaReadCore.constraintsGetForLabel(anyInt())).thenReturn(emptyIterator()); when(_read.countsForNode(anyInt())).thenReturn(1L); when(_read.countsForRelationship(anyInt(), anyInt(), anyInt())).thenReturn(1L); when(_schemaReadCore.indexGetState(any(typeof(IndexReference)))).thenReturn(InternalIndexState.ONLINE); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailOnExistingOwnedConstraintIndex() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFailOnExistingOwnedConstraintIndex() { // given IndexingService indexingService = mock(typeof(IndexingService)); StubKernel kernel = new StubKernel(this); long constraintIndexId = 111; long constraintIndexOwnerId = 222; when(_schemaRead.indexGetCommittedId(_indexReference)).thenReturn(constraintIndexId); IndexProxy indexProxy = mock(typeof(IndexProxy)); when(indexingService.GetIndexProxy(constraintIndexId)).thenReturn(indexProxy); NodePropertyAccessor nodePropertyAccessor = mock(typeof(NodePropertyAccessor)); when(_schemaRead.index(_descriptor)).thenReturn(_indexReference); when(_schemaRead.indexGetOwningUniquenessConstraintId(_indexReference)).thenReturn(constraintIndexOwnerId); // which means there's an owner when(_tokenRead.nodeLabelName(LABEL_ID)).thenReturn("MyLabel"); when(_tokenRead.propertyKeyName(PROPERTY_KEY_ID)).thenReturn("MyKey"); ConstraintIndexCreator creator = new ConstraintIndexCreator(() => kernel, indexingService, nodePropertyAccessor, _logProvider); // when try { KernelTransactionImplementation transaction = CreateTransaction(); creator.CreateUniquenessConstraintIndex(transaction, _descriptor, DefaultProvider); fail("Should've failed"); } catch (AlreadyConstrainedException) { // THEN good } // then assertEquals("There should have been no need to acquire a statement to create the constraint index", 0, kernel.Transactions.Count); verify(_schemaRead).index(_descriptor); verify(_schemaRead).indexGetOwningUniquenessConstraintId(_indexReference); verifyNoMoreInteractions(_schemaRead); }