//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void consistencyCheckerLogUseSystemTimezoneIfConfigurable() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ConsistencyCheckerLogUseSystemTimezoneIfConfigurable() { TimeZone defaultTimeZone = TimeZone.Default; try { ConsistencyCheckService service = mock(typeof(ConsistencyCheckService)); Mockito.when(service.runFullConsistencyCheck(any(typeof(DatabaseLayout)), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(typeof(ConsistencyFlags)))).then(invocationOnMock => { LogProvider provider = invocationOnMock.getArgument(3); provider.getLog("test").info("testMessage"); return(ConsistencyCheckService.Result.success(new File(StringUtils.EMPTY))); }); File storeDir = _testDirectory.directory(); File configFile = _testDirectory.file(Config.DEFAULT_CONFIG_FILE_NAME); Properties properties = new Properties(); properties.setProperty(GraphDatabaseSettings.db_timezone.name(), LogTimeZone.SYSTEM.name()); properties.store(new StreamWriter(configFile), null); string[] args = new string[] { storeDir.Path, "-config", configFile.Path }; CheckLogRecordTimeZone(service, args, 5, "+0500"); CheckLogRecordTimeZone(service, args, -5, "-0500"); } finally { TimeZone.Default = defaultTimeZone; } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void databaseAndBackupAreMutuallyExclusive() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void DatabaseAndBackupAreMutuallyExclusive() { ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService)); Path homeDir = _testDir.directory("home").toPath(); CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService); when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null)); IncorrectUsage incorrectUsage = assertThrows(typeof(IncorrectUsage), () => checkConsistencyCommand.execute(new string[] { "--database=foo", "--backup=bar" })); assertEquals("Only one of '--database' and '--backup' can be specified.", incorrectUsage.Message); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void passesOnCheckParameters() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void PassesOnCheckParameters() { ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService)); Path homeDir = _testDir.directory("home").toPath(); CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService); when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null)); checkConsistencyCommand.Execute(new string[] { "--database=mydb", "--check-graph=false", "--check-indexes=false", "--check-index-structure=false", "--check-label-scan-store=false", "--check-property-owners=true" }); verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), eq(new ConsistencyFlags(false, false, false, false, true))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldCanonicalizeReportDirectory() throws java.io.IOException, org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException, org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldCanonicalizeReportDirectory() { ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService)); Path homeDir = _testDir.directory("home").toPath(); CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService); when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null)); checkConsistencyCommand.Execute(new string[] { "--database=mydb", "--report-dir=" + Paths.get("..", "bar") }); verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), eq((new File("../bar")).CanonicalFile), any(typeof(ConsistencyFlags))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void canRunOnBackup() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void CanRunOnBackup() { ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService)); DatabaseLayout backupLayout = _testDir.databaseLayout("backup"); Path homeDir = _testDir.directory("home").toPath(); CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService); when(consistencyCheckService.runFullConsistencyCheck(eq(backupLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null)); checkConsistencyCommand.Execute(new string[] { "--backup=" + backupLayout.DatabaseDirectory() }); verify(consistencyCheckService).runFullConsistencyCheck(eq(backupLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(), any(typeof(ConsistencyFlags))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void failsWhenInconsistenciesAreFound() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void FailsWhenInconsistenciesAreFound() { ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService)); Path homeDir = _testDir.directory("home").toPath(); File databasesFolder = GetDatabasesFolder(homeDir); CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService); DatabaseLayout databaseLayout = DatabaseLayout.of(databasesFolder, "mydb"); when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(true), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.failure(new File("/the/report/path"))); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => checkConsistencyCommand.execute(new string[] { "--database=mydb", "--verbose" })); assertThat(commandFailed.Message, containsString((new File("/the/report/path")).ToString())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void enablesVerbosity() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void EnablesVerbosity() { ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService)); Path homeDir = _testDir.directory("home").toPath(); File databasesFolder = GetDatabasesFolder(homeDir); CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService); DatabaseLayout databaseLayout = DatabaseLayout.of(databasesFolder, "mydb"); when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(true), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null)); checkConsistencyCommand.Execute(new string[] { "--database=mydb", "--verbose" }); verify(consistencyCheckService).runFullConsistencyCheck(eq(databaseLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(true), any(), any(typeof(ConsistencyFlags))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: ConsistencyCheckService.Result run(String... args) throws ToolFailureException internal virtual ConsistencyCheckService.Result Run(params string[] args) { Args arguments = Args.withFlags(VERBOSE).parse(args); File storeDir = DetermineStoreDirectory(arguments); Config tuningConfiguration = ReadConfiguration(arguments); bool verbose = IsVerbose(arguments); DatabaseLayout databaseLayout = DatabaseLayout.of(storeDir); CheckDbState(databaseLayout, tuningConfiguration); ZoneId logTimeZone = tuningConfiguration.Get(GraphDatabaseSettings.db_timezone).ZoneId; LogProvider logProvider = FormattedLogProvider.withZoneId(logTimeZone).toOutputStream(_systemOut); try { return(_consistencyCheckService.runFullConsistencyCheck(databaseLayout, tuningConfiguration, ProgressMonitorFactory.textual(_systemError), logProvider, _fs, verbose, new ConsistencyFlags(tuningConfiguration))); } catch (ConsistencyCheckIncompleteException e) { throw new ToolFailureException("Check aborted due to exception", e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void execute(String[] args) throws org.neo4j.commandline.admin.IncorrectUsage, org.neo4j.commandline.admin.CommandFailed public override void Execute(string[] args) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String database; string database; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final boolean verbose; bool verbose; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Optional<java.nio.file.Path> additionalConfigFile; Optional <Path> additionalConfigFile; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.nio.file.Path reportDir; Path reportDir; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Optional<java.nio.file.Path> backupPath; Optional <Path> backupPath; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final boolean checkGraph; bool checkGraph; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final boolean checkIndexes; bool checkIndexes; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final boolean checkIndexStructure; bool checkIndexStructure; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final boolean checkLabelScanStore; bool checkLabelScanStore; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final boolean checkPropertyOwners; bool checkPropertyOwners; try { database = _arguments.parse(args).get(ARG_DATABASE); backupPath = _arguments.getOptionalPath("backup"); verbose = _arguments.getBoolean("verbose"); additionalConfigFile = _arguments.getOptionalPath("additional-config"); reportDir = _arguments.getOptionalPath("report-dir").orElseThrow(() => new System.ArgumentException("report-dir must be a valid path")); } catch (System.ArgumentException e) { throw new IncorrectUsage(e.Message); } if (backupPath.Present) { if (_arguments.has(ARG_DATABASE)) { throw new IncorrectUsage("Only one of '--" + ARG_DATABASE + "' and '--backup' can be specified."); } if (!backupPath.get().toFile().Directory) { throw new CommandFailed(format("Specified backup should be a directory: %s", backupPath.get())); } } Config config = LoadNeo4jConfig(_homeDir, _configDir, database, LoadAdditionalConfig(additionalConfigFile)); try { // We can remove the loading from config file in 4.0 if (_arguments.has(CHECK_GRAPH)) { checkGraph = _arguments.getBoolean(CHECK_GRAPH); } else { checkGraph = config.Get(ConsistencyCheckSettings.ConsistencyCheckGraph); } if (_arguments.has(CHECK_INDEXES)) { checkIndexes = _arguments.getBoolean(CHECK_INDEXES); } else { checkIndexes = config.Get(ConsistencyCheckSettings.ConsistencyCheckIndexes); } if (_arguments.has(CHECK_INDEX_STRUCTURE)) { checkIndexStructure = _arguments.getBoolean(CHECK_INDEX_STRUCTURE); } else { checkIndexStructure = config.Get(ConsistencyCheckSettings.ConsistencyCheckIndexStructure); } if (_arguments.has(CHECK_LABEL_SCAN_STORE)) { checkLabelScanStore = _arguments.getBoolean(CHECK_LABEL_SCAN_STORE); } else { checkLabelScanStore = config.Get(ConsistencyCheckSettings.ConsistencyCheckLabelScanStore); } if (_arguments.has(CHECK_PROPERTY_OWNERS)) { checkPropertyOwners = _arguments.getBoolean(CHECK_PROPERTY_OWNERS); } else { checkPropertyOwners = config.Get(ConsistencyCheckSettings.ConsistencyCheckPropertyOwners); } } catch (System.ArgumentException e) { throw new IncorrectUsage(e.Message); } try { using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { File databaseDirectory = backupPath.map(Path.toFile).orElse(config.Get(database_path)); DatabaseLayout databaseLayout = DatabaseLayout.of(databaseDirectory); CheckDbState(databaseLayout, config); ZoneId logTimeZone = config.Get(GraphDatabaseSettings.db_timezone).ZoneId; // Only output progress indicator if a console receives the output ProgressMonitorFactory progressMonitorFactory = ProgressMonitorFactory.NONE; if (System.console() != null) { progressMonitorFactory = ProgressMonitorFactory.textual(System.out); } ConsistencyCheckService.Result consistencyCheckResult = _consistencyCheckService.runFullConsistencyCheck(databaseLayout, config, progressMonitorFactory, FormattedLogProvider.withZoneId(logTimeZone).toOutputStream(System.out), fileSystem, verbose, reportDir.toFile(), new ConsistencyFlags(checkGraph, checkIndexes, checkIndexStructure, checkLabelScanStore, checkPropertyOwners)); if (!consistencyCheckResult.Successful) { throw new CommandFailed(format("Inconsistencies found. See '%s' for details.", consistencyCheckResult.ReportFile())); } } } catch (Exception e) when(e is ConsistencyCheckIncompleteException || e is IOException) { throw new CommandFailed("Consistency checking failed." + e.Message, e); } }