Skip to content

Commit

Permalink
REFACTORING: changing method name to getBranchesByRepository in WebCl…
Browse files Browse the repository at this point in the history
…ient
  • Loading branch information
Janek1010 committed Feb 16, 2024
1 parent 385a6b1 commit 81eb148
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
public interface GithubClient {
Flux<Repository> getAllRepositoriesByUser(String username);

Flux<Branch> getAllBranches(Repository repository);
Flux<Branch> getBranchesByRepository(Repository repository);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Flux<Repository> getAllRepositoriesByUser(String username) {
}

@Override
public Flux<Branch> getAllBranches(Repository repository) {
public Flux<Branch> getBranchesByRepository(Repository repository) {
String uri = repository.branchesUrl().replace("{/branch}", "");
return webClient.get()
.uri(uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Flux<RepositoryDTO> getRepositoriesWithBranchesByUser(String username) {
}

public Flux<BranchDTO> getBranchesByRepository(Repository repository) {
return githubClient.getAllBranches(repository)
return githubClient.getBranchesByRepository(repository)
.map(branch -> new BranchDTO(branch.name(), branch.commit().sha()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void shouldReturnCorrectBranchesFlux() throws IOException {
);

//when
Flux<Branch> response = githubClient.getAllBranches(repositoryTested);
Flux<Branch> response = githubClient.getBranchesByRepository(repositoryTested);
// then
StepVerifier.create(response)
.recordWith(ArrayList::new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BranchDTO> branchesReturned = githubService.getBranchesByRepository(repositoryTested);

Expand Down Expand Up @@ -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<RepositoryDTO> result = githubService.getRepositoriesWithBranchesByUser(username);
Expand Down

0 comments on commit 81eb148

Please sign in to comment.