Rename classes (#1331)
This commit is contained in:
parent
62db91ef1f
commit
fde269c51e
@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class FooComponent {
|
public class FooService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FooRepository fooRepository;
|
private FooRepository fooRepository;
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.boot.service;
|
package org.baeldung.boot.service;
|
||||||
|
|
||||||
import org.baeldung.boot.components.FooComponent;
|
import org.baeldung.boot.components.FooService;
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.boot.model.Foo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@ -11,15 +11,15 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class FooService {
|
public class FooController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FooComponent fooComponent;
|
private FooService fooService;
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseEntity<?> getFooWithId(@PathVariable Integer id) throws Exception {
|
public ResponseEntity<?> getFooWithId(@PathVariable Integer id) throws Exception {
|
||||||
|
|
||||||
Foo foo = fooComponent.getFooWithId(id);
|
Foo foo = fooService.getFooWithId(id);
|
||||||
|
|
||||||
return new ResponseEntity<>(foo, HttpStatus.OK);
|
return new ResponseEntity<>(foo, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ public class FooService {
|
|||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public ResponseEntity<?> getFooWithName(@RequestParam String name) throws Exception {
|
public ResponseEntity<?> getFooWithName(@RequestParam String name) throws Exception {
|
||||||
|
|
||||||
Foo foo = fooComponent.getFooWithName(name);
|
Foo foo = fooService.getFooWithName(name);
|
||||||
|
|
||||||
return new ResponseEntity<>(foo, HttpStatus.OK);
|
return new ResponseEntity<>(foo, HttpStatus.OK);
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.boot;
|
package org.baeldung.boot;
|
||||||
|
|
||||||
import org.baeldung.boot.components.FooComponent;
|
import org.baeldung.boot.components.FooService;
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.boot.model.Foo;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -32,7 +32,7 @@ public class FooComponentTests {
|
|||||||
private TestRestTemplate testRestTemplate;
|
private TestRestTemplate testRestTemplate;
|
||||||
|
|
||||||
@SpyBean
|
@SpyBean
|
||||||
private FooComponent fooComponent;
|
private FooService fooService;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
@ -40,7 +40,7 @@ public class FooComponentTests {
|
|||||||
foo.setId(5);
|
foo.setId(5);
|
||||||
foo.setName("MOCKED_FOO");
|
foo.setName("MOCKED_FOO");
|
||||||
|
|
||||||
doReturn(foo).when(fooComponent).getFooWithId(anyInt());
|
doReturn(foo).when(fooService).getFooWithId(anyInt());
|
||||||
|
|
||||||
// doCallRealMethod().when(fooComponent).getFooWithName(anyString());
|
// doCallRealMethod().when(fooComponent).getFooWithName(anyString());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user