From ff43929fff069817ead96cce23719675074bebb8 Mon Sep 17 00:00:00 2001 From: kaustubh datar Date: Sat, 10 Dec 2022 21:10:46 +0530 Subject: [PATCH] Updated with Joke Service Implementation. Closes springframeworkguru#58 --- pom.xml | 6 +++++- .../services/JokeService.java | 6 ++++++ .../services/JokeServiceImpl.java | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/springframework/spring5jokesappv2/services/JokeService.java create mode 100644 src/main/java/com/springframework/spring5jokesappv2/services/JokeServiceImpl.java diff --git a/pom.xml b/pom.xml index b3fa5e858..6b9927f7d 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,11 @@ org.springframework.boot spring-boot-starter-web - + + guru.springframework + chuck-norris-for-actuator + 2.4.0 + org.springframework.boot spring-boot-starter-test diff --git a/src/main/java/com/springframework/spring5jokesappv2/services/JokeService.java b/src/main/java/com/springframework/spring5jokesappv2/services/JokeService.java new file mode 100644 index 000000000..f627e8140 --- /dev/null +++ b/src/main/java/com/springframework/spring5jokesappv2/services/JokeService.java @@ -0,0 +1,6 @@ +package com.springframework.spring5jokesappv2.services; + +public interface JokeService { + + String getJoke(); +} diff --git a/src/main/java/com/springframework/spring5jokesappv2/services/JokeServiceImpl.java b/src/main/java/com/springframework/spring5jokesappv2/services/JokeServiceImpl.java new file mode 100644 index 000000000..7b26deb14 --- /dev/null +++ b/src/main/java/com/springframework/spring5jokesappv2/services/JokeServiceImpl.java @@ -0,0 +1,18 @@ +package com.springframework.spring5jokesappv2.services; + +import guru.springframework.norris.chuck.ChuckNorrisQuotes; +import org.springframework.stereotype.Service; + +@Service +public class JokeServiceImpl implements JokeService{ + private final ChuckNorrisQuotes chuckNorrisQuotes; + + public JokeServiceImpl(){ + this.chuckNorrisQuotes = new ChuckNorrisQuotes(); + } + + @Override + public String getJoke() { + return chuckNorrisQuotes.getRandomQuote(); + } +}