All examples are moved to special folder

This commit is contained in:
Yuriy Dvorzhetskiy committed 2019-09-05 19:38:23 +06:00
1 parent 7efe4bbab3
commit be3ac01fe8
126 files changed

No files matched your search

@@ -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);
}
}
@@ -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";
}
@@ -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));
}
}
@@ -0,0 +1,7 @@
package ru.otus.testingExample.services;
public interface GreetingService {
void sayRussianGreeting();
void sayEnglishGreeting();
void sayChinaGreeting();
}
@@ -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)));
}
}
@@ -0,0 +1,5 @@
package ru.otus.testingExample.services;
public interface IOService {
void out(String message);
}