From 51a24853dc5a6d0f432d0680f04f0a2c14797f4e Mon Sep 17 00:00:00 2001 From: Gabriela Trutan Date: Wed, 25 Sep 2024 12:03:17 +0200 Subject: [PATCH] SLVS-1396 Rename method --- .../Migration/BindingToConnectionMigrationTests.cs | 6 +++--- .../Migration/ConnectedModeMigrationTests.cs | 10 +++++----- .../Persistence/ServerConnectionsRepositoryTests.cs | 4 ++-- .../Migration/BindingToConnectionMigration.cs | 2 +- src/ConnectedMode/Migration/ConnectedModeMigration.cs | 2 +- .../Persistence/ServerConnectionsRepository.cs | 2 +- src/Core/Binding/IServerConnectionsRepository.cs | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ConnectedMode.UnitTests/Migration/BindingToConnectionMigrationTests.cs b/src/ConnectedMode.UnitTests/Migration/BindingToConnectionMigrationTests.cs index 94e723027..be465df1f 100644 --- a/src/ConnectedMode.UnitTests/Migration/BindingToConnectionMigrationTests.cs +++ b/src/ConnectedMode.UnitTests/Migration/BindingToConnectionMigrationTests.cs @@ -95,11 +95,11 @@ public async Task MigrateBindingToServerConnectionIfNeeded_RunsOnBackgroundThrea [TestMethod] public async Task MigrateBindingToServerConnectionIfNeeded_ConnectionsStorageFileExists_ShouldNotMigrate() { - serverConnectionsRepository.IsConnectionsFileExisting().Returns(true); + serverConnectionsRepository.ConnectionsFileExists().Returns(true); await testSubject.MigrateAllBindingsToServerConnectionsIfNeededAsync(); - serverConnectionsRepository.Received(1).IsConnectionsFileExisting(); + serverConnectionsRepository.Received(1).ConnectionsFileExists(); serverConnectionsRepository.DidNotReceiveWithAnyArgs().TryAdd(default); unintrusiveBindingPathProvider.DidNotReceive().GetBindingPaths(); } @@ -113,7 +113,7 @@ public async Task MigrateBindingToServerConnectionIfNeeded_ConnectionsStorageDoe Received.InOrder(() => { - serverConnectionsRepository.IsConnectionsFileExisting(); + serverConnectionsRepository.ConnectionsFileExists(); logger.WriteLine(MigrationStrings.ConnectionMigration_StartMigration); unintrusiveBindingPathProvider.GetBindingPaths(); serverConnectionsRepository.TryAdd(Arg.Any()); diff --git a/src/ConnectedMode.UnitTests/Migration/ConnectedModeMigrationTests.cs b/src/ConnectedMode.UnitTests/Migration/ConnectedModeMigrationTests.cs index cb2f49ca6..c786ff72a 100644 --- a/src/ConnectedMode.UnitTests/Migration/ConnectedModeMigrationTests.cs +++ b/src/ConnectedMode.UnitTests/Migration/ConnectedModeMigrationTests.cs @@ -347,7 +347,7 @@ public async Task Migrate_ConnectionDoesNotExist_CannotAdd_DoesNotCreateConnecti var unintrusiveBindingController = new Mock(); var convertedConnection = ServerConnection.FromBoundSonarQubeProject(AnyBoundProject); var serverConnectionsRepositoryMock = new Mock(); - serverConnectionsRepositoryMock.Setup(x => x.IsConnectionsFileExisting()).Returns(true); + serverConnectionsRepositoryMock.Setup(x => x.ConnectionsFileExists()).Returns(true); serverConnectionsRepositoryMock.Setup(x => x.TryAdd(convertedConnection)).Returns(false); var testSubject = CreateTestSubject(unintrusiveBindingController: unintrusiveBindingController.Object, serverConnectionsRepository: serverConnectionsRepositoryMock.Object); @@ -371,7 +371,7 @@ public async Task Migrate_ConnectionDoesNotExist_Throws_DoesNotCreateConnection( var unintrusiveBindingController = new Mock(); var convertedConnection = ServerConnection.FromBoundSonarQubeProject(AnyBoundProject); var serverConnectionsRepositoryMock = new Mock(); - serverConnectionsRepositoryMock.Setup(x => x.IsConnectionsFileExisting()).Returns(true); + serverConnectionsRepositoryMock.Setup(x => x.ConnectionsFileExists()).Returns(true); serverConnectionsRepositoryMock.Setup(x => x.TryAdd(convertedConnection)).Throws(new Exception()); var testSubject = CreateTestSubject(unintrusiveBindingController: unintrusiveBindingController.Object, serverConnectionsRepository: serverConnectionsRepositoryMock.Object); @@ -400,7 +400,7 @@ public async Task Migrate_ConnectionsJsonFileDoesNotExistAndNewBindingsExist_Doe unintrusiveBindingController: unintrusiveBindingControllerMock.Object, unintrusiveBindingPathProvider: bindingPathProvider.Object, logger:logger.Object); - serverConnectionsRepositoryMock.Setup(mock => mock.IsConnectionsFileExisting()).Returns(false); + serverConnectionsRepositoryMock.Setup(mock => mock.ConnectionsFileExists()).Returns(false); bindingPathProvider.Setup(mock => mock.GetBindingPaths()).Returns(["binding1"]); await testSubject.MigrateAsync(AnyBoundProject, Mock.Of>(), false, CancellationToken.None); @@ -428,7 +428,7 @@ public async Task Migrate_ConnectionsJsonFileDoesNotExistAndNoNewBindingsExist_M unintrusiveBindingController: unintrusiveBindingControllerMock.Object, unintrusiveBindingPathProvider:bindingPathProvider.Object, logger: logger.Object); - serverConnectionsRepositoryMock.Setup(mock => mock.IsConnectionsFileExisting()).Returns(false); + serverConnectionsRepositoryMock.Setup(mock => mock.ConnectionsFileExists()).Returns(false); bindingPathProvider.Setup(mock => mock.GetBindingPaths()).Returns([]); await testSubject.MigrateAsync(AnyBoundProject, Mock.Of>(), false, CancellationToken.None); @@ -550,7 +550,7 @@ private static Mock CreateServerConnectionsReposit { var serverConnectionsRepositoryMock = new Mock(); serverConnectionsRepositoryMock.Setup(x => x.TryAdd(It.IsAny())).Returns(true); - serverConnectionsRepositoryMock.Setup(x => x.IsConnectionsFileExisting()).Returns(true); + serverConnectionsRepositoryMock.Setup(x => x.ConnectionsFileExists()).Returns(true); return serverConnectionsRepositoryMock; } diff --git a/src/ConnectedMode.UnitTests/Persistence/ServerConnectionsRepositoryTests.cs b/src/ConnectedMode.UnitTests/Persistence/ServerConnectionsRepositoryTests.cs index 8276f17eb..3afb6587f 100644 --- a/src/ConnectedMode.UnitTests/Persistence/ServerConnectionsRepositoryTests.cs +++ b/src/ConnectedMode.UnitTests/Persistence/ServerConnectionsRepositoryTests.cs @@ -543,11 +543,11 @@ public void TryUpdateCredentialsById_SonarQubeConnectionExists_UpdatesCredential [TestMethod] [DataRow(true)] [DataRow(false)] - public void IsConnectionsFileExisting_ReturnsTrueOnlyIfTheConnectionsFileExists(bool fileExists) + public void ConnectionsFileExists_ReturnsTrueOnlyIfTheConnectionsFileExists(bool fileExists) { fileSystem.File.Exists(Arg.Any()).Returns(fileExists); - var result = testSubject.IsConnectionsFileExisting(); + var result = testSubject.ConnectionsFileExists(); result.Should().Be(fileExists); } diff --git a/src/ConnectedMode/Migration/BindingToConnectionMigration.cs b/src/ConnectedMode/Migration/BindingToConnectionMigration.cs index 57e1c7c05..0591663af 100644 --- a/src/ConnectedMode/Migration/BindingToConnectionMigration.cs +++ b/src/ConnectedMode/Migration/BindingToConnectionMigration.cs @@ -86,7 +86,7 @@ public Task MigrateAllBindingsToServerConnectionsIfNeededAsync() private void MigrateBindingToServerConnectionIfNeeded() { - if (serverConnectionsRepository.IsConnectionsFileExisting()) + if (serverConnectionsRepository.ConnectionsFileExists()) { return; } diff --git a/src/ConnectedMode/Migration/ConnectedModeMigration.cs b/src/ConnectedMode/Migration/ConnectedModeMigration.cs index 0b2d84076..270fca0a9 100644 --- a/src/ConnectedMode/Migration/ConnectedModeMigration.cs +++ b/src/ConnectedMode/Migration/ConnectedModeMigration.cs @@ -283,7 +283,7 @@ private ServerConnection GetServerConnectionWithMigration(BoundSonarQubeProject // if the file doesn't exist, creating it now will prevent the migration of all existing bindings. // The order being important, we throw an exception. For more info see IBindingToConnectionMigration // But if there are no bindings in the new format, then creating the connections file is safe, because the new migration did not do anything in this case - if (!serverConnectionsRepository.IsConnectionsFileExisting() && unintrusiveBindingPathProvider.GetBindingPaths().Any()) + if (!serverConnectionsRepository.ConnectionsFileExists() && unintrusiveBindingPathProvider.GetBindingPaths().Any()) { logger.WriteLine(MigrationStrings.ConnectionsJson_DoesNotExist); return proposedConnection; diff --git a/src/ConnectedMode/Persistence/ServerConnectionsRepository.cs b/src/ConnectedMode/Persistence/ServerConnectionsRepository.cs index 4e4b737d1..3578bc375 100644 --- a/src/ConnectedMode/Persistence/ServerConnectionsRepository.cs +++ b/src/ConnectedMode/Persistence/ServerConnectionsRepository.cs @@ -137,7 +137,7 @@ public bool TryUpdateCredentialsById(string connectionId, ICredentials credentia return false; } - public bool IsConnectionsFileExisting() => fileSystem.File.Exists(connectionsStorageFilePath); + public bool ConnectionsFileExists() => fileSystem.File.Exists(connectionsStorageFilePath); private bool TryAddConnection(List connections, ServerConnection connection) { diff --git a/src/Core/Binding/IServerConnectionsRepository.cs b/src/Core/Binding/IServerConnectionsRepository.cs index c73fecb30..13a859b1b 100644 --- a/src/Core/Binding/IServerConnectionsRepository.cs +++ b/src/Core/Binding/IServerConnectionsRepository.cs @@ -28,5 +28,5 @@ public interface IServerConnectionsRepository bool TryDelete(string connectionId); bool TryUpdateSettingsById(string connectionId, ServerConnectionSettings connectionSettings); bool TryUpdateCredentialsById(string connectionId, ICredentials credentials); - bool IsConnectionsFileExisting(); + bool ConnectionsFileExists(); }