//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void randomModifications(long[] expected, int count) throws java.io.IOException private void RandomModifications(long[] expected, int count) { BitArray editedNodes = new BitArray(); using (LabelScanWriter writer = _store.newWriter()) { for (int i = 0; i < count; i++) { int nodeId = _random.Next(NODE_COUNT); if (editedNodes.Get(nodeId)) { i--; continue; } int changeSize = _random.Next(3) + 1; long labels = expected[nodeId]; long[] labelsBefore = GetLabels(labels); for (int j = 0; j < changeSize; j++) { labels = FlipRandom(labels, LABEL_COUNT, _random.random()); } long[] labelsAfter = GetLabels(labels); editedNodes.Set(nodeId, true); NodeLabelUpdate labelChanges = labelChanges(nodeId, labelsBefore, labelsAfter); writer.Write(labelChanges); expected[nodeId] = labels; } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void failedIndexShouldRepairAutomatically() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void FailedIndexShouldRepairAutomatically() { // given using (Transaction tx = Db.beginTx()) { Db.schema().indexFor(_person).on("name").create(); tx.Success(); } AwaitIndexesOnline(5, SECONDS); CreateNamed(_person, "Johan"); // when - we restart the database in a state where the index is not operational Db.restartDatabase(new SabotageNativeIndex(Random.random())); // then - the database should still be operational CreateNamed(_person, "Lars"); AwaitIndexesOnline(5, SECONDS); IndexStateShouldBe(equalTo(ONLINE)); AssertFindsNamed(_person, "Lars"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void randomizedTest() internal virtual void RandomizedTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int count = 10000 + rnd.nextInt(1000); int count = 10000 + _rnd.Next(1000); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<org.eclipse.collections.api.tuple.primitive.ObjectLongPair<org.neo4j.values.storable.Value>> valueRefPairs = new java.util.ArrayList<>(); IList <ObjectLongPair <Value> > valueRefPairs = new List <ObjectLongPair <Value> >(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.list.MutableList<org.eclipse.collections.api.tuple.primitive.ObjectLongPair<org.neo4j.values.storable.Value>> toRemove = new org.eclipse.collections.impl.list.mutable.FastList<>(); MutableList <ObjectLongPair <Value> > toRemove = new FastList <ObjectLongPair <Value> >(); for (int i = 0; i < count; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.values.storable.Value value = rnd.randomValues().nextValue(); Value value = _rnd.randomValues().nextValue(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long ref = container.add(value); long @ref = _container.add(value); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.tuple.primitive.ObjectLongPair<org.neo4j.values.storable.Value> pair = pair(value, ref); ObjectLongPair <Value> pair = pair(value, @ref); if (_rnd.nextBoolean()) { toRemove.add(pair); } else { valueRefPairs.Add(pair); } } toRemove.shuffleThis(_rnd.random()); foreach (ObjectLongPair <Value> valueRefPair in toRemove) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.values.storable.Value removed = container.remove(valueRefPair.getTwo()); Value removed = _container.remove(valueRefPair.Two); assertEquals(valueRefPair.One, removed); assertThrows(typeof(System.ArgumentException), () => _container.remove(valueRefPair.Two)); assertThrows(typeof(System.ArgumentException), () => _container.get(valueRefPair.Two)); } foreach (ObjectLongPair <Value> valueRefPair in valueRefPairs) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.values.storable.Value actualValue = container.get(valueRefPair.getTwo()); Value actualValue = _container.get(valueRefPair.Two); assertEquals(valueRefPair.One, actualValue); } }
// ====================================================== // Below is code for generating import data // ====================================================== private IList <InputEntity> RandomNodeData() { IList <InputEntity> nodes = new List <InputEntity>(); for (int i = 0; i < 300; i++) { InputEntity node = new InputEntity(); node.Id(System.Guid.randomUUID().ToString(), [email protected]_Fields.Global); node.property("name", "Node " + i); node.property("pointA", "\" { x : -4.2, y : " + i + ", crs: WGS-84 } \""); node.property("pointB", "\" { x : -8, y : " + i + " } \""); node.property("date", LocalDate.of(2018, i % 12 + 1, i % 28 + 1)); node.property("time", OffsetTime.of(1, i % 60, 0, 0, ZoneOffset.ofHours(9))); node.property("dateTime", ZonedDateTime.of(2011, 9, 11, 8, i % 60, 0, 0, ZoneId.of("Europe/Stockholm"))); node.property("dateTime2", new DateTime(2011, 9, 11, 8, i % 60, 0, 0)); // No zone specified node.property("localTime", LocalTime.of(1, i % 60, 0)); node.property("localDateTime", new DateTime(2011, 9, 11, 8, i % 60)); node.property("duration", Period.of(2, -3, i % 30)); node.Labels(RandomLabels(Random.random())); nodes.Add(node); } return(nodes); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void randomizedTest() internal virtual void RandomizedTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int count = 10000 + rnd.nextInt(1000); int count = 10000 + _rnd.Next(1000); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableLongLongMap m = new org.eclipse.collections.impl.map.mutable.primitive.LongLongHashMap(); MutableLongLongMap m = new LongLongHashMap(); while (m.size() < count) { m.put(_rnd.nextLong(), _rnd.nextLong()); } m.forEachKeyValue((k, v) => { assertFalse(_map.containsKey(k)); _map.put(k, v); assertTrue(_map.containsKey(k)); assertEquals(v, _map.get(k)); assertEquals(v, _map.getOrThrow(k)); assertEquals(v, _map.getIfAbsent(k, v * 2)); assertEquals(v, _map.getIfAbsentPut(k, v * 2)); assertEquals(v, _map.getIfAbsentPut(k, () => v * 2)); }); assertEquals(m.size(), _map.size()); assertTrue(m.Keys.allSatisfy(_map.containsKey)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<org.eclipse.collections.api.tuple.primitive.LongLongPair> toRemove = m.keyValuesView().select(p -> rnd.nextInt(100) < 75).toList().shuffleThis(rnd.random()); IList <LongLongPair> toRemove = m.keyValuesView().select(p => _rnd.Next(100) < 75).toList().shuffleThis(_rnd.random()); toRemove.ForEach(p => { long k = p.One; long v = p.Two; _map.updateValue(k, v + 1, x => - x); assertEquals(-v, _map.get(k)); _map.remove(k); assertEquals(v * 2, _map.removeKeyIfAbsent(k, v * 2)); assertEquals(v * 2, _map.getIfAbsent(k, v * 2)); assertFalse(_map.containsKey(k)); assertThrows(typeof(System.InvalidOperationException), () => _map.getOrThrow(k)); _map.updateValue(k, v + 42, x => - x); assertEquals(-v - 42, _map.get(k)); }); toRemove.ForEach(p => _map.removeKey(p.One)); assertEquals(count - toRemove.Count, _map.size()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadForwardCorrectlyWithConcurrentInsert() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadForwardCorrectlyWithConcurrentInsert() { TestCoordinator testCoordinator = new TestCoordinator(this, _random.random(), true, 1); ShouldReadCorrectlyWithConcurrentUpdates(testCoordinator); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void scrambleFile(java.io.File file) throws java.io.IOException private void ScrambleFile(File file) { LabelScanStoreTest.scrambleFile(Random.random(), file); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldStayCorrectAfterRandomModifications() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldStayCorrectAfterRandomModifications() { // GIVEN using (GBPTree <KEY, VALUE> index = CreateIndex()) { IComparer <KEY> keyComparator = _layout; IDictionary <KEY, VALUE> data = new SortedDictionary <KEY, VALUE>(keyComparator); int count = 100; int totalNumberOfRounds = 10; for (int i = 0; i < count; i++) { data[RandomKey(Random.random())] = RandomValue(Random.random()); } // WHEN using (Writer <KEY, VALUE> writer = CreateWriter(index)) { foreach (KeyValuePair <KEY, VALUE> entry in data.SetOfKeyValuePairs()) { writer.Put(entry.Key, entry.Value); } } for (int round = 0; round < totalNumberOfRounds; round++) { // THEN for (int i = 0; i < count; i++) { KEY first = RandomKey(Random.random()); KEY second = RandomKey(Random.random()); KEY from; KEY to; if (_layout.keySeed(first) < _layout.keySeed(second)) { from = first; to = second; } else { from = second; to = first; } IDictionary <KEY, VALUE> expectedHits = expectedHits(data, from, to, keyComparator); using (RawCursor <Hit <KEY, VALUE>, IOException> result = index.Seek(from, to)) { while (result.Next()) { KEY key = result.get().key(); if (expectedHits.Remove(key) == null) { fail("Unexpected hit " + key + " when searching for " + from + " - " + to); } assertTrue(keyComparator.Compare(key, from) >= 0); if (keyComparator.Compare(from, to) != 0) { assertTrue(keyComparator.Compare(key, to) < 0); } } if (expectedHits.Count > 0) { fail("There were results which were expected to be returned, but weren't:" + expectedHits + " when searching range " + from + " - " + to); } } } index.Checkpoint(Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited); RandomlyModifyIndex(index, data, Random.random(), (double)round / totalNumberOfRounds); } // and finally index.ConsistencyCheck(); } }