Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f1519a2

Browse files
author
Rajeev Kumar Singh
committed
Refactoring
1 parent 9075a04 commit f1519a2

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ build/
2121
nbbuild/
2222
dist/
2323
nbdist/
24-
.nb-gradle/
24+
.nb-gradle/
25+
26+
secret.txt

‎src/main/java/com/example/webclientdemo/GithubClient.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,38 @@ public GithubClient(AppProperties appProperties) {
4141
}
4242

4343

44-
public Flux<GithubRepo> listRepositories() {
44+
public Flux<GithubRepo> listGithubRepositories() {
4545
return webClient.get()
4646
.uri("/user/repos?sort={sortField}&direction={sortDirection}", "updated", "desc")
4747
.exchange()
4848
.flatMapMany(clientResponse -> clientResponse.bodyToFlux(GithubRepo.class));
4949

5050
}
5151

52-
public Mono<GithubRepo> createRepository(RepoRequest repoRequest) {
52+
public Mono<GithubRepo> createGithubRepository(RepoRequest repoRequest) {
5353
return webClient.post()
5454
.uri("/user/repos")
5555
.body(Mono.just(repoRequest), RepoRequest.class)
5656
.retrieve()
5757
.bodyToMono(GithubRepo.class);
5858
}
5959

60-
public Mono<GithubRepo> getRepository(String owner, String repo) {
60+
public Mono<GithubRepo> getGithubRepository(String owner, String repo) {
6161
return webClient.get()
6262
.uri("/repos/{owner}/{repo}", owner, repo)
6363
.retrieve()
6464
.bodyToMono(GithubRepo.class);
6565
}
6666

67-
public Mono<GithubRepo> editRepository(String owner, String repo, RepoRequest repoRequest) {
67+
public Mono<GithubRepo> editGithubRepository(String owner, String repo, RepoRequest repoRequest) {
6868
return webClient.patch()
6969
.uri("/repos/{owner}/{repo}", owner, repo)
7070
.body(BodyInserters.fromObject(repoRequest))
7171
.retrieve()
7272
.bodyToMono(GithubRepo.class);
7373
}
7474

75-
public Mono<Void> deleteRepository(String owner, String repo) {
75+
public Mono<Void> deleteGithubRepository(String owner, String repo) {
7676
return webClient.delete()
7777
.uri("/repos/{owner}/{repo}", owner, repo)
7878
.retrieve()

‎src/main/java/com/example/webclientdemo/GithubController.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ public class GithubController {
3030
private static final Logger logger = LoggerFactory.getLogger(GithubController.class);
3131

3232
@GetMapping("/repos")
33-
public Flux<GithubRepo> listRepositories() {
34-
return githubClient.listRepositories();
33+
public Flux<GithubRepo> listGithubRepositories() {
34+
return githubClient.listGithubRepositories();
3535
}
3636

3737
@PostMapping("/repos")
38-
public Mono<GithubRepo> createRepository(@RequestBody RepoRequest repoRequest) {
39-
return githubClient.createRepository(repoRequest);
38+
public Mono<GithubRepo> createGithubRepository(@RequestBody RepoRequest repoRequest) {
39+
return githubClient.createGithubRepository(repoRequest);
4040
}
4141

4242
@GetMapping("/repos/{repo}")
43-
public Mono<GithubRepo> getRepository(@PathVariable String repo) {
44-
return githubClient.getRepository(appProperties.getGithub().getUsername(), repo);
43+
public Mono<GithubRepo> getGithubRepository(@PathVariable String repo) {
44+
return githubClient.getGithubRepository(appProperties.getGithub().getUsername(), repo);
4545
}
4646

4747
@PatchMapping("/repos/{repo}")
48-
public Mono<GithubRepo> editRepository(@PathVariable String repo, @Valid @RequestBody RepoRequest repoRequest) {
49-
return githubClient.editRepository(appProperties.getGithub().getUsername(), repo, repoRequest);
48+
public Mono<GithubRepo> editGithubRepository(@PathVariable String repo, @Valid @RequestBody RepoRequest repoRequest) {
49+
return githubClient.editGithubRepository(appProperties.getGithub().getUsername(), repo, repoRequest);
5050
}
5151

5252
@DeleteMapping("/repos/{repo}")
53-
public Mono<Void> deleteRepository(@PathVariable String repo) {
54-
return githubClient.deleteRepository(appProperties.getGithub().getUsername(), repo);
53+
public Mono<Void> deleteGithubRepository(@PathVariable String repo) {
54+
return githubClient.deleteGithubRepository(appProperties.getGithub().getUsername(), repo);
5555
}
5656

5757

‎src/test/java/com/example/webclientdemo/WebclientDemoApplicationTests.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class WebclientDemoApplicationTests {
2121
private WebTestClient webTestClient;
2222

2323
@Test
24-
public void testCreateRepository() {
24+
public void testCreateGithubRepository() {
2525
RepoRequest repoRequest = new RepoRequest("test-webclient-repository", "Repository created for testing WebClient");
2626

2727
webTestClient.post().uri("/api/repos")
@@ -37,7 +37,7 @@ public void testCreateRepository() {
3737
}
3838

3939
@Test
40-
public void testGetAllRepositories() {
40+
public void testGetAllGithubRepositories() {
4141
webTestClient.get().uri("/api/repos")
4242
.accept(MediaType.APPLICATION_JSON_UTF8)
4343
.exchange()
@@ -47,7 +47,7 @@ public void testGetAllRepositories() {
4747
}
4848

4949
@Test
50-
public void testGetSingleRepository() {
50+
public void testGetSingleGithubRepository() {
5151
webTestClient.get()
5252
.uri("/api/repos/{repo}", "test-webclient-repository")
5353
.exchange()
@@ -58,7 +58,7 @@ public void testGetSingleRepository() {
5858
}
5959

6060
@Test
61-
public void testEditRepository() {
61+
public void testEditGithubRepository() {
6262
RepoRequest newRepoDetails = new RepoRequest("updated-webclient-repository", "Updated name and description");
6363
webTestClient.patch()
6464
.uri("/api/repos/{repo}", "test-webclient-repository")
@@ -73,7 +73,7 @@ public void testEditRepository() {
7373
}
7474

7575
@Test
76-
public void testDeleteRepository() {
76+
public void testDeleteGithubRepository() {
7777
webTestClient.delete()
7878
.uri("/api/repos/{repo}", "updated-webclient-repository")
7979
.exchange()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /