diff options
author | Benjamin Campomenosi <109955405+benjamin-campomenosi-sonarsource@users.noreply.github.com> | 2023-07-12 14:04:51 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-07-19 20:03:06 +0000 |
commit | 963ebc53266c3ebf6ec7a52b67a933adaaf3cf89 (patch) | |
tree | 37b7c580a9087d4ee22fc2dede285569f94efdfa /server/sonar-webserver-api | |
parent | f5ff20dbd80554f8bf51e7af68db868256e16bac (diff) | |
download | sonarqube-963ebc53266c3ebf6ec7a52b67a933adaaf3cf89.tar.gz sonarqube-963ebc53266c3ebf6ec7a52b67a933adaaf3cf89.zip |
SONAR-19850 Fix name of method in ProjectLifeCycleListeners
Diffstat (limited to 'server/sonar-webserver-api')
3 files changed, 19 insertions, 18 deletions
diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/project/ProjectLifeCycleListeners.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/project/ProjectLifeCycleListeners.java index 0a8c2238cb0..981237903e3 100644 --- a/server/sonar-webserver-api/src/main/java/org/sonar/server/project/ProjectLifeCycleListeners.java +++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/project/ProjectLifeCycleListeners.java @@ -40,7 +40,7 @@ public interface ProjectLifeCycleListeners { * This method ensures all {@link ProjectLifeCycleListener} implementations are called, even if one or more of * them fail with an exception. */ - void onProjectBranchesDeleted(Set<Project> projects); + void onProjectBranchesChanged(Set<Project> projects); /** * This method is called after the specified project's key has been changed and will call method diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/project/ProjectLifeCycleListenersImpl.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/project/ProjectLifeCycleListenersImpl.java index a7e96c110e1..9d98d0f80af 100644 --- a/server/sonar-webserver-api/src/main/java/org/sonar/server/project/ProjectLifeCycleListenersImpl.java +++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/project/ProjectLifeCycleListenersImpl.java @@ -61,7 +61,7 @@ public class ProjectLifeCycleListenersImpl implements ProjectLifeCycleListeners } @Override - public void onProjectBranchesDeleted(Set<Project> projects) { + public void onProjectBranchesChanged(Set<Project> projects) { checkNotNull(projects, "projects can't be null"); if (projects.isEmpty()) { return; diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/project/ProjectLifeCycleListenersImplTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/project/ProjectLifeCycleListenersImplTest.java index c73ef83e00e..600a3876564 100644 --- a/server/sonar-webserver-api/src/test/java/org/sonar/server/project/ProjectLifeCycleListenersImplTest.java +++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/project/ProjectLifeCycleListenersImplTest.java @@ -34,6 +34,7 @@ import org.mockito.Mockito; import static java.util.Collections.singleton; import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.same; @@ -126,39 +127,39 @@ public class ProjectLifeCycleListenersImplTest { } @Test - public void onProjectBranchesDeleted_throws_NPE_if_set_is_null() { - assertThatThrownBy(() -> underTestWithListeners.onProjectBranchesDeleted(null)) + public void onProjectBranchesChanged_throws_NPE_if_set_is_null() { + assertThatThrownBy(() -> underTestWithListeners.onProjectBranchesChanged(null)) .isInstanceOf(NullPointerException.class) .hasMessage("projects can't be null"); } @Test - public void onProjectBranchesDeleted_throws_NPE_if_set_is_null_even_if_no_listeners() { - assertThatThrownBy(() -> underTestNoListeners.onProjectBranchesDeleted(null)) + public void onProjectBranchesChanged_throws_NPE_if_set_is_null_even_if_no_listeners() { + assertThatThrownBy(() -> underTestNoListeners.onProjectBranchesChanged(null)) .isInstanceOf(NullPointerException.class) .hasMessage("projects can't be null"); } @Test - public void onProjectBranchesDeleted_has_no_effect_if_set_is_empty() { - underTestNoListeners.onProjectBranchesDeleted(Collections.emptySet()); + public void onProjectBranchesChanged_has_no_effect_if_set_is_empty() { + underTestNoListeners.onProjectBranchesChanged(Collections.emptySet()); - underTestWithListeners.onProjectBranchesDeleted(Collections.emptySet()); + underTestWithListeners.onProjectBranchesChanged(Collections.emptySet()); verifyNoInteractions(listener1, listener2, listener3); } @Test @UseDataProvider("oneOrManyProjects") - public void onProjectBranchesDeleted_does_not_fail_if_there_is_no_listener(Set<Project> projects) { - underTestNoListeners.onProjectBranchesDeleted(projects); + public void onProjectBranchesChanged_does_not_fail_if_there_is_no_listener(Set<Project> projects) { + assertThatNoException().isThrownBy(()-> underTestNoListeners.onProjectBranchesChanged(projects)); } @Test @UseDataProvider("oneOrManyProjects") - public void onProjectBranchesDeleted_calls_all_listeners_in_order_of_addition_to_constructor(Set<Project> projects) { + public void onProjectBranchesChanged_calls_all_listeners_in_order_of_addition_to_constructor(Set<Project> projects) { InOrder inOrder = Mockito.inOrder(listener1, listener2, listener3); - underTestWithListeners.onProjectBranchesDeleted(projects); + underTestWithListeners.onProjectBranchesChanged(projects); inOrder.verify(listener1).onProjectBranchesChanged(same(projects)); inOrder.verify(listener2).onProjectBranchesChanged(same(projects)); @@ -168,13 +169,13 @@ public class ProjectLifeCycleListenersImplTest { @Test @UseDataProvider("oneOrManyProjects") - public void onProjectBranchesDeleted_calls_all_listeners_even_if_one_throws_an_Exception(Set<Project> projects) { + public void onProjectBranchesChanged_calls_all_listeners_even_if_one_throws_an_Exception(Set<Project> projects) { InOrder inOrder = Mockito.inOrder(listener1, listener2, listener3); doThrow(new RuntimeException("Faking listener2 throwing an exception")) .when(listener2) .onProjectBranchesChanged(any()); - underTestWithListeners.onProjectBranchesDeleted(projects); + underTestWithListeners.onProjectBranchesChanged(projects); inOrder.verify(listener1).onProjectBranchesChanged(same(projects)); inOrder.verify(listener2).onProjectBranchesChanged(same(projects)); @@ -184,13 +185,13 @@ public class ProjectLifeCycleListenersImplTest { @Test @UseDataProvider("oneOrManyProjects") - public void onProjectBranchesDeleted_calls_all_listeners_even_if_one_throws_an_Error(Set<Project> projects) { + public void onProjectBranchesChanged_calls_all_listeners_even_if_one_throws_an_Error(Set<Project> projects) { InOrder inOrder = Mockito.inOrder(listener1, listener2, listener3); doThrow(new Error("Faking listener2 throwing an Error")) .when(listener2) .onProjectBranchesChanged(any()); - underTestWithListeners.onProjectBranchesDeleted(projects); + underTestWithListeners.onProjectBranchesChanged(projects); inOrder.verify(listener1).onProjectBranchesChanged(same(projects)); inOrder.verify(listener2).onProjectBranchesChanged(same(projects)); @@ -240,7 +241,7 @@ public class ProjectLifeCycleListenersImplTest { @Test @UseDataProvider("oneOrManyRekeyedProjects") public void onProjectsRekeyed_does_not_fail_if_there_is_no_listener(Set<RekeyedProject> projects) { - underTestNoListeners.onProjectsRekeyed(projects); + assertThatNoException().isThrownBy(() -> underTestNoListeners.onProjectsRekeyed(projects)); } @Test |