Skip to content

Commit fde269c

Browse files
authored
Rename classes (eugenp#1331)
1 parent 62db91e commit fde269c

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

spring-boot/src/main/java/org/baeldung/boot/components/FooComponent.java renamed to spring-boot/src/main/java/org/baeldung/boot/components/FooService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.springframework.stereotype.Component;
77

88
@Component
9-
public class FooComponent {
9+
public class FooService {
1010

1111
@Autowired
1212
private FooRepository fooRepository;

spring-boot/src/main/java/org/baeldung/boot/service/FooService.java renamed to spring-boot/src/main/java/org/baeldung/boot/service/FooController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.baeldung.boot.service;
22

3-
import org.baeldung.boot.components.FooComponent;
3+
import org.baeldung.boot.components.FooService;
44
import org.baeldung.boot.model.Foo;
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.http.HttpStatus;
@@ -11,23 +11,23 @@
1111
import org.springframework.web.bind.annotation.RestController;
1212

1313
@RestController
14-
public class FooService {
14+
public class FooController {
1515

1616
@Autowired
17-
private FooComponent fooComponent;
17+
private FooService fooService;
1818

1919
@GetMapping("/{id}")
2020
public ResponseEntity<?> getFooWithId(@PathVariable Integer id) throws Exception {
2121

22-
Foo foo = fooComponent.getFooWithId(id);
22+
Foo foo = fooService.getFooWithId(id);
2323

2424
return new ResponseEntity<>(foo, HttpStatus.OK);
2525
}
2626

2727
@GetMapping("/")
2828
public ResponseEntity<?> getFooWithName(@RequestParam String name) throws Exception {
2929

30-
Foo foo = fooComponent.getFooWithName(name);
30+
Foo foo = fooService.getFooWithName(name);
3131

3232
return new ResponseEntity<>(foo, HttpStatus.OK);
3333
}

‎spring-boot/src/test/java/org/baeldung/boot/FooComponentTests.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.baeldung.boot;
22

3-
import org.baeldung.boot.components.FooComponent;
3+
import org.baeldung.boot.components.FooService;
44
import org.baeldung.boot.model.Foo;
55
import org.junit.Before;
66
import org.junit.Test;
@@ -32,15 +32,15 @@ public class FooComponentTests {
3232
private TestRestTemplate testRestTemplate;
3333

3434
@SpyBean
35-
private FooComponent fooComponent;
35+
private FooService fooService;
3636

3737
@Before
3838
public void init() throws Exception {
3939
Foo foo = new Foo();
4040
foo.setId(5);
4141
foo.setName("MOCKED_FOO");
4242

43-
doReturn(foo).when(fooComponent).getFooWithId(anyInt());
43+
doReturn(foo).when(fooService).getFooWithId(anyInt());
4444

4545
// doCallRealMethod().when(fooComponent).getFooWithName(anyString());
4646
}

0 commit comments

Comments
 (0)