internal virtual IndexUpdater NewPopulatingUpdater() { IndexUpdater updater = new CollectingIndexUpdater(updates => processUpdates(updates, _updatesConflictDetector)); if (descriptor.type() == UNIQUE && CanCheckConflictsWithoutStoreAccess()) { // The index population detects conflicts on the fly, however for updates coming in we're in a position // where we cannot detect conflicts while applying, but instead afterwards. updater = new DeferredConflictCheckingIndexUpdater(updater, this.newReader, descriptor); } return(updater); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldQueryAboutAddedAndChangedValueTuples() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldQueryAboutAddedAndChangedValueTuples() { // given IndexUpdater actual = mock(typeof(IndexUpdater)); IndexReader reader = mock(typeof(IndexReader)); when(reader.Query(anyVararg())).thenAnswer(invocation => iterator(0)); long nodeId = 0; IList <IndexEntryUpdate <IndexDescriptor> > updates = new List <IndexEntryUpdate <IndexDescriptor> >(); updates.Add(add(nodeId++, _descriptor, Tuple(10, 11))); updates.Add(change(nodeId++, _descriptor, Tuple("abc", "def"), Tuple("ghi", "klm"))); updates.Add(remove(nodeId++, _descriptor, Tuple(1001L, 1002L))); updates.Add(change(nodeId++, _descriptor, Tuple(( sbyte )2, ( sbyte )3), Tuple(( sbyte )4, ( sbyte )5))); updates.Add(add(nodeId++, _descriptor, Tuple(5, "5"))); using (DeferredConflictCheckingIndexUpdater updater = new DeferredConflictCheckingIndexUpdater(actual, () => reader, _descriptor)) { // when foreach (IndexEntryUpdate <IndexDescriptor> update in updates) { updater.Process(update); verify(actual).process(update); } } // then foreach (IndexEntryUpdate <IndexDescriptor> update in updates) { if (update.UpdateMode() == UpdateMode.ADDED || update.UpdateMode() == UpdateMode.CHANGED) { Value[] tuple = update.Values(); IndexQuery[] query = new IndexQuery[tuple.Length]; for (int i = 0; i < tuple.Length; i++) { query[i] = IndexQuery.exact(_propertyKeyIds[i], tuple[i]); } verify(reader).query(query); } } verify(reader).close(); verifyNoMoreInteractions(reader); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowOnIndexEntryConflict() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowOnIndexEntryConflict() { // given IndexUpdater actual = mock(typeof(IndexUpdater)); IndexReader reader = mock(typeof(IndexReader)); when(reader.Query(anyVararg())).thenAnswer(invocation => iterator(101, 202)); DeferredConflictCheckingIndexUpdater updater = new DeferredConflictCheckingIndexUpdater(actual, () => reader, _descriptor); // when updater.Process(add(0, _descriptor, Tuple(10, 11))); try { updater.Close(); fail("Should have failed"); } catch (IndexEntryConflictException e) { // then good assertThat(e.Message, containsString("101")); assertThat(e.Message, containsString("202")); } }