diff --git a/src/main/java/org/example/githubservice/client/api/GithubClient.java b/src/main/java/org/example/githubservice/client/api/GithubClient.java index b4fc397..342f379 100644 --- a/src/main/java/org/example/githubservice/client/api/GithubClient.java +++ b/src/main/java/org/example/githubservice/client/api/GithubClient.java @@ -7,5 +7,5 @@ public interface GithubClient { Flux getAllRepositoriesByUser(String username); - Flux getAllBranches(Repository repository); + Flux getBranchesByRepository(Repository repository); } diff --git a/src/main/java/org/example/githubservice/client/impl/GithubWebClient.java b/src/main/java/org/example/githubservice/client/impl/GithubWebClient.java index 9d11a6c..935cfee 100644 --- a/src/main/java/org/example/githubservice/client/impl/GithubWebClient.java +++ b/src/main/java/org/example/githubservice/client/impl/GithubWebClient.java @@ -34,7 +34,7 @@ public Flux getAllRepositoriesByUser(String username) { } @Override - public Flux getAllBranches(Repository repository) { + public Flux getBranchesByRepository(Repository repository) { String uri = repository.branchesUrl().replace("{/branch}", ""); return webClient.get() .uri(uri) diff --git a/src/main/java/org/example/githubservice/service/GithubService.java b/src/main/java/org/example/githubservice/service/GithubService.java index f35828b..2137933 100644 --- a/src/main/java/org/example/githubservice/service/GithubService.java +++ b/src/main/java/org/example/githubservice/service/GithubService.java @@ -24,7 +24,7 @@ public Flux getRepositoriesWithBranchesByUser(String username) { } public Flux getBranchesByRepository(Repository repository) { - return githubClient.getAllBranches(repository) + return githubClient.getBranchesByRepository(repository) .map(branch -> new BranchDTO(branch.name(), branch.commit().sha())); } } diff --git a/src/test/java/org/example/githubservice/client/GithubWebClientTest.java b/src/test/java/org/example/githubservice/client/GithubWebClientTest.java index 31793df..0d05dd6 100644 --- a/src/test/java/org/example/githubservice/client/GithubWebClientTest.java +++ b/src/test/java/org/example/githubservice/client/GithubWebClientTest.java @@ -87,7 +87,7 @@ void shouldReturnCorrectBranchesFlux() throws IOException { ); //when - Flux response = githubClient.getAllBranches(repositoryTested); + Flux response = githubClient.getBranchesByRepository(repositoryTested); // then StepVerifier.create(response) .recordWith(ArrayList::new) diff --git a/src/test/java/org/example/githubservice/service/GithubServiceTest.java b/src/test/java/org/example/githubservice/service/GithubServiceTest.java index e004bac..166aa00 100644 --- a/src/test/java/org/example/githubservice/service/GithubServiceTest.java +++ b/src/test/java/org/example/githubservice/service/GithubServiceTest.java @@ -40,7 +40,7 @@ void testGetListOfBranchesDTO() { Branch branch1 = new Branch("branch1", new Commit("123")); Branch branch2 = new Branch("branch2", new Commit("321")); - when(githubClient.getAllBranches(any())).thenReturn(Flux.just(branch1, branch2)); + when(githubClient.getBranchesByRepository(any())).thenReturn(Flux.just(branch1, branch2)); Flux branchesReturned = githubService.getBranchesByRepository(repositoryTested); @@ -69,8 +69,8 @@ void testGetRepositoriesWithBranchesByUser() { // when when(githubClient.getAllRepositoriesByUser(username)).thenReturn(Flux.just(repository1, repository2)); - when(githubClient.getAllBranches(repository1)).thenReturn(Flux.fromIterable(branches1)); - when(githubClient.getAllBranches(repository2)).thenReturn(Flux.fromIterable(branches2)); + when(githubClient.getBranchesByRepository(repository1)).thenReturn(Flux.fromIterable(branches1)); + when(githubClient.getBranchesByRepository(repository2)).thenReturn(Flux.fromIterable(branches2)); // then Flux result = githubService.getRepositoriesWithBranchesByUser(username);