diff --git a/.gitignore b/.gitignore
index 57f1cb2..d952daf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,6 @@
-/.idea/
\ No newline at end of file
+target/
+build/
+.idea/
+*.iml
+.gradle/
+.mvn/wrapper/maven-wrapper.jar
diff --git a/.gitignore.txt b/.gitignore.txt
deleted file mode 100644
index 57f1cb2..0000000
--- a/.gitignore.txt
+++ /dev/null
@@ -1 +0,0 @@
-/.idea/
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index a156ef4..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-gs-spring-boot
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index daa2f90..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index ba88c4b..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml b/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml
deleted file mode 100644
index 6fec8f4..0000000
--- a/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml b/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml
deleted file mode 100644
index 9eb8596..0000000
--- a/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml b/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml
deleted file mode 100644
index 33c30b4..0000000
--- a/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml
deleted file mode 100644
index 06441f4..0000000
--- a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_5.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_5.xml
deleted file mode 100644
index 1205e0d..0000000
--- a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_5.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_5.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_5.xml
deleted file mode 100644
index 467b779..0000000
--- a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_5.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_5.xml b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_5.xml
deleted file mode 100644
index 65b251d..0000000
--- a/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_5.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_5.xml b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_5.xml
deleted file mode 100644
index c85f307..0000000
--- a/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_5.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_5.xml b/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_5.xml
deleted file mode 100644
index 4ace22a..0000000
--- a/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_5.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_h2database_h2_1_4_197.xml b/.idea/libraries/Maven__com_h2database_h2_1_4_197.xml
deleted file mode 100644
index 87c599a..0000000
--- a/.idea/libraries/Maven__com_h2database_h2_1_4_197.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_zaxxer_HikariCP_2_7_9.xml b/.idea/libraries/Maven__com_zaxxer_HikariCP_2_7_9.xml
deleted file mode 100644
index 6d6865c..0000000
--- a/.idea/libraries/Maven__com_zaxxer_HikariCP_2_7_9.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml b/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml
deleted file mode 100644
index e74f3ab..0000000
--- a/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml b/.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml
deleted file mode 100644
index 6978c0b..0000000
--- a/.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml
deleted file mode 100644
index cbe5ca7..0000000
--- a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml
deleted file mode 100644
index 1407c58..0000000
--- a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_31.xml b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_31.xml
deleted file mode 100644
index a6693a2..0000000
--- a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_31.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_31.xml b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_31.xml
deleted file mode 100644
index bc00163..0000000
--- a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_31.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_31.xml b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_31.xml
deleted file mode 100644
index a47a3be..0000000
--- a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_31.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_9_Final.xml b/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_9_Final.xml
deleted file mode 100644
index 5a26bec..0000000
--- a/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_9_Final.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml b/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml
deleted file mode 100644
index 5f7dd01..0000000
--- a/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml b/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml
deleted file mode 100644
index 6073e53..0000000
--- a/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml b/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml
deleted file mode 100644
index 20e8163..0000000
--- a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_2_RELEASE.xml
deleted file mode 100644
index 216fa5d..0000000
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_2_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_2_RELEASE.xml
deleted file mode 100644
index 416393d..0000000
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_2_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_2_RELEASE.xml
deleted file mode 100644
index f4f17f8..0000000
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_2_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_2_RELEASE.xml
deleted file mode 100644
index 1fe0fd1..0000000
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_2_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_2_RELEASE.xml
deleted file mode 100644
index 7f64d70..0000000
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_2_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_2_RELEASE.xml
deleted file mode 100644
index 73c5114..0000000
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_2_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_2_RELEASE.xml
deleted file mode 100644
index 15cdbc9..0000000
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_2_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_2_RELEASE.xml
deleted file mode 100644
index ab4ca86..0000000
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_2_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_aop_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_aop_5_0_6_RELEASE.xml
deleted file mode 100644
index 45ed002..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_aop_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_beans_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_beans_5_0_6_RELEASE.xml
deleted file mode 100644
index c046b8d..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_beans_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_context_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_context_5_0_6_RELEASE.xml
deleted file mode 100644
index 9b830cd..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_context_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_core_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_core_5_0_6_RELEASE.xml
deleted file mode 100644
index 597e34e..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_core_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_expression_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_expression_5_0_6_RELEASE.xml
deleted file mode 100644
index ffca824..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_expression_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_6_RELEASE.xml
deleted file mode 100644
index c0a9cc7..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_6_RELEASE.xml
deleted file mode 100644
index 671875f..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_tx_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_tx_5_0_6_RELEASE.xml
deleted file mode 100644
index 6e29e18..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_tx_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_web_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_web_5_0_6_RELEASE.xml
deleted file mode 100644
index 521bb85..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_web_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_6_RELEASE.xml
deleted file mode 100644
index e4279b7..0000000
--- a/.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_6_RELEASE.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml b/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml
deleted file mode 100644
index 33ccf19..0000000
--- a/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 01b5b5c..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 751276b..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index e96534f..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index e90adcd..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,943 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- hello.controller.*
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- HelloController
- aslist
- compata
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1526804939552
-
-
- 1526804939552
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- file://$PROJECT_DIR$/src/main/java/hello/controller/GreetingController.java
- 15
-
-
-
-
- file://$PROJECT_DIR$/src/main/java/hello/controller/HelloController.java
- 55
-
-
-
-
-
-
-
-
-
-
- ZonedDateTime.of(getLocalDateTime(), getZoneId(zoneString))
- JAVA
- CODE_FRAGMENT
-
-
- ZonedDateTime.of(getLocalDateTime(), getZoneId("UTC-04:00"))
- JAVA
- CODE_FRAGMENT
-
-
-
-
- getZoneId(zoneString)
- JAVA
- EXPRESSION
-
-
- topics.stream().filter(topic -> topic.getId().equals(id)).findFirst().get()
- JAVA
- EXPRESSION
-
-
- topics.stream().filter(topic -> topic.getId().equals(id))
- JAVA
- EXPRESSION
-
-
- topics.stream().filter(topicId -> topicId.equals(id))
- JAVA
- EXPRESSION
-
-
- topics.stream().filter(topicId -> topicId.equals(id)).findFirst().get()
- JAVA
- EXPRESSION
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No facets are configured
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
- gs-spring-boot
-
-
-
-
-
-
-
-
-
-
-
-
- Maven: ch.qos.logback:logback-classic:1.2.3
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
index c954cec..11213b0 100644
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -1 +1 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
+distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
diff --git a/application.properties b/application.properties
deleted file mode 100644
index d3baf26..0000000
--- a/application.properties
+++ /dev/null
@@ -1 +0,0 @@
-#server.port = 8081
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 09f1083..78cc85d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,32 +1,30 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE")
- }
+plugins {
+ id 'java'
+ id 'org.springframework.boot' version '3.4.5'
+ id 'io.spring.dependency-management' version '1.1.7'
}
-apply plugin: 'java'
-apply plugin: 'eclipse'
-apply plugin: 'idea'
-apply plugin: 'org.springframework.boot'
-apply plugin: 'io.spring.dependency-management'
+group = 'org.springframework'
+version = '0.1.0'
-bootJar {
- baseName = 'gs-spring-boot'
- version = '0.1.0'
+java {
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(21)
+ }
}
repositories {
mavenCentral()
}
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-
dependencies {
- compile("org.springframework.boot:spring-boot-starter-web")
- testCompile("junit:junit")
+ implementation 'org.springframework.boot:spring-boot-starter-web'
+ implementation 'org.springframework.boot:spring-boot-starter-jdbc'
+ runtimeOnly 'com.h2database:h2'
+ testImplementation 'org.springframework.boot:spring-boot-starter-test'
+}
+
+tasks.named('test') {
+ useJUnitPlatform()
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a2ff3cc..b836b84 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Thu Mar 01 09:01:15 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
diff --git a/gs-spring-boot.iml b/gs-spring-boot.iml
deleted file mode 100644
index ad195a8..0000000
--- a/gs-spring-boot.iml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 63f5cbd..a74a171 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,21 +5,16 @@
org.springframework
gs-spring-boot
- pom
+ jar
0.1.0
org.springframework.boot
spring-boot-starter-parent
- 2.0.2.RELEASE
+ 3.4.5
-
- org.springframework.boot
- spring-boot-properties-migrator
- runtime
-
org.springframework.boot
spring-boot-starter-web
@@ -32,10 +27,15 @@
com.h2database
h2
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
- 1.8
+ 21
diff --git a/src/main/java/hello/Application.java b/src/main/java/hello/Application.java
index 7cf8faf..97cf811 100644
--- a/src/main/java/hello/Application.java
+++ b/src/main/java/hello/Application.java
@@ -5,65 +5,33 @@
import java.util.stream.Collectors;
import hello.model.Customer;
-import hello.model.Quote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.web.client.RestTemplate;
@SpringBootApplication
public class Application implements CommandLineRunner {
private static final Logger log = LoggerFactory.getLogger(Application.class);
- public static void main(String[] args) {
-
- ApplicationContext ctx = SpringApplication.run(Application.class, args);
-
- System.out.println("Let's inspect the beans provided by Spring Boot:");
-
- String[] beanNames = ctx.getBeanDefinitionNames();
- Arrays.sort(beanNames);
- for (String beanName : beanNames) {
- System.out.println(beanName);
- }
-
- RestTemplate restTemplate = new RestTemplate();
- Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
- log.info(quote.toString());
- }
+ private final JdbcTemplate jdbcTemplate;
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
+ public Application(JdbcTemplate jdbcTemplate) {
+ this.jdbcTemplate = jdbcTemplate;
}
- @Bean
- public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
- return args -> {
- Quote quote = restTemplate.getForObject(
- "http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
- log.info(quote.toString());
- };
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
}
-
- @Autowired
- JdbcTemplate jdbcTemplate;
-
@Override
public void run(String... args) throws Exception {
log.info("Creating tables");
- jdbcTemplate.execute("DROP TABLE customers IF EXISTS");
+ jdbcTemplate.execute("DROP TABLE IF EXISTS customers");
jdbcTemplate.execute("CREATE TABLE customers(id SERIAL, first_name VARCHAR(255), last_name VARCHAR(255))");
// Split up the array of whole names into an array of first/last names
diff --git a/src/main/java/hello/controller/GlobalExceptionHandler.java b/src/main/java/hello/controller/GlobalExceptionHandler.java
new file mode 100644
index 0000000..593aa96
--- /dev/null
+++ b/src/main/java/hello/controller/GlobalExceptionHandler.java
@@ -0,0 +1,21 @@
+package hello.controller;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import java.util.NoSuchElementException;
+
+@ControllerAdvice
+public class GlobalExceptionHandler {
+
+ @ExceptionHandler(NoSuchElementException.class)
+ public ResponseEntity handleNotFound(NoSuchElementException ex) {
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ex.getMessage());
+ }
+
+ @ExceptionHandler(Exception.class)
+ public ResponseEntity handleGeneral(Exception ex) {
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Internal server error");
+ }
+}
diff --git a/src/main/java/hello/controller/GreetingController.java b/src/main/java/hello/controller/GreetingController.java
index cf52f8d..36ebdee 100644
--- a/src/main/java/hello/controller/GreetingController.java
+++ b/src/main/java/hello/controller/GreetingController.java
@@ -1,7 +1,7 @@
package hello.controller;
import hello.model.Greeting;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -12,7 +12,7 @@ public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
- @RequestMapping("/")
+ @GetMapping("/")
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
diff --git a/src/main/java/hello/controller/HelloController.java b/src/main/java/hello/controller/HelloController.java
index f3602fa..55d5c86 100644
--- a/src/main/java/hello/controller/HelloController.java
+++ b/src/main/java/hello/controller/HelloController.java
@@ -2,51 +2,42 @@
import hello.declaration.TimeClient;
import hello.model.SimpleTimeClient;
-import hello.model.Topic;
import hello.service.TopicService;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.bind.annotation.RequestMapping;
import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
import java.time.ZoneId;
-import java.time.chrono.ChronoPeriod;
import java.time.temporal.ChronoUnit;
-import java.util.List;
-import java.util.regex.Pattern;
-import java.util.stream.Collector;
-import java.util.stream.Collectors;
@RestController
public class HelloController {
-
String joinTemplate = "Joining All String ID's with JOIN method: ";
String makeDistinctAndSortCharactersTemplate = "-------------Get all ID characters, select distict and sort with ID= ";
String splitAllIdWithColonSelectIDWithJavaKeywordThenSortThenJoinTemplate = "-------------Split All Id With Colon," +
"Select ID With \"Java\" Keyword," +
" Then Sort Then Join ";
- String findIdHavingCharacterTemplate = "-------------Return All ID having character \'g\' in it: ";
+ String findIdHavingCharacterTemplate = "-------------Return All ID having character 'g' in it: ";
String findAllFilesInPathAndSortTemplate = "---------Find all files in path and sort: ";
String findParticularFileInPathAndSortTemplate = "----------Find File in present directory which strats with \"grad\",provided maximum depth=25 and sort : ";
String findParticularFileInPathAndSortWithWalkFunctionTemplate = "----------Find File in present directory which strats with \"grad\",provided maximum depth=25 and sort : with walk function";
String readFileWithStreamFunctionTemplate = "---------Read \"temp.txt\" file with stream functions, having \"print\" witin it: ";
+ private final TopicService topicService;
- @Autowired
- private TopicService topicService;
+ public HelloController(TopicService topicService) {
+ this.topicService = topicService;
+ }
/**
* Java 8 Date Time example
*
* @return
*/
- @RequestMapping("/datetime")
+ @GetMapping("/datetime")
public String index() {
TimeClient myTimeClient = new SimpleTimeClient();
- LocalDateTime localDateTime = LocalDateTime.now();
return "Greetings from Spring Boot! ----------------------" +
"Datetime now is " + String.valueOf(myTimeClient.toString()) + "----------------------" +
"Datetime tomorrow will be " + String.valueOf(myTimeClient.getLocalDateTime().plusDays(1)) + "----------------------" +
@@ -63,7 +54,7 @@ public String index() {
*
* @return
*/
- @RequestMapping("/topic/string/operation")
+ @GetMapping("/topic/string/operation")
public String showStringOperation() {
String join = topicService.returnAllTopicIDWithStringSlicing();
@@ -84,7 +75,7 @@ public String showStringOperation() {
* File Operation in Java 8
* @return
*/
- @RequestMapping("/topic/file/operation")
+ @GetMapping("/topic/file/operation")
public String showFileOperation() {
String findAllFilesInPathAndSort = topicService.findAllFilesInPathAndSort();
String findParticularFileInPathAndSort = topicService.findParticularFileInPathAndSort();
@@ -96,6 +87,4 @@ public String showFileOperation() {
+ readFileWithStreamFunctionTemplate + readFileWithStreamFunction;
}
-
-
}
diff --git a/src/main/java/hello/controller/TopicController.java b/src/main/java/hello/controller/TopicController.java
index c2e8273..a5f5c91 100644
--- a/src/main/java/hello/controller/TopicController.java
+++ b/src/main/java/hello/controller/TopicController.java
@@ -2,7 +2,6 @@
import hello.model.Topic;
import hello.service.TopicService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -10,15 +9,17 @@
@RestController
public class TopicController {
- @Autowired
- private TopicService topicService;
+ private final TopicService topicService;
+ public TopicController(TopicService topicService) {
+ this.topicService = topicService;
+ }
/**
* Get all Topic
* @return
*/
- @RequestMapping("/topic")
+ @GetMapping("/topic")
public List getAllTopics() {
return topicService.getAllTopics();
}
@@ -28,7 +29,7 @@ public List getAllTopics() {
* @param id
* @return
*/
- @RequestMapping("/topic/{id}")
+ @GetMapping("/topic/{id}")
public Topic getTopicWithID(@PathVariable String id) {
return topicService.getTopicWithId(id);
}
@@ -37,7 +38,7 @@ public Topic getTopicWithID(@PathVariable String id) {
* Add a new topic in list
* @param topic
*/
- @RequestMapping(method = RequestMethod.POST, value = "/topic")
+ @PostMapping("/topic")
public void addTopic(@RequestBody Topic topic) {
topicService.addTopic(topic);
}
@@ -47,17 +48,16 @@ public void addTopic(@RequestBody Topic topic) {
* @param id
* @param topic
*/
- @RequestMapping(method = RequestMethod.PUT, value = "/topic/{id}")
+ @PutMapping("/topic/{id}")
public void updateTopic(@PathVariable String id, @RequestBody Topic topic) {
topicService.updateTopic(id, topic);
}
-
/**
* Delete a topic with ID
* @param id
*/
- @RequestMapping(method = RequestMethod.DELETE, value = "/topic/{id}")
+ @DeleteMapping("/topic/{id}")
public void deleteTopic(@PathVariable String id) {
topicService.deleteTopic(id);
}
@@ -67,24 +67,18 @@ public void deleteTopic(@PathVariable String id) {
* @param minLength
* @return
*/
- @RequestMapping(value = "/topic/minimum/length/{minLength}")
+ @GetMapping("/topic/minimum/length/{minLength}")
public List filterMinimumLengthForId(@PathVariable Integer minLength) {
return topicService.filterMinimumLengthForId(minLength);
}
-
/**
* Sort with Id
* @return
*/
- @RequestMapping("/topic/sort")
+ @GetMapping("/topic/sort")
public List sortTopicsWithID() {
return topicService.sortTopicsWithID();
}
-
-
-
-
-
}
diff --git a/src/main/java/hello/declaration/CustomPredicate.java b/src/main/java/hello/declaration/CustomPredicate.java
index 46f0c44..b9a5686 100644
--- a/src/main/java/hello/declaration/CustomPredicate.java
+++ b/src/main/java/hello/declaration/CustomPredicate.java
@@ -4,6 +4,7 @@
* Use as a Functional Interface
* @param
*/
-public interface CustomPredicate {
+@FunctionalInterface
+public interface CustomPredicate {
boolean test(T t);
}
diff --git a/src/main/java/hello/declaration/TimeClient.java b/src/main/java/hello/declaration/TimeClient.java
index 80aa106..b5f5343 100644
--- a/src/main/java/hello/declaration/TimeClient.java
+++ b/src/main/java/hello/declaration/TimeClient.java
@@ -1,36 +1,34 @@
package hello.declaration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.time.DateTimeException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
/**
* Implementing Defaults and Static Functions in Interface
*/
-
public interface TimeClient {
+ Logger log = LoggerFactory.getLogger(TimeClient.class);
+
void setTime(int hour, int minute, int second);
void setDate(int day, int month, int year);
void setDateAndTime(int day, int month, int year, int hour, int minute, int second);
LocalDateTime getLocalDateTime();
- static ZoneId getZoneId (String zoneString) {
+ static ZoneId getZoneId(String zoneString) {
try {
return ZoneId.of(zoneString);
} catch (DateTimeException e) {
- System.err.println("Invalid time zone: " + zoneString +
- "; using default time zone instead.");
+ log.warn("Invalid time zone: {}; using default time zone instead.", zoneString);
return ZoneId.systemDefault();
}
}
-
default ZonedDateTime getZonedDateTime(String zoneString) {
return ZonedDateTime.of(getLocalDateTime(), getZoneId(zoneString));
}
diff --git a/src/main/java/hello/model/Customer.java b/src/main/java/hello/model/Customer.java
index a6df80e..633cdd9 100644
--- a/src/main/java/hello/model/Customer.java
+++ b/src/main/java/hello/model/Customer.java
@@ -1,9 +1,6 @@
package hello.model;
-public class Customer {
- private long id;
- private String firstName, lastName;
-
+public record Customer(long id, String firstName, String lastName) {
@Override
public String toString() {
return "Customer{" +
@@ -12,34 +9,4 @@ public String toString() {
", lastName='" + lastName + '\'' +
'}';
}
-
- public Customer(long id, String firstName, String lastName) {
- this.id = id;
- this.firstName = firstName;
- this.lastName = lastName;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
}
diff --git a/src/main/java/hello/model/Greeting.java b/src/main/java/hello/model/Greeting.java
index f2e7772..6a5f8ce 100644
--- a/src/main/java/hello/model/Greeting.java
+++ b/src/main/java/hello/model/Greeting.java
@@ -1,21 +1,3 @@
package hello.model;
-public class Greeting {
- private final long id;
- private final String content;
-
- public Greeting(long id, String content) {
- this.id = id;
- this.content = content;
- }
-
-
- public long getId() {
-
- return id;
- }
-
- public String getContent() {
- return content;
- }
-}
+public record Greeting(long id, String content) {}
diff --git a/src/main/java/hello/service/TopicService.java b/src/main/java/hello/service/TopicService.java
index feffb92..667885e 100644
--- a/src/main/java/hello/service/TopicService.java
+++ b/src/main/java/hello/service/TopicService.java
@@ -2,6 +2,8 @@
import hello.declaration.CustomPredicate;
import hello.model.Topic;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
@@ -18,6 +20,7 @@
@Service
public class TopicService {
+ private static final Logger log = LoggerFactory.getLogger(TopicService.class);
private List topics = new ArrayList<>(Arrays.asList(
new Topic("spring", "Spring Framework", "Spring Framework Description"),
@@ -30,13 +33,14 @@ public List getAllTopics() {
}
/**
- * Strean Example
+ * Stream Example
*
* @param id
* @return
*/
public Topic getTopicWithId(String id) {
- return topics.stream().filter(topic -> topic.getId().equals(id)).findFirst().get();
+ return topics.stream().filter(topic -> topic.getId().equals(id)).findFirst()
+ .orElseThrow(() -> new NoSuchElementException("Topic not found with id: " + id));
}
public void addTopic(Topic topic) {
@@ -55,7 +59,7 @@ public void updateTopic(String id, Topic topic) {
}
/**
- * Lamda Expressions
+ * Lambda Expressions
*
* @param id
*/
@@ -64,7 +68,7 @@ public void deleteTopic(String id) {
}
/**
- * Calling fucntional Interface
+ * Calling functional Interface
*
* @param minLength
* @return
@@ -223,8 +227,8 @@ public String findParticularFileInPathAndSortWithWalkFunction() {
* @return
*/
public String readFileWithStreamFunction() {
- Path path = Paths.get("temp.txt");
- System.out.println();
+ Path path = Paths.get("src/main/resources/temp.txt");
+ log.info("Reading file: {}", path);
try (BufferedReader reader = Files.newBufferedReader(path)) {
String lines = reader
.lines()
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
new file mode 100644
index 0000000..126cab5
--- /dev/null
+++ b/src/main/resources/application.properties
@@ -0,0 +1,3 @@
+spring.application.name=springboot-java8-demo
+server.port=8080
+spring.h2.console.enabled=true
diff --git a/temp.txt b/src/main/resources/temp.txt
similarity index 100%
rename from temp.txt
rename to src/main/resources/temp.txt
diff --git a/src/test/java/hello/controller/GreetingControllerTest.java b/src/test/java/hello/controller/GreetingControllerTest.java
new file mode 100644
index 0000000..e6afd4a
--- /dev/null
+++ b/src/test/java/hello/controller/GreetingControllerTest.java
@@ -0,0 +1,36 @@
+package hello.controller;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.test.web.servlet.MockMvc;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+@WebMvcTest(GreetingController.class)
+class GreetingControllerTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @MockitoBean
+ private JdbcTemplate jdbcTemplate;
+
+ @Test
+ void greeting_defaultName_returnsHelloWorld() throws Exception {
+ mockMvc.perform(get("/"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.content").value("Hello, World!"))
+ .andExpect(jsonPath("$.id").exists());
+ }
+
+ @Test
+ void greeting_withName_returnsPersonalizedGreeting() throws Exception {
+ mockMvc.perform(get("/").param("name", "Devin"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.content").value("Hello, Devin!"));
+ }
+}
diff --git a/src/test/java/hello/controller/TopicControllerTest.java b/src/test/java/hello/controller/TopicControllerTest.java
new file mode 100644
index 0000000..2273871
--- /dev/null
+++ b/src/test/java/hello/controller/TopicControllerTest.java
@@ -0,0 +1,113 @@
+package hello.controller;
+
+import hello.model.Topic;
+import hello.service.TopicService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
+import org.springframework.http.MediaType;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.test.web.servlet.MockMvc;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+@WebMvcTest(TopicController.class)
+class TopicControllerTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @MockitoBean
+ private TopicService topicService;
+
+ @MockitoBean
+ private JdbcTemplate jdbcTemplate;
+
+ @Test
+ void getAllTopics_returnsOk() throws Exception {
+ List topics = Arrays.asList(
+ new Topic("java", "Core Java", "Java Description"),
+ new Topic("spring", "Spring", "Spring Description")
+ );
+ when(topicService.getAllTopics()).thenReturn(topics);
+
+ mockMvc.perform(get("/topic"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$[0].id").value("java"))
+ .andExpect(jsonPath("$[1].id").value("spring"));
+ }
+
+ @Test
+ void getTopicWithID_existingId_returnsOk() throws Exception {
+ Topic topic = new Topic("java", "Core Java", "Java Description");
+ when(topicService.getTopicWithId("java")).thenReturn(topic);
+
+ mockMvc.perform(get("/topic/java"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.id").value("java"))
+ .andExpect(jsonPath("$.subjectName").value("Core Java"));
+ }
+
+ @Test
+ void getTopicWithID_nonExistingId_returns404() throws Exception {
+ when(topicService.getTopicWithId("nonexistent"))
+ .thenThrow(new NoSuchElementException("Topic not found with id: nonexistent"));
+
+ mockMvc.perform(get("/topic/nonexistent"))
+ .andExpect(status().isNotFound());
+ }
+
+ @Test
+ void addTopic_returnsOk() throws Exception {
+ mockMvc.perform(post("/topic")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content("{\"id\":\"python\",\"subjectName\":\"Python\",\"subjectDescription\":\"Python Desc\"}"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void updateTopic_returnsOk() throws Exception {
+ mockMvc.perform(put("/topic/java")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content("{\"id\":\"java\",\"subjectName\":\"Advanced Java\",\"subjectDescription\":\"Adv Java Desc\"}"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void deleteTopic_returnsOk() throws Exception {
+ mockMvc.perform(delete("/topic/java"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void sortTopicsWithID_returnsOk() throws Exception {
+ List sorted = Arrays.asList(
+ new Topic("java", "Core Java", "Java Description"),
+ new Topic("spring", "Spring", "Spring Description")
+ );
+ when(topicService.sortTopicsWithID()).thenReturn(sorted);
+
+ mockMvc.perform(get("/topic/sort"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$[0].id").value("java"));
+ }
+
+ @Test
+ void filterMinimumLengthForId_returnsOk() throws Exception {
+ List filtered = Arrays.asList(
+ new Topic("spring", "Spring", "Spring Description")
+ );
+ when(topicService.filterMinimumLengthForId(4)).thenReturn(filtered);
+
+ mockMvc.perform(get("/topic/minimum/length/4"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$[0].id").value("spring"));
+ }
+}
diff --git a/src/test/java/hello/service/TopicServiceTest.java b/src/test/java/hello/service/TopicServiceTest.java
new file mode 100644
index 0000000..3882192
--- /dev/null
+++ b/src/test/java/hello/service/TopicServiceTest.java
@@ -0,0 +1,84 @@
+package hello.service;
+
+import hello.model.Topic;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TopicServiceTest {
+
+ private TopicService topicService;
+
+ @BeforeEach
+ void setUp() {
+ topicService = new TopicService();
+ }
+
+ @Test
+ void getAllTopics_returnsDefaultTopics() {
+ List topics = topicService.getAllTopics();
+ assertEquals(3, topics.size());
+ }
+
+ @Test
+ void getTopicWithId_existingId_returnsTopic() {
+ Topic topic = topicService.getTopicWithId("java");
+ assertNotNull(topic);
+ assertEquals("java", topic.getId());
+ assertEquals("Core Java", topic.getSubjectName());
+ }
+
+ @Test
+ void getTopicWithId_nonExistingId_throwsException() {
+ assertThrows(NoSuchElementException.class, () -> topicService.getTopicWithId("nonexistent"));
+ }
+
+ @Test
+ void addTopic_increasesListSize() {
+ Topic newTopic = new Topic("python", "Python", "Python Description");
+ topicService.addTopic(newTopic);
+ assertEquals(4, topicService.getAllTopics().size());
+ assertEquals("python", topicService.getTopicWithId("python").getId());
+ }
+
+ @Test
+ void updateTopic_existingId_updatesTopic() {
+ Topic updatedTopic = new Topic("java", "Advanced Java", "Advanced Java Description");
+ topicService.updateTopic("java", updatedTopic);
+ Topic result = topicService.getTopicWithId("java");
+ assertEquals("Advanced Java", result.getSubjectName());
+ }
+
+ @Test
+ void deleteTopic_existingId_removesFromList() {
+ topicService.deleteTopic("java");
+ assertEquals(2, topicService.getAllTopics().size());
+ assertThrows(NoSuchElementException.class, () -> topicService.getTopicWithId("java"));
+ }
+
+ @Test
+ void sortTopicsWithID_returnsSortedList() {
+ List sorted = topicService.sortTopicsWithID();
+ assertEquals("java", sorted.get(0).getId());
+ assertEquals("javascript", sorted.get(1).getId());
+ assertEquals("spring", sorted.get(2).getId());
+ }
+
+ @Test
+ void filterMinimumLengthForId_returnsFilteredList() {
+ List filtered = topicService.filterMinimumLengthForId(4);
+ assertEquals(2, filtered.size());
+ }
+
+ @Test
+ void returnAllTopicIDWithStringSlicing_returnsJoinedIds() {
+ String result = topicService.returnAllTopicIDWithStringSlicing();
+ assertTrue(result.contains("spring"));
+ assertTrue(result.contains("java"));
+ assertTrue(result.contains(":"));
+ }
+}