-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/hw-03 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
uoles
wants to merge
25
commits into
master
Choose a base branch
from
feature/hw-03
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
441a587
Add files commit.
uoles b22839c
Edit readme.
uoles baef643
Edit readme.
uoles 1afc67d
Edit readme.
uoles 9d46552
- Переименование классов.
uoles c3266f7
- Переименованы классы.
f02aaa1
- XML конфигурация spring заменена на Java-based.
0c00541
Java-based конфигурация spring заменена на Annotation-based.
5836fb1
Загрузка имени файла с вопросами из конфигурационного файла.
uoles da86894
- Рефакторинг.
c27da6c
- Локализация для вопросов и сообщений.
e37b4a6
Merge branch 'master' into feature/hw-02
uoles d1ca11a
- Убраны лишние тесты.
uoles 00bc9bd
Рефакторинг.
uoles f6c34d2
Merge branch 'master' into feature/hw-02
uoles e2ba5e0
Добавление файлов настроек для тестов.
998fed3
Рефакторинг.
f5693bd
Рефакторинг.
uoles c44d163
- Перенос приложения на Spring Boot.
uoles 6766ccd
Тесты переведены на Spring Boot.
f7c8922
Настройки перенесены в *.yml файлы.
2fd53d2
Добавлен баннер.
f483831
Рефакторинг.
879244e
Доработки по замечаниям.
2faf494
Рефакторинг.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,3 @@ | |
| target | ||
| *.iml | ||
| *.log | ||
| *.txt | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| # OtusSpringHW | ||
| Домашние задания по Spring для Otus. | ||
| # OtusSpringHW | ||
|
|
||
| Домашнее задание #3: | ||
| - Создать проект используя Spring Boot Initializr. | ||
| - Перенести приложение на Spring Boot. | ||
| - Сделать собственный баннер для приложения. | ||
| - Перенести все свойства в *.yml файлы. | ||
| - Перенести тесты и использовать spring-boot-test-starter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <name>home-work</name> | ||
|
|
||
| <groupId>ru.otus.mkulikov</groupId> | ||
| <artifactId>home-work</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <parent> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-parent</artifactId> | ||
| <version>2.1.3.RELEASE</version> | ||
| <relativePath/> <!-- lookup parent from repository --> | ||
| </parent> | ||
|
|
||
| <properties> | ||
| <java.version>11</java.version> | ||
| <encoding>UTF-8</encoding> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>net.sf.opencsv</groupId> | ||
| <artifactId>opencsv</artifactId> | ||
| <version>2.3</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>javax.annotation</groupId> | ||
| <artifactId>javax.annotation-api</artifactId> | ||
| <version>1.3.2</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.projectlombok</groupId> | ||
| <artifactId>lombok</artifactId> | ||
| <version>1.18.4</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <!-- tests --> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <version>5.3.2</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <version>5.3.2</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.platform</groupId> | ||
| <artifactId>junit-platform-launcher</artifactId> | ||
| <version>1.4.1</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <!-- https://mvnrepository.com/artifact/org.mockito/mockito-all --> | ||
| <dependency> | ||
| <groupId>org.mockito</groupId> | ||
| <artifactId>mockito-all</artifactId> | ||
| <version>1.10.19</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <!-- Spring Boot --> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-test</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-configuration-processor</artifactId> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <encoding>${encoding}</encoding> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-resources-plugin</artifactId> | ||
| <configuration> | ||
| <encoding>${encoding}</encoding> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>2.22.0</version> | ||
|
|
||
| <configuration> | ||
| <skipTests>false</skipTests> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-maven-plugin</artifactId> | ||
| </plugin> | ||
| </plugins> | ||
|
|
||
| <resources> | ||
| <resource> | ||
| <directory>src/main/resources</directory> | ||
| <includes> | ||
| <include>**/*.csv</include> | ||
| <include>**/*.properties</include> | ||
| <include>**/*.txt</include> | ||
| <include>**/*.yml</include> | ||
| </includes> | ||
| <filtering>false</filtering> | ||
| </resource> | ||
| </resources> | ||
| </build> | ||
| </project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package ru.otus.mkulikov; | ||
|
|
||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| import org.springframework.context.ApplicationContext; | ||
| import ru.otus.mkulikov.exceptions.QuestionsFileLoadingException; | ||
| import ru.otus.mkulikov.services.processor.ProcessorService; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 2019-03-14 | ||
| * Time: 15:27 | ||
| */ | ||
|
|
||
| @SpringBootApplication | ||
| @EnableConfigurationProperties | ||
| public class Application { | ||
|
|
||
| public static void main(String[] args) { | ||
| ApplicationContext context = SpringApplication.run(Application.class); | ||
| try { | ||
| ProcessorService processor = context.getBean(ProcessorService.class); | ||
| processor.startTest(); | ||
| } catch (QuestionsFileLoadingException e) { | ||
| e.printStackTrace(); | ||
| } | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/ru/otus/mkulikov/config/LocaleProperties.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package ru.otus.mkulikov.config; | ||
|
|
||
| import lombok.Data; | ||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 19.04.2019 | ||
| * Time: 9:57 | ||
| */ | ||
|
|
||
| @Data | ||
| @Component | ||
| @ConfigurationProperties(prefix = "locale") | ||
| public class LocaleProperties { | ||
|
|
||
| private String basename; | ||
| private String defaultLocale; | ||
| private String encoding; | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/ru/otus/mkulikov/config/QuetionsProperties.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package ru.otus.mkulikov.config; | ||
|
|
||
| import lombok.Data; | ||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 19.04.2019 | ||
| * Time: 10:25 | ||
| */ | ||
|
|
||
| @Data | ||
| @Component | ||
| @ConfigurationProperties(prefix = "questions.default") | ||
| public class QuetionsProperties { | ||
|
|
||
| private String dir; | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/java/ru/otus/mkulikov/exceptions/QuestionsFileLoadingException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package ru.otus.mkulikov.exceptions; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 2019-03-17 | ||
| * Time: 01:40 | ||
| */ | ||
|
|
||
| public class QuestionsFileLoadingException extends RuntimeException { | ||
|
|
||
| public QuestionsFileLoadingException(String message) { | ||
| super(message); | ||
| } | ||
|
|
||
| public QuestionsFileLoadingException(String message, Throwable cause) { | ||
| super(message, cause); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package ru.otus.mkulikov.models; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 2019-03-14 | ||
| * Time: 15:54 | ||
| */ | ||
|
|
||
| @Data | ||
| public class Question implements Serializable { | ||
|
|
||
| private String id; | ||
| private String question; | ||
| private String answer1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А не проще это масством сделать?) Настойчиво рекомендую) |
||
| private String answer2; | ||
| private String answer3; | ||
| private String answer4; | ||
| private String trueAnswer; | ||
| private String userAnswer; | ||
|
|
||
| public Question(String id, String question, String answer1, String answer2, String answer3, String answer4, String trueAnswer, String userAnswer) { | ||
| this.id = id; | ||
| this.question = question; | ||
| this.answer1 = answer1; | ||
| this.answer2 = answer2; | ||
| this.answer3 = answer3; | ||
| this.answer4 = answer4; | ||
| this.trueAnswer = trueAnswer; | ||
| this.userAnswer = userAnswer; | ||
| } | ||
|
|
||
| public Question() { | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package ru.otus.mkulikov.models; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 2019-03-14 | ||
| * Time: 15:29 | ||
| */ | ||
|
|
||
| @Data | ||
| public class User { | ||
|
|
||
| private final String name; | ||
| private final String surname; | ||
|
|
||
| public User(String name, String surname) { | ||
| this.name = name; | ||
| this.surname = surname; | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
src/main/java/ru/otus/mkulikov/services/console/ConsoleIOServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package ru.otus.mkulikov.services.console; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import javax.annotation.PreDestroy; | ||
| import java.util.Scanner; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 17.03.2019 | ||
| * Time: 23:21 | ||
| */ | ||
|
|
||
| @Service | ||
| public class ConsoleIOServiceImpl implements IOService { | ||
|
|
||
| private final Scanner in; | ||
|
|
||
| public ConsoleIOServiceImpl() { | ||
| in = new Scanner(System.in); | ||
| } | ||
|
|
||
| @Override | ||
| public void write(String text) { | ||
| System.out.println(text); | ||
| } | ||
|
|
||
| @Override | ||
| public String read() { | ||
| return in.nextLine(); | ||
| } | ||
|
|
||
| @PreDestroy | ||
| public void destroy() { | ||
| in.close(); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/ru/otus/mkulikov/services/console/IOService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package ru.otus.mkulikov.services.console; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 17.03.2019 | ||
| * Time: 23:21 | ||
| */ | ||
|
|
||
| public interface IOService { | ||
|
|
||
| void write(String text); | ||
|
|
||
| String read(); | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/ru/otus/mkulikov/services/localisation/LocalisationService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package ru.otus.mkulikov.services.localisation; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 2019-03-21 | ||
| * Time: 14:02 | ||
| */ | ||
|
|
||
| public interface LocalisationService { | ||
|
|
||
| String getValue(String key); | ||
|
|
||
| String getValueWithParams(String key, String[] params); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот это как раз уже есть в parent-e