File tree 5 files changed +43
-2
lines changed
java/guru/springframework/spring6restmvc
test/java/guru/springframework/spring6restmvc/controller
5 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 1
1
package guru .springframework .spring6restmvc .controller ;
2
2
3
+ import guru .springframework .spring6restmvc .model .Beer ;
3
4
import guru .springframework .spring6restmvc .services .BeerService ;
4
5
import lombok .AllArgsConstructor ;
6
+ import lombok .extern .slf4j .Slf4j ;
5
7
import org .springframework .stereotype .Controller ;
6
8
9
+ import java .util .UUID ;
10
+
7
11
/**
8
12
* Created by jt, Spring Framework Guru.
9
13
*/
14
+ @ Slf4j
10
15
@ AllArgsConstructor
11
16
@ Controller
12
17
public class BeerController {
13
18
private final BeerService beerService ;
14
19
20
+ public Beer getBeerById (UUID id ){
21
+
22
+ log .debug ("Get Beer by Id - in controller" );
23
+
24
+ return beerService .getBeerById (id );
25
+ }
26
+
15
27
}
Original file line number Diff line number Diff line change 1
1
package guru .springframework .spring6restmvc .services ;
2
2
3
3
import guru .springframework .spring6restmvc .model .Beer ;
4
- import org .springframework .stereotype .Service ;
5
4
6
5
import java .util .UUID ;
7
6
8
7
/**
9
8
* Created by jt, Spring Framework Guru.
10
9
*/
11
- @ Service
12
10
public interface BeerService {
13
11
14
12
Beer getBeerById (UUID id );
Original file line number Diff line number Diff line change 2
2
3
3
import guru .springframework .spring6restmvc .model .Beer ;
4
4
import guru .springframework .spring6restmvc .model .BeerStyle ;
5
+ import lombok .extern .slf4j .Slf4j ;
6
+ import org .springframework .stereotype .Service ;
5
7
6
8
import java .math .BigDecimal ;
7
9
import java .time .LocalDateTime ;
10
12
/**
11
13
* Created by jt, Spring Framework Guru.
12
14
*/
15
+ @ Slf4j
16
+ @ Service
13
17
public class BeerServiceImpl implements BeerService {
14
18
@ Override
15
19
public Beer getBeerById (UUID id ) {
20
+
21
+ log .debug ("Get Beer by Id - in service. Id: " + id .toString ());
22
+
16
23
return Beer .builder ()
17
24
.id (id )
18
25
.version (1 )
Original file line number Diff line number Diff line change 1
1
2
+ logging.level.guru.springframework =debug
Original file line number Diff line number Diff line change
1
+ package guru .springframework .spring6restmvc .controller ;
2
+
3
+ import org .junit .jupiter .api .Test ;
4
+ import org .springframework .beans .factory .annotation .Autowired ;
5
+ import org .springframework .boot .test .context .SpringBootTest ;
6
+
7
+ import java .util .UUID ;
8
+
9
+ import static org .junit .jupiter .api .Assertions .*;
10
+
11
+ @ SpringBootTest
12
+ class BeerControllerTest {
13
+
14
+ @ Autowired
15
+ BeerController beerController ;
16
+
17
+ @ Test
18
+ void getBeerById () {
19
+
20
+ System .out .println (beerController .getBeerById (UUID .randomUUID ()));
21
+
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments