mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-06-20 11:14:34 +00:00
All examples are moved to special folder
This commit is contained in:
1 parent
7efe4bbab3
commit
be3ac01fe8
126 files changed
No files matched your search
+11
@@ -0,0 +1,11 @@
|
||||
package ru.otus.testingExample.services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ConsoleIOService implements IOService {
|
||||
@Override
|
||||
public void out(String message) {
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package ru.otus.testingExample.services;
|
||||
|
||||
public class CountryCodes {
|
||||
public static final String COUNTRY_CODE_RU = "RU";
|
||||
public static final String COUNTRY_CODE_EN = "EN";
|
||||
public static final String COUNTRY_CODE_CN = "CN";
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package ru.otus.testingExample.services;
|
||||
|
||||
public class GreetingNotFoundException extends RuntimeException {
|
||||
public GreetingNotFoundException(String countryCode) {
|
||||
super(String.format("No greeting was found for country code %s", countryCode));
|
||||
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package ru.otus.testingExample.services;
|
||||
|
||||
public interface GreetingService {
|
||||
void sayRussianGreeting();
|
||||
void sayEnglishGreeting();
|
||||
void sayChinaGreeting();
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package ru.otus.testingExample.services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.otus.testingExample.dao.GreetingDao;
|
||||
|
||||
import static ru.otus.testingExample.services.CountryCodes.*;
|
||||
|
||||
@Service
|
||||
public class GreetingServiceImpl implements GreetingService {
|
||||
private final IOService ioService;
|
||||
private final GreetingDao greetingDao;
|
||||
|
||||
public GreetingServiceImpl(IOService ioService, GreetingDao greetingDao) {
|
||||
this.ioService = ioService;
|
||||
this.greetingDao = greetingDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sayRussianGreeting() {
|
||||
ioService.out(greetingDao.findGreetingByCountryCode(COUNTRY_CODE_RU).orElseThrow(() -> new GreetingNotFoundException(COUNTRY_CODE_RU)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sayEnglishGreeting() {
|
||||
ioService.out(greetingDao.findGreetingByCountryCode(COUNTRY_CODE_EN).orElseThrow(() -> new GreetingNotFoundException(COUNTRY_CODE_EN)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sayChinaGreeting() {
|
||||
ioService.out(greetingDao.findGreetingByCountryCode(COUNTRY_CODE_CN).orElseThrow(() -> new GreetingNotFoundException(COUNTRY_CODE_CN)));
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package ru.otus.testingExample.services;
|
||||
|
||||
public interface IOService {
|
||||
void out(String message);
|
||||
}
|
||||
Reference in new issue
Block a user