//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.function.ThrowingFunction<org.neo4j.kernel.impl.transaction.log.LogPosition,org.neo4j.kernel.impl.transaction.log.TransactionCursor,java.io.IOException> log(int... transactionCounts) throws java.io.IOException private ThrowingFunction <LogPosition, TransactionCursor, IOException> Log(params int[] transactionCounts) { long baseOffset = LogPosition.start(0).ByteOffset; //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.function.ThrowingFunction<org.neo4j.kernel.impl.transaction.log.LogPosition,org.neo4j.kernel.impl.transaction.log.TransactionCursor,java.io.IOException> result = mock(org.neo4j.function.ThrowingFunction.class); ThrowingFunction <LogPosition, TransactionCursor, IOException> result = mock(typeof(ThrowingFunction)); AtomicLong txId = new AtomicLong(0); CommittedTransactionRepresentation[][] logs = new CommittedTransactionRepresentation[transactionCounts.Length][]; for (int logVersion = 0; logVersion < transactionCounts.Length; logVersion++) { logs[logVersion] = Transactions(transactionCounts[logVersion], txId); } when(result.Apply(any(typeof(LogPosition)))).thenAnswer(invocation => { LogPosition position = invocation.getArgument(0); if (position == null) { // A mockito issue when calling the "when" methods, I believe return(null); } // For simplicity the offset means, in this test, the array offset CommittedTransactionRepresentation[] transactions = logs[toIntExact(position.LogVersion)]; CommittedTransactionRepresentation[] subset = copyOfRange(transactions, toIntExact(position.ByteOffset - baseOffset), transactions.Length); ArrayUtil.reverse(subset); return(given(subset)); }); return(result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMakeFromCanonical() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage, org.neo4j.dbms.archive.IncorrectFormat //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMakeFromCanonical() { Path dataDir = _testDirectory.directory("some-other-path").toPath(); Path databaseDir = dataDir.resolve("databases/foo.db"); Files.createDirectories(databaseDir); Files.write(_configDir.resolve(Config.DEFAULT_CONFIG_FILE_NAME), singletonList(FormatProperty(data_directory, dataDir))); (new LoadCommand(_homeDir, _configDir, _loader)).execute(ArrayUtil.concat(new string[] { "--database=foo.db", "--from=foo.dump" })); verify(_loader).load(eq(Paths.get((new File("foo.dump")).CanonicalPath)), any(), any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAddMissingLabels() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAddMissingLabels() { // GIVEN string[] toAdd = new string[] { "Add1", "Add2" }; InputEntityVisitor node = additiveLabels(toAdd).apply(_entity); // WHEN string[] nodeLabels = new string[] { "SomeOther" }; node(node, "source", 1, 0, "id", NO_PROPERTIES, null, nodeLabels, null); // THEN assertEquals(asSet(ArrayUtil.union(toAdd, nodeLabels)), asSet(_entity.labels())); }
internal static void ValidateQuery(IndexCapability capability, IndexOrder indexOrder, IndexQuery[] predicates) { if (indexOrder != IndexOrder.NONE) { ValueCategory valueCategory = predicates[0].ValueGroup().category(); IndexOrder[] orderCapability = capability.OrderCapability(valueCategory); if (!ArrayUtil.contains(orderCapability, indexOrder)) { orderCapability = ArrayUtils.add(orderCapability, IndexOrder.NONE); throw new System.NotSupportedException(format("Tried to query index with unsupported order %s. Supported orders for query %s are %s.", indexOrder, Arrays.ToString(predicates), Arrays.ToString(orderCapability))); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void execute(String database, String... otherArgs) throws org.neo4j.commandline.admin.IncorrectUsage, org.neo4j.commandline.admin.CommandFailed private void Execute(string database, params string[] otherArgs) { (new LoadCommand(_homeDir, _configDir, _loader)).execute(ArrayUtil.concat(new string[] { "--database=" + database, "--from=" + _archive }, otherArgs)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SafeVarargs static NodeRecordCheck forDenseNodes(RecordField<org.neo4j.kernel.impl.store.record.NodeRecord,org.neo4j.consistency.report.ConsistencyReport_NodeConsistencyReport>... additional) internal static NodeRecordCheck ForDenseNodes(params RecordField <NodeRecord, ConsistencyReport_NodeConsistencyReport>[] additional) { RecordField <NodeRecord, ConsistencyReport_NodeConsistencyReport>[] basic = ArrayUtil.array <RecordField <NodeRecord, ConsistencyReport_NodeConsistencyReport> >(RelationshipGroupField.NextGroup, LabelsField.Labels); return(new NodeRecordCheck(union(basic, additional))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadConsistentPropertyValues() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadConsistentPropertyValues() { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Node[] nodes = new Node[10]; Node[] nodes = new Node[10]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String[] keys = new String[] {"1", "2", "3"}; string[] keys = new string[] { "1", "2", "3" }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String[] values = new String[] { longString('a'), longString('b'), longString('c')}; string[] values = new string[] { LongString('a'), LongString('b'), LongString('c') }; using (Transaction tx = Db.beginTx()) { for (int i = 0; i < nodes.Length; i++) { nodes[i] = Db.createNode(); foreach (string key in keys) { nodes[i].SetProperty(key, values[0]); } } tx.Success(); } int updaters = 10; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicLong updatersDone = new java.util.concurrent.atomic.AtomicLong(updaters); AtomicLong updatersDone = new AtomicLong(updaters); Race race = new Race(); for (int i = 0; i < updaters; i++) { // Changers race.AddContestant(() => { try { ThreadLocalRandom random = ThreadLocalRandom.current(); for (int j = 0; j < 100; j++) { Node node = nodes[random.Next(nodes.Length)]; string key = keys[random.Next(keys.Length)]; using (Transaction tx = Db.beginTx()) { node.RemoveProperty(key); tx.Success(); } using (Transaction tx = Db.beginTx()) { node.SetProperty(key, values[random.Next(values.Length)]); tx.Success(); } } } finally { updatersDone.decrementAndGet(); } }); } for (int i = 0; i < 100; i++) { // Readers race.AddContestant(() => { ThreadLocalRandom random = ThreadLocalRandom.current(); while (updatersDone.get() > 0) { using (Transaction tx = Db.beginTx()) { string value = ( string )nodes[random.Next(nodes.Length)].getProperty(keys[random.Next(keys.Length)], null); assertTrue(value, string.ReferenceEquals(value, null) || ArrayUtil.contains(values, value)); tx.Success(); } } }); } // WHEN race.Go(); }