org.springframework
spring-core
diff --git a/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/exceptions/JndiExceptionsUnitTest.java b/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/exceptions/JndiExceptionsUnitTest.java
index 49d4facffb..434fa41252 100644
--- a/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/exceptions/JndiExceptionsUnitTest.java
+++ b/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/exceptions/JndiExceptionsUnitTest.java
@@ -1,5 +1,12 @@
package com.baeldung.jndi.exceptions;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NoInitialContextException;
+
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@@ -7,15 +14,10 @@ import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.jndi.JndiTemplate;
import org.springframework.mock.jndi.SimpleNamingContextBuilder;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NoInitialContextException;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class JndiExceptionsUnitTest {
+ @Disabled
@Test
@Order(1)
void givenNoContext_whenLookupObject_thenThrowNoInitialContext() {
diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml
index ece85fd5dc..3fe6f735eb 100644
--- a/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml
+++ b/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml
@@ -2,7 +2,6 @@
4.0.0
- com.baeldung.servicemodule
servicemodule
jar
diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml
index 6f1038767d..a042ee4562 100644
--- a/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml
+++ b/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml
@@ -8,8 +8,8 @@
1.0
- decoupling-pattern2
- com.baeldung.decoupling-pattern2
+ com.baeldung.decoupling-pattern2
+ decoupling-pattern2
1.0-SNAPSHOT
diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml
index 64766b9aff..20e97fca0f 100644
--- a/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml
+++ b/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml
@@ -8,8 +8,8 @@
1.0
- decoupling-pattern2
- com.baeldung.decoupling-pattern2
+ com.baeldung.decoupling-pattern2
+ decoupling-pattern2
1.0-SNAPSHOT
diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml
index 9249ea5d89..f65ebb0b55 100644
--- a/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml
+++ b/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml
@@ -3,13 +3,12 @@
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">
4.0.0
- com.baeldung.servicemodule
servicemodule
1.0
- decoupling-pattern2
- >com.baeldung.decoupling-pattern2
+ com.baeldung.decoupling-pattern2
+ decoupling-pattern2
1.0-SNAPSHOT
diff --git a/core-java-modules/core-java-jpms/pom.xml b/core-java-modules/core-java-jpms/pom.xml
new file mode 100644
index 0000000000..dfb3c71229
--- /dev/null
+++ b/core-java-modules/core-java-jpms/pom.xml
@@ -0,0 +1,21 @@
+
+
+ 4.0.0
+ core-java-jpms
+ 0.0.1-SNAPSHOT
+ core-java-jpms
+ pom
+
+
+ com.baeldung.core-java-modules
+ core-java-modules
+ 1.0.0-SNAPSHOT
+
+
+
+ decoupling-pattern1
+ decoupling-pattern2
+
+
+
diff --git a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoUnitTest.java b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoManualTest.java
similarity index 88%
rename from core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoUnitTest.java
rename to core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoManualTest.java
index 0c50651af0..d56dea62f4 100644
--- a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoUnitTest.java
+++ b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoManualTest.java
@@ -2,7 +2,7 @@ package com.baeldung.exitvshalt;
import org.junit.Test;
-public class JvmExitDemoUnitTest {
+public class JvmExitDemoManualTest {
JvmExitAndHaltDemo jvmExitAndHaltDemo = new JvmExitAndHaltDemo();
diff --git a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoUnitTest.java b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoManualTest.java
similarity index 88%
rename from core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoUnitTest.java
rename to core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoManualTest.java
index 9f08e95c6a..4fe0999a9c 100644
--- a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoUnitTest.java
+++ b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoManualTest.java
@@ -2,7 +2,7 @@ package com.baeldung.exitvshalt;
import org.junit.Test;
-public class JvmHaltDemoUnitTest {
+public class JvmHaltDemoManualTest {
JvmExitAndHaltDemo jvmExitAndHaltDemo = new JvmExitAndHaltDemo();
diff --git a/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java b/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java
index 47473c29ea..f9fbc5dc3a 100644
--- a/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java
+++ b/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java
@@ -1,6 +1,8 @@
package com.baeldung.optional;
+import java.util.List;
import java.util.Optional;
+import java.util.stream.Collectors;
public class Person {
private String name;
@@ -21,7 +23,7 @@ public class Person {
}
public Optional getAge() {
- return Optional.ofNullable(age);
+ return Optional.of(age);
}
public void setAge(int age) {
@@ -36,4 +38,37 @@ public class Person {
return Optional.ofNullable(password);
}
+ public static List search(List people, String name, Optional age) {
+ // Null checks for people and name
+ return people.stream()
+ .filter(p -> p.getName().equals(name))
+ .filter(p -> p.getAge().get() >= age.orElse(0))
+ .collect(Collectors.toList());
+ }
+
+ public static List search(List people, String name, Integer age) {
+ // Null checks for people and name
+ final Integer ageFilter = age != null ? age : 0;
+
+ return people.stream()
+ .filter(p -> p.getName().equals(name))
+ .filter(p -> p.getAge().get() >= ageFilter)
+ .collect(Collectors.toList());
+ }
+
+ public static List search(List people, String name) {
+ return doSearch(people, name, 0);
+ }
+
+ public static List search(List people, String name, int age) {
+ return doSearch(people, name, age);
+ }
+
+ private static List doSearch(List people, String name, int age) {
+ // Null checks for people and name
+ return people.stream()
+ .filter(p -> p.getName().equals(name))
+ .filter(p -> p.getAge().get().intValue() >= age)
+ .collect(Collectors.toList());
+ }
}
diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml
index b3b9be9ee4..904cec2815 100644
--- a/core-java-modules/pom.xml
+++ b/core-java-modules/pom.xml
@@ -14,11 +14,110 @@
- pre-jpms
- core-java-optional
- core-java-lang-operators
- core-java-networking-2
+ core-java
+
+
+
+
+ core-java-8
+ core-java-8-2
+
+
+
+
+
+
+
+ core-java-annotations
+ core-java-arrays
+ core-java-arrays-2
+
+ core-java-collections
+ core-java-collections-2
+ core-java-collections-3
+ core-java-collections-array-list
+ core-java-collections-list
+ core-java-collections-list-2
+ core-java-collections-list-3
+ core-java-collections-set
+
+ core-java-concurrency-2
+ core-java-concurrency-advanced
+ core-java-concurrency-advanced-2
+ core-java-concurrency-advanced-3
+ core-java-concurrency-basic
+ core-java-concurrency-basic-2
+ core-java-concurrency-collections
+
+
core-java-date-operations-2
+
+
+
+ core-java-exceptions
+ core-java-exceptions-2
+
+ core-java-function
+
+ core-java-io
+ core-java-io-2
+ core-java-io-apis
+ core-java-io-conversions
+
+ core-java-jar
+ core-java-jndi
+
+ core-java-jvm
+
+ core-java-lambdas
+ core-java-lang
+ core-java-lang-2
+ core-java-lang-math
+ core-java-lang-oop
+ core-java-lang-oop-2
+ core-java-lang-oop-3
+ core-java-lang-oop-4
+ core-java-lang-operators
+ core-java-lang-syntax
+ core-java-lang-syntax-2
+
+ core-java-networking
+ core-java-networking-2
+ core-java-nio
+ core-java-nio-2
+
+ core-java-optional
+
+
+ core-java-perf
+
+ core-java-reflection
+
+ core-java-security
+ core-java-streams
+ core-java-streams-2
+ core-java-streams-3
+ core-java-string-algorithms
+ core-java-string-algorithms-2
+ core-java-string-algorithms-3
+ core-java-string-apis
+ core-java-string-conversions
+ core-java-string-conversions-2
+ core-java-string-operations
+ core-java-string-operations-2
+ core-java-strings
+ core-java-sun
+
+ core-java-text
+
+
+
+ pre-jpms
diff --git a/core-scala/src/test/scala/com/baeldung/scala/RegexUnitTest.scala b/core-scala/src/test/scala/com/baeldung/scala/RegexUnitTest.scala
new file mode 100644
index 0000000000..94263d620a
--- /dev/null
+++ b/core-scala/src/test/scala/com/baeldung/scala/RegexUnitTest.scala
@@ -0,0 +1,73 @@
+package com.baeldung.scala
+
+import org.junit.Test
+import org.junit.Assert.assertEquals
+
+class RegexUnitTest {
+ private val polishPostalCode = "([0-9]{2})\\-([0-9]{3})".r
+ private val timestamp = "([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{3})".r
+ private val timestampUnanchored = timestamp.unanchored
+
+ @Test
+ def givenRegularExpression_whenCallingFindFirstIn_thenShouldFindCorrectMatches(): Unit = {
+ val postCode = polishPostalCode.findFirstIn("Warsaw 01-011, Jerusalem Avenue")
+ assertEquals(Some("01-011"), postCode)
+ }
+
+ @Test
+ def givenRegularExpression_whenCallingFindFirstMatchIn_thenShouldFindCorrectMatches(): Unit = {
+ val postCodes = polishPostalCode.findFirstMatchIn("Warsaw 01-011, Jerusalem Avenue")
+ assertEquals(Some("011"), for (m <- postCodes) yield m.group(2))
+ }
+
+ @Test
+ def givenRegularExpression_whenCallingFindAllIn_thenShouldFindCorrectMatches(): Unit = {
+ val postCodes = polishPostalCode.findAllIn("Warsaw 01-011, Jerusalem Avenue, Cracow 30-059, Mickiewicza Avenue")
+ .toList
+ assertEquals(List("01-011", "30-059"), postCodes)
+
+ polishPostalCode.findAllIn("Warsaw 01-011, Jerusalem Avenue, Cracow 30-059, Mickiewicza Avenue")
+ }
+
+ @Test
+ def givenRegularExpression_whenCallingFindAlMatchlIn_thenShouldFindCorrectMatches(): Unit = {
+ val postCodes = polishPostalCode.findAllMatchIn("Warsaw 01-011, Jerusalem Avenue, Cracow 30-059, Mickiewicza Avenue")
+ .toList
+ val postalDistricts = for (m <- postCodes) yield m.group(1)
+ assertEquals(List("01", "30"), postalDistricts)
+ }
+
+ @Test
+ def givenRegularExpression_whenExtractingValues_thenShouldExtractCorrectValues(): Unit = {
+ val description = "11:34:01.411" match {
+ case timestamp(hour, minutes, _, _) => s"It's $minutes minutes after $hour"
+ }
+
+ assertEquals("It's 34 minutes after 11", description)
+ }
+
+ @Test
+ def givenUnanchoredRegularExpression_whenExtractingValues_thenShouldExtractCorrectValues(): Unit = {
+ val description = "Timestamp: 11:34:01.411 error appeared" match {
+ case timestampUnanchored(hour, minutes, _, _) => s"It's $minutes minutes after $hour"
+ }
+
+ assertEquals("It's 34 minutes after 11", description)
+ }
+
+ @Test
+ def givenRegularExpression_whenCallingReplaceAllIn_thenShouldReplaceText(): Unit = {
+ val minutes = timestamp.replaceAllIn("11:34:01.311", m => m.group(2))
+
+ assertEquals("34", minutes)
+ }
+
+ @Test
+ def givenRegularExpression_whenCallingReplaceAllInWithMatcher_thenShouldReplaceText(): Unit = {
+ val secondsThatDayInTotal = timestamp.replaceAllIn("11:34:01.311", _ match {
+ case timestamp(hours, minutes, seconds, _) => s"$hours-$minutes"
+ })
+
+ assertEquals("11-34", secondsThatDayInTotal)
+ }
+}
diff --git a/json-2/README.md b/json-2/README.md
new file mode 100644
index 0000000000..e7c3043339
--- /dev/null
+++ b/json-2/README.md
@@ -0,0 +1,5 @@
+## JSON
+
+This module contains articles about JSON.
+
+### Relevant Articles:
diff --git a/json-2/pom.xml b/json-2/pom.xml
new file mode 100644
index 0000000000..72b3295b2b
--- /dev/null
+++ b/json-2/pom.xml
@@ -0,0 +1,41 @@
+
+
+ com.baeldung
+ json-2
+ 0.0.1-SNAPSHOT
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+
+
+ com.jsoniter
+ jsoniter
+ ${jsoniter.version}
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+
+ 0.9.23
+ 3.11.1
+
+
diff --git a/json-2/src/main/java/com/baeldung/jsoniter/model/Name.java b/json-2/src/main/java/com/baeldung/jsoniter/model/Name.java
new file mode 100644
index 0000000000..ed5e221235
--- /dev/null
+++ b/json-2/src/main/java/com/baeldung/jsoniter/model/Name.java
@@ -0,0 +1,22 @@
+package com.baeldung.jsoniter.model;
+
+public class Name {
+ private String firstName;
+ private String surname;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getSurname() {
+ return surname;
+ }
+
+ public void setSurname(String surname) {
+ this.surname = surname;
+ }
+}
diff --git a/json-2/src/main/java/com/baeldung/jsoniter/model/Student.java b/json-2/src/main/java/com/baeldung/jsoniter/model/Student.java
new file mode 100644
index 0000000000..07c73dd18e
--- /dev/null
+++ b/json-2/src/main/java/com/baeldung/jsoniter/model/Student.java
@@ -0,0 +1,26 @@
+package com.baeldung.jsoniter.model;
+
+import com.jsoniter.annotation.JsonProperty;
+import com.jsoniter.fuzzy.MaybeStringIntDecoder;
+
+public class Student {
+ @JsonProperty(decoder = MaybeStringIntDecoder.class)
+ private int id;
+ private Name name;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Name getName() {
+ return name;
+ }
+
+ public void setName(Name name) {
+ this.name = name;
+ }
+}
diff --git a/json-2/src/test/java/com/baeldung/jsoniter/JsoniterIntroUnitTest.java b/json-2/src/test/java/com/baeldung/jsoniter/JsoniterIntroUnitTest.java
new file mode 100644
index 0000000000..09f82567a2
--- /dev/null
+++ b/json-2/src/test/java/com/baeldung/jsoniter/JsoniterIntroUnitTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.jsoniter;
+
+import com.baeldung.jsoniter.model.Name;
+import com.baeldung.jsoniter.model.Student;
+import com.jsoniter.JsonIterator;
+import com.jsoniter.ValueType;
+import com.jsoniter.any.Any;
+
+import org.junit.Test;
+
+import static com.jsoniter.ValueType.STRING;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class JsoniterIntroUnitTest {
+
+ @Test
+ public void whenParsedUsingBindAPI_thenConvertedToJavaObjectCorrectly() {
+ String input = "{\"id\":1,\"name\":{\"firstName\":\"Joe\",\"surname\":\"Blogg\"}}";
+
+ Student student = JsonIterator.deserialize(input, Student.class);
+
+ assertThat(student.getId()).isEqualTo(1);
+ assertThat(student.getName().getFirstName()).isEqualTo("Joe");
+ assertThat(student.getName().getSurname()).isEqualTo("Blogg");
+ }
+
+ @Test
+ public void givenTypeInJsonFuzzy_whenFieldIsMaybeDecoded_thenFieldParsedCorrectly() {
+ String input = "{\"id\":\"1\",\"name\":{\"firstName\":\"Joe\",\"surname\":\"Blogg\"}}";
+
+ Student student = JsonIterator.deserialize(input, Student.class);
+
+ assertThat(student.getId()).isEqualTo(1);
+ }
+
+ @Test
+ public void whenParsedUsingAnyAPI_thenFieldValueCanBeExtractedUsingTheFieldName() {
+ String input = "{\"id\":1,\"name\":{\"firstName\":\"Joe\",\"surname\":\"Blogg\"}}";
+
+ Any any = JsonIterator.deserialize(input);
+
+ assertThat(any.toInt("id")).isEqualTo(1);
+ assertThat(any.toString("name", "firstName")).isEqualTo("Joe");
+ assertThat(any.toString("name", "surname")).isEqualTo("Blogg");
+ }
+
+ @Test
+ public void whenParsedUsingAnyAPI_thenFieldValueTypeIsCorrect() {
+ String input = "{\"id\":1,\"name\":{\"firstName\":\"Joe\",\"surname\":\"Blogg\"}}";
+
+ Any any = JsonIterator.deserialize(input);
+
+ assertThat(any.get("id").valueType()).isEqualTo(ValueType.NUMBER);
+ assertThat(any.get("name").valueType()).isEqualTo(ValueType.OBJECT);
+ assertThat(any.get("error").valueType()).isEqualTo(ValueType.INVALID);
+ }
+
+ @Test
+ public void whenParsedUsingIteratorAPI_thenFieldValuesExtractedCorrectly() throws Exception {
+ Name name = new Name();
+ String input = "{ \"firstName\" : \"Joe\", \"surname\" : \"Blogg\" }";
+ JsonIterator iterator = JsonIterator.parse(input);
+
+ for (String field = iterator.readObject(); field != null; field = iterator.readObject()) {
+ switch (field) {
+ case "firstName":
+ if (iterator.whatIsNext() == ValueType.STRING) {
+ name.setFirstName(iterator.readString());
+ }
+ continue;
+ case "surname":
+ if (iterator.whatIsNext() == ValueType.STRING) {
+ name.setSurname(iterator.readString());
+ }
+ continue;
+ default:
+ iterator.skip();
+ }
+ }
+
+ assertThat(name.getFirstName()).isEqualTo("Joe");
+ assertThat(name.getSurname()).isEqualTo("Blogg");
+ }
+
+}
diff --git a/json-2/src/test/resources/Student.json b/json-2/src/test/resources/Student.json
new file mode 100644
index 0000000000..7ff3351e8e
--- /dev/null
+++ b/json-2/src/test/resources/Student.json
@@ -0,0 +1 @@
+{"id":1,"name":{"firstName": "Joe", "surname":"Blogg"}}
diff --git a/libraries-2/src/test/java/com/baeldung/handlebars/BuiltinHelperUnitTest.java b/libraries-2/src/test/java/com/baeldung/handlebars/BuiltinHelperUnitTest.java
index 6749f7fe0a..aa29e4c441 100644
--- a/libraries-2/src/test/java/com/baeldung/handlebars/BuiltinHelperUnitTest.java
+++ b/libraries-2/src/test/java/com/baeldung/handlebars/BuiltinHelperUnitTest.java
@@ -7,6 +7,8 @@ import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
import com.github.jknack.handlebars.io.TemplateLoader;
import java.io.IOException;
+
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -18,6 +20,7 @@ public class BuiltinHelperUnitTest {
private TemplateLoader templateLoader = new ClassPathTemplateLoader("/handlebars", ".html");
+ @Ignore
@Test
public void whenUsedWith_ThenContextChanges() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
@@ -30,6 +33,7 @@ public class BuiltinHelperUnitTest {
assertThat(templateString).isEqualTo("\nI live in World
\n");
}
+ @Ignore
@Test
public void whenUsedWithMustacheStyle_ThenContextChanges() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
@@ -42,6 +46,7 @@ public class BuiltinHelperUnitTest {
assertThat(templateString).isEqualTo("\nI live in World
\n");
}
+ @Ignore
@Test
public void whenUsedEach_ThenIterates() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
@@ -58,6 +63,7 @@ public class BuiltinHelperUnitTest {
+ "\nSpring is my friend.\n");
}
+ @Ignore
@Test
public void whenUsedEachMustacheStyle_ThenIterates() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
@@ -74,6 +80,7 @@ public class BuiltinHelperUnitTest {
+ "\nSpring is my friend.\n");
}
+ @Ignore
@Test
public void whenUsedIf_ThenPutsCondition() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
@@ -86,6 +93,7 @@ public class BuiltinHelperUnitTest {
assertThat(templateString).isEqualTo("\nBaeldung is busy.
\n");
}
+ @Ignore
@Test
public void whenUsedIfMustacheStyle_ThenPutsCondition() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
diff --git a/libraries-2/src/test/java/com/baeldung/handlebars/ReusingTemplatesUnitTest.java b/libraries-2/src/test/java/com/baeldung/handlebars/ReusingTemplatesUnitTest.java
index 36f78f486e..56449f59e4 100644
--- a/libraries-2/src/test/java/com/baeldung/handlebars/ReusingTemplatesUnitTest.java
+++ b/libraries-2/src/test/java/com/baeldung/handlebars/ReusingTemplatesUnitTest.java
@@ -7,6 +7,8 @@ import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
import com.github.jknack.handlebars.io.TemplateLoader;
import java.io.IOException;
+
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -18,6 +20,7 @@ public class ReusingTemplatesUnitTest {
private TemplateLoader templateLoader = new ClassPathTemplateLoader("/handlebars", ".html");
+ @Ignore
@Test
public void whenOtherTemplateIsReferenced_ThenCanReuse() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
@@ -30,6 +33,7 @@ public class ReusingTemplatesUnitTest {
assertThat(templateString).isEqualTo("Hi Baeldung!
\nThis is the page Baeldung
");
}
+ @Ignore
@Test
public void whenBlockIsDefined_ThenCanOverrideWithPartial() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
diff --git a/maven-all/pom.xml b/maven-all/pom.xml
new file mode 100644
index 0000000000..3a79a2a686
--- /dev/null
+++ b/maven-all/pom.xml
@@ -0,0 +1,25 @@
+
+
+ 4.0.0
+ maven-all
+ 0.0.1-SNAPSHOT
+ maven-all
+ pom
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ maven
+ maven-custom-plugin/counter-maven-plugin
+ maven-war-plugin
+ profiles
+ versions-maven-plugin
+
+
+
diff --git a/maven-polyglot/pom.xml b/maven-polyglot/pom.xml
new file mode 100644
index 0000000000..eb4e629a96
--- /dev/null
+++ b/maven-polyglot/pom.xml
@@ -0,0 +1,22 @@
+
+
+ 4.0.0
+ maven-polyglot
+ 0.0.1-SNAPSHOT
+ maven-polyglot
+ pom
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ maven-polyglot-json-extension
+
+
+
+
diff --git a/micronaut/src/main/resources/application.yml b/micronaut/src/main/resources/application.yml
index 4119026dd6..32daacd4aa 100644
--- a/micronaut/src/main/resources/application.yml
+++ b/micronaut/src/main/resources/application.yml
@@ -2,4 +2,4 @@ micronaut:
application:
name: hello-world-server
server:
- port: 9080
\ No newline at end of file
+ port: ${random.port}
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java b/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java
index 022099eed0..6ce9bcad45 100644
--- a/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java
+++ b/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java
@@ -5,9 +5,9 @@ import java.util.List;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
-import com.baeldung.multipledb.model.product.ProductMultipleDB;
+import com.baeldung.multipledb.model.product.Product;
-public interface ProductRepository extends PagingAndSortingRepository {
+public interface ProductRepository extends PagingAndSortingRepository {
- List findAllByPrice(double price, Pageable pageable);
+ List findAllByPrice(double price, Pageable pageable);
}
diff --git a/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java b/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/Product.java
similarity index 80%
rename from persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java
rename to persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/Product.java
index 8bdff340ac..eaf471043c 100644
--- a/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java
+++ b/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/Product.java
@@ -6,7 +6,7 @@ import javax.persistence.Table;
@Entity
@Table(schema = "products")
-public class ProductMultipleDB {
+public class Product {
@Id
private int id;
@@ -15,19 +15,19 @@ public class ProductMultipleDB {
private double price;
- public ProductMultipleDB() {
+ public Product() {
super();
}
- private ProductMultipleDB(int id, String name, double price) {
+ private Product(int id, String name, double price) {
super();
this.id = id;
this.name = name;
this.price = price;
}
- public static ProductMultipleDB from(int id, String name, double price) {
- return new ProductMultipleDB(id, name, price);
+ public static Product from(int id, String name, double price) {
+ return new Product(id, name, price);
}
public int getId() {
diff --git a/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java
index cdbb307d7f..831790af95 100644
--- a/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java
+++ b/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java
@@ -23,7 +23,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import com.baeldung.multipledb.dao.product.ProductRepository;
-import com.baeldung.multipledb.model.product.ProductMultipleDB;
+import com.baeldung.multipledb.model.product.Product;
@RunWith(SpringRunner.class)
@SpringBootTest(classes=MultipleDbApplication.class)
@@ -36,22 +36,22 @@ public class ProductRepositoryIntegrationTest {
@Before
@Transactional("productTransactionManager")
public void setUp() {
- productRepository.save(ProductMultipleDB.from(1001, "Book", 21));
- productRepository.save(ProductMultipleDB.from(1002, "Coffee", 10));
- productRepository.save(ProductMultipleDB.from(1003, "Jeans", 30));
- productRepository.save(ProductMultipleDB.from(1004, "Shirt", 32));
- productRepository.save(ProductMultipleDB.from(1005, "Bacon", 10));
+ productRepository.save(Product.from(1001, "Book", 21));
+ productRepository.save(Product.from(1002, "Coffee", 10));
+ productRepository.save(Product.from(1003, "Jeans", 30));
+ productRepository.save(Product.from(1004, "Shirt", 32));
+ productRepository.save(Product.from(1005, "Bacon", 10));
}
@Test
public void whenRequestingFirstPageOfSizeTwo_ThenReturnFirstPage() {
Pageable pageRequest = PageRequest.of(0, 2);
- Page result = productRepository.findAll(pageRequest);
+ Page result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(2));
assertTrue(result.stream()
- .map(ProductMultipleDB::getId)
+ .map(Product::getId)
.allMatch(id -> Arrays.asList(1001, 1002)
.contains(id)));
}
@@ -60,11 +60,11 @@ public class ProductRepositoryIntegrationTest {
public void whenRequestingSecondPageOfSizeTwo_ThenReturnSecondPage() {
Pageable pageRequest = PageRequest.of(1, 2);
- Page result = productRepository.findAll(pageRequest);
+ Page result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(2));
assertTrue(result.stream()
- .map(ProductMultipleDB::getId)
+ .map(Product::getId)
.allMatch(id -> Arrays.asList(1003, 1004)
.contains(id)));
}
@@ -73,11 +73,11 @@ public class ProductRepositoryIntegrationTest {
public void whenRequestingLastPage_ThenReturnLastPageWithRemData() {
Pageable pageRequest = PageRequest.of(2, 2);
- Page result = productRepository.findAll(pageRequest);
+ Page result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(1));
assertTrue(result.stream()
- .map(ProductMultipleDB::getId)
+ .map(Product::getId)
.allMatch(id -> Arrays.asList(1005)
.contains(id)));
}
@@ -86,12 +86,12 @@ public class ProductRepositoryIntegrationTest {
public void whenSortingByNameAscAndPaging_ThenReturnSortedPagedResult() {
Pageable pageRequest = PageRequest.of(0, 3, Sort.by("name"));
- Page result = productRepository.findAll(pageRequest);
+ Page result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(3));
assertThat(result.getContent()
.stream()
- .map(ProductMultipleDB::getId)
+ .map(Product::getId)
.collect(Collectors.toList()), equalTo(Arrays.asList(1005, 1001, 1002)));
}
@@ -101,12 +101,12 @@ public class ProductRepositoryIntegrationTest {
Pageable pageRequest = PageRequest.of(0, 3, Sort.by("price")
.descending());
- Page result = productRepository.findAll(pageRequest);
+ Page result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(3));
assertThat(result.getContent()
.stream()
- .map(ProductMultipleDB::getId)
+ .map(Product::getId)
.collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001)));
}
@@ -117,12 +117,12 @@ public class ProductRepositoryIntegrationTest {
.descending()
.and(Sort.by("name")));
- Page result = productRepository.findAll(pageRequest);
+ Page result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(5));
assertThat(result.getContent()
.stream()
- .map(ProductMultipleDB::getId)
+ .map(Product::getId)
.collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001, 1005, 1002)));
}
@@ -131,11 +131,11 @@ public class ProductRepositoryIntegrationTest {
public void whenRequestingFirstPageOfSizeTwoUsingCustomMethod_ThenReturnFirstPage() {
Pageable pageRequest = PageRequest.of(0, 2);
- List result = productRepository.findAllByPrice(10, pageRequest);
+ List result = productRepository.findAllByPrice(10, pageRequest);
assertThat(result, hasSize(2));
assertTrue(result.stream()
- .map(ProductMultipleDB::getId)
+ .map(Product::getId)
.allMatch(id -> Arrays.asList(1002, 1005)
.contains(id)));
}
diff --git a/pom.xml b/pom.xml
index 666ef838dd..e641aebe7d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -332,20 +332,23 @@
parent-spring-5
parent-java
parent-kotlin
-
+
+ akka-http
akka-streams
+
algorithms-genetic
algorithms-miscellaneous-1
algorithms-miscellaneous-2
algorithms-miscellaneous-3
algorithms-miscellaneous-4
algorithms-miscellaneous-5
+ algorithms-searching
algorithms-sorting
algorithms-sorting-2
- algorithms-searching
animal-sniffer-mvn-plugin
annotations
antlr
+
apache-avro
apache-bval
apache-curator
@@ -366,12 +369,18 @@
apache-tika
apache-velocity
apache-zookeeper
+
asciidoctor
asm
+
atomix
+
aws
aws-lambda
+ aws-reactive
+
axon
+
azure
bazel
@@ -381,83 +390,18 @@
cas
cdi
checker-plugin
- cloud-foundry-uaa/cf-uaa-oauth2-client
- cloud-foundry-uaa/cf-uaa-oauth2-resource-server
+
+ cloud-foundry-uaa
code-generation
+
core-groovy
core-groovy-2
core-groovy-collections
-
-
-
- core-java-modules/core-java-8
- core-java-modules/core-java-8-2
- core-java-modules/core-java-annotations
- core-java-modules/core-java-streams
- core-java-modules/core-java-streams-2
- core-java-modules/core-java-streams-3
-
- core-java-modules/core-java-function
- core-java-modules/core-java-lang-math
-
-
- core-java-modules/core-java-text
- core-java-modules/core-java-lambdas
-
-
- core-java-modules/core-java-arrays
- core-java-modules/core-java-arrays-2
- core-java-modules/core-java-collections
- core-java-modules/core-java-collections-2
- core-java-modules/core-java-collections-3
- core-java-modules/core-java-collections-list
- core-java-modules/core-java-collections-list-2
- core-java-modules/core-java-collections-list-3
- core-java-modules/core-java-collections-array-list
- core-java-modules/core-java-collections-set
- core-java-modules/core-java-concurrency-basic
- core-java-modules/core-java-concurrency-basic-2
- core-java-modules/core-java-concurrency-collections
- core-java-modules/core-java-io
- core-java-modules/core-java-io-2
- core-java-modules/core-java-io-apis
- core-java-modules/core-java-io-conversions
- core-java-modules/core-java-nio
- core-java-modules/core-java-nio-2
- core-java-modules/core-java-security
- core-java-modules/core-java-exceptions
- core-java-modules/core-java-lang-syntax
- core-java-modules/core-java-lang-syntax-2
- core-java-modules/core-java-lang
- core-java-modules/core-java-lang-2
- core-java-modules/core-java-lang-oop
- core-java-modules/core-java-lang-oop-2
- core-java-modules/core-java-lang-oop-3
- core-java-modules/core-java-lang-oop-4
+
core-java-modules
- core-java-modules/core-java-networking
- core-java-modules/core-java-perf
- core-java-modules/core-java-reflection
- core-java-modules/core-java-sun
- core-java-modules/core-java-string-conversions
- core-java-modules/core-java-string-conversions-2
- core-java-modules/core-java-string-operations
- core-java-modules/core-java-string-operations-2
- core-java-modules/core-java-string-algorithms
- core-java-modules/core-java-string-algorithms-2
- core-java-modules/core-java-string-apis
- core-java-modules/core-java-strings
- core-java-modules/core-java
- core-java-modules/core-java-jar
- core-java-modules/core-java-jvm
core-kotlin-modules
core-scala
+
couchbase
custom-pmd
@@ -479,15 +423,16 @@
google-cloud
google-web-toolkit
+
graphql/graphql-java
grpc
gson
guava
- guava-io
guava-collections
guava-collections-map
guava-collections-set
+ guava-io
guava-modules
guice
@@ -502,12 +447,16 @@
immutables
jackson-modules
+ java-blockchain
+
java-collections-conversions
java-collections-conversions-2
java-collections-maps
java-collections-maps-2
- java-jdi
+
+ javafx
+ java-jdi
java-lite
java-math
java-math-2
@@ -518,12 +467,10 @@
java-spi
java-vavr-stream
java-websocket
- javafx
javax-servlets
javaxval
jaxb
-
+ jee-7
jee-7-security
jee-kotlin
jersey
@@ -538,6 +485,7 @@
jooby
jsf
json
+ json-2
json-path
jsoup
jta
@@ -545,52 +493,51 @@
kotlin-libraries
kotlin-libraries-2
+ kotlin-quasar
- libraries
libraries-2
libraries-3
+ libraries-apache-commons
+ libraries-apache-commons-collections
+ libraries-apache-commons-io
libraries-data
libraries-data-2
libraries-data-db
libraries-data-io
- libraries-apache-commons
- libraries-apache-commons-collections
- libraries-apache-commons-io
- libraries-primitive
- libraries-testing
- libraries-security
- libraries-server
libraries-http
libraries-io
+ libraries-primitive
+ libraries-security
+ libraries-server
+ libraries-testing
linkrest
logging-modules
lombok
+ lombok-custom
lucene
+ machine-learning
mapstruct
-
- maven-all/maven
- maven-all/maven-custom-plugin/counter-maven-plugin
- maven-all/maven-war-plugin
- maven-all/profiles
- maven-all/versions-maven-plugin
+
+ maven-all
maven-archetype
-
- maven-polyglot/maven-polyglot-json-extension
-
+
+ maven-polyglot
+
mesos-marathon
metrics
-
+ micronaut
microprofile
msf4j
-
+
mustache
mybatis
- ninja
netflix-modules
+ ninja
+ oauth2-framework-impl
optaplanner
orika
osgi
@@ -598,11 +545,12 @@
patterns
pdf
performance-tests
+ persistence-modules
protobuffer
- persistence-modules
quarkus
+
rabbitmq
@@ -610,32 +558,12 @@
reactor-core
resteasy
restx
-
- rule-engines
rsocket
+ rule-engines
rxjava-core
+ rxjava-libraries
rxjava-observables
rxjava-operators
- rxjava-libraries
- software-security/sql-injection-samples
-
- tensorflow-java
- spf4j
- spring-boot-config-jpa-error
- spring-boot-flowable
- spring-boot-mvc-2
- spring-boot-performance
- spring-boot-properties
- spring-mvc-basics
- spring-security-modules/spring-security-kerberos
- oauth2-framework-impl
-
- spring-boot-nashorn
- java-blockchain
- machine-learning
- webrtc
- wildfly
- quarkus-extension
@@ -671,8 +599,6 @@
- netflix-modules
-
parent-boot-1
parent-boot-2
parent-spring-4
@@ -681,12 +607,14 @@
parent-kotlin
saas
+ software-security/sql-injection-samples
+
spark-java
+ spf4j
spring-4
spring-5
- spring-5-webflux
spring-5-data-reactive
spring-5-mvc
spring-5-reactive
@@ -695,55 +623,63 @@
spring-5-reactive-oauth
spring-5-reactive-security
spring-5-security
- spring-5-security-oauth
spring-5-security-cognito
+ spring-5-security-oauth
+ spring-5-webflux
spring-activiti
spring-akka
spring-amqp
spring-aop
spring-apache-camel
+
spring-batch
spring-bom
spring-boot
spring-boot-admin
spring-boot-angular
+ spring-boot-artifacts
spring-boot-autoconfiguration
spring-boot-bootstrap
spring-boot-camel
- spring-boot-config-jpa-error
spring-boot-client
-
+ spring-boot-config-jpa-error
spring-boot-crud
spring-boot-ctx-fluent
spring-boot-custom-starter
+ spring-boot-data
+ spring-boot-deployment
+ spring-boot-di
+ spring-boot-environment
+ spring-boot-flowable
spring-boot-jasypt
spring-boot-keycloak
spring-boot-kotlin
+ spring-boot-libraries
spring-boot-logging-log4j2
spring-boot-mvc
+ spring-boot-mvc-2
spring-boot-mvc-birt
- spring-boot-environment
- spring-boot-deployment
+ spring-boot-nashorn
+ spring-boot-parent
+ spring-boot-performance
+ spring-boot-properties
+ spring-boot-property-exp
+
+ spring-boot-rest
spring-boot-runtime
spring-boot-runtime/disabling-console-jul
spring-boot-runtime/disabling-console-log4j2
spring-boot-runtime/disabling-console-logback
- spring-boot-artifacts
- spring-boot-rest
- spring-boot-data
- spring-boot-parent
- spring-boot-property-exp
spring-boot-security
spring-boot-springdoc
spring-boot-testing
spring-boot-vue
- spring-caching
- spring-boot-libraries
+ spring-caching
spring-cloud
spring-cloud-bus
@@ -757,9 +693,9 @@
spring-data-rest
spring-data-rest-querydsl
+ spring-di
spring-dispatcher-servlet
spring-drools
- spring-di
spring-ehcache
spring-ejb
@@ -784,60 +720,41 @@
spring-mobile
spring-mockito
- spring-websockets
+
+ spring-mvc-basics
+ spring-mvc-basics-2
+ spring-mvc-basics-3
spring-mvc-basics-4
+
spring-mvc-forms-jsp
spring-mvc-forms-thymeleaf
spring-mvc-java
spring-mvc-kotlin
- spring-mvc-basics-2
- spring-mvc-basics-3
- spring-mvc-views
+
spring-mvc-velocity
+ spring-mvc-views
spring-mvc-webflow
spring-mvc-xml
spring-protobuf
-
-
spring-quartz
spring-reactive-kotlin
spring-reactor
spring-remoting
- spring-rest-http
spring-rest-angular
spring-rest-compress
- spring-rest-testing
spring-rest-hal-browser
+ spring-rest-http
spring-rest-query-language
spring-rest-shell
spring-rest-simple
spring-resttemplate
-
+ spring-rest-testing
+ spring-roo
+
spring-scheduling
- spring-security-modules/spring-security-acl
- spring-security-modules/spring-security-angular/server
- spring-security-modules/spring-security-cache-control
- spring-security-modules/spring-security-core
- spring-security-modules/spring-security-mvc
- spring-security-modules/spring-security-mvc-boot
- spring-security-modules/spring-security-mvc-custom
- spring-security-modules/spring-security-mvc-digest-auth
- spring-security-modules/spring-security-mvc-jsonview
- spring-security-modules/spring-security-mvc-ldap
- spring-security-modules/spring-security-mvc-login
- spring-security-modules/spring-security-mvc-persisted-remember-me
- spring-security-modules/spring-security-mvc-socket
- spring-security-modules/spring-security-oidc
-
- spring-security-modules/spring-security-rest
- spring-security-modules/spring-security-rest-basic-auth
- spring-security-modules/spring-security-rest-custom
- spring-security-modules/spring-security-sso
- spring-security-modules/spring-security-stormpath
- spring-security-modules/spring-security-thymeleaf
- spring-security-modules/spring-security-x509
+ spring-security-modules
spring-session
spring-shell
spring-sleuth
@@ -849,17 +766,20 @@
spring-swagger-codegen
spring-thymeleaf
+ spring-thymeleaf-2
spring-vault
spring-vertx
spring-webflux-amqp
+ spring-websockets
static-analysis
stripe
structurizr
struts-2
+ tensorflow-java
testing-modules
twilio
@@ -872,17 +792,11 @@
video-tutorials
vraptor
+ webrtc
wicket
-
+ wildfly
xml
xstream
-
- tensorflow-java
- spring-boot-flowable
- spring-security-modules/spring-security-kerberos
-
- spring-boot-nashorn
- java-blockchain
@@ -925,9 +839,6 @@
parent-java
parent-kotlin
- core-java-modules/core-java-concurrency-advanced
- core-java-modules/core-java-concurrency-advanced-2
- core-java-modules/core-java-concurrency-advanced-3
core-kotlin
core-kotlin-2
@@ -936,12 +847,6 @@
jws
libraries
- persistence-modules/hibernate5
- persistence-modules/hibernate-mapping
- persistence-modules/java-jpa
- persistence-modules/java-jpa-2
- persistence-modules/java-mongodb
- persistence-modules/jnosql
vaadin
vavr
@@ -977,20 +882,23 @@
parent-spring-5
parent-java
parent-kotlin
-
+
+ akka-http
akka-streams
+
algorithms-genetic
algorithms-miscellaneous-1
algorithms-miscellaneous-2
algorithms-miscellaneous-3
algorithms-miscellaneous-4
algorithms-miscellaneous-5
+ algorithms-searching
algorithms-sorting
algorithms-sorting-2
- algorithms-searching
animal-sniffer-mvn-plugin
annotations
antlr
+
apache-avro
apache-bval
apache-curator
@@ -1011,90 +919,39 @@
apache-tika
apache-velocity
apache-zookeeper
+
asciidoctor
asm
+
atomix
+
aws
aws-lambda
+ aws-reactive
+
axon
+
azure
+
bazel
+ blade
bootique
cas
cdi
checker-plugin
- cloud-foundry-uaa/cf-uaa-oauth2-client
- cloud-foundry-uaa/cf-uaa-oauth2-resource-server
+
+ cloud-foundry-uaa
code-generation
+
core-groovy
core-groovy-2
core-groovy-collections
-
-
- core-java-modules/core-java-8
- core-java-modules/core-java-8-2
- core-java-modules/core-java-annotations
- core-java-modules/core-java-streams
- core-java-modules/core-java-streams-2
- core-java-modules/core-java-streams-3
-
- core-java-modules/core-java-function
- core-java-modules/core-java-lang-math
-
-
- core-java-modules/core-java-text
-
-
- core-java-modules/core-java-arrays
- core-java-modules/core-java-arrays-2
- core-java-modules/core-java-collections
- core-java-modules/core-java-collections-2
- core-java-modules/core-java-collections-3
- core-java-modules/core-java-collections-list
- core-java-modules/core-java-collections-list-2
- core-java-modules/core-java-collections-list-3
- core-java-modules/core-java-collections-array-list
- core-java-modules/core-java-collections-set
- core-java-modules/core-java-concurrency-basic
- core-java-modules/core-java-concurrency-basic-2
- core-java-modules/core-java-concurrency-collections
- core-java-modules/core-java-io
- core-java-modules/core-java-io-2
- core-java-modules/core-java-io-apis
- core-java-modules/core-java-io-conversions
- core-java-modules/core-java-nio
- core-java-modules/core-java-nio-2
- core-java-modules/core-java-security
- core-java-modules/core-java-exceptions
- core-java-modules/core-java-lang-syntax
- core-java-modules/core-java-lang-syntax-2
- core-java-modules/core-java-lang
- core-java-modules/core-java-lang-2
- core-java-modules/core-java-lang-oop
- core-java-modules/core-java-lang-oop-2
- core-java-modules/core-java-lang-oop-3
- core-java-modules/core-java-lang-oop-4
+
core-java-modules
- core-java-modules/core-java-networking
- core-java-modules/core-java-perf
- core-java-modules/core-java-sun
- core-java-modules/core-java-string-conversions
- core-java-modules/core-java-string-conversions-2
- core-java-modules/core-java-string-operations
- core-java-modules/core-java-string-operations-2
- core-java-modules/core-java-string-algorithms
- core-java-modules/core-java-string-algorithms-2
- core-java-modules/core-java-string-apis
- core-java-modules/core-java-strings
core-kotlin-modules
core-scala
+
couchbase
custom-pmd
@@ -1116,15 +973,16 @@
google-cloud
google-web-toolkit
+
graphql/graphql-java
grpc
gson
guava
- guava-io
guava-collections
guava-collections-map
guava-collections-set
+ guava-io
guava-modules
guice
@@ -1139,15 +997,19 @@
immutables
jackson-modules
+ java-blockchain
+
java-collections-conversions
java-collections-conversions-2
java-collections-maps
java-collections-maps-2
+
+
+ javafx
java-jdi
- java-ee-8-security-api
java-lite
java-math
- java-math-2
+ java-math-2
java-numbers
java-numbers-2
java-numbers-3
@@ -1155,12 +1017,10 @@
java-spi
java-vavr-stream
java-websocket
- javafx
javax-servlets
javaxval
jaxb
-
+ jee-7
jee-7-security
jee-kotlin
jersey
@@ -1181,50 +1041,52 @@
kotlin-libraries
+ kotlin-libraries-2
+ kotlin-quasar
- libraries
+ libraries-2
libraries-3
+ libraries-apache-commons
+ libraries-apache-commons-collections
+ libraries-apache-commons-io
libraries-data
libraries-data-2
libraries-data-db
libraries-data-io
- libraries-apache-commons
- libraries-apache-commons-collections
- libraries-apache-commons-io
- libraries-testing
+ libraries-http
+ libraries-io
+ libraries-primitive
libraries-security
libraries-server
- libraries-http
+ libraries-testing
linkrest
logging-modules
lombok
+ lombok-custom
lucene
+ machine-learning
mapstruct
-
- maven-all/maven
- maven-all/maven-custom-plugin/counter-maven-plugin
- maven-all/maven-war-plugin
- maven-all/profiles
- maven-all/versions-maven-plugin
-
+
+ maven-all
maven-archetype
-
- maven-polyglot/maven-polyglot-json-extension
-
+
+ maven-polyglot
+
mesos-marathon
metrics
-
+ micronaut
microprofile
msf4j
-
+
mustache
mybatis
- ninja
netflix-modules
+ ninja
+ oauth2-framework-impl
optaplanner
orika
osgi
@@ -1232,10 +1094,12 @@
patterns
pdf
performance-tests
+ persistence-modules
protobuffer
- persistence-modules
+ quarkus
+
rabbitmq
@@ -1243,20 +1107,12 @@
reactor-core
resteasy
restx
-
- rule-engines
rsocket
+ rule-engines
rxjava-core
+ rxjava-libraries
rxjava-observables
rxjava-operators
- rxjava-libraries
- oauth2-framework-impl
- spf4j
- spring-boot-performance
- spring-boot-properties
- spring-mvc-basics
-
-
@@ -1292,7 +1148,10 @@
parent-kotlin
saas
+ software-security/sql-injection-samples
+
spark-java
+ spf4j
spring-4
@@ -1305,48 +1164,64 @@
spring-5-reactive-oauth
spring-5-reactive-security
spring-5-security
- spring-5-security-oauth
spring-5-security-cognito
+ spring-5-security-oauth
+ spring-5-webflux
+
spring-activiti
spring-akka
spring-amqp
spring-aop
spring-apache-camel
+
spring-batch
spring-bom
spring-boot
spring-boot-admin
spring-boot-angular
+ spring-boot-artifacts
spring-boot-autoconfiguration
spring-boot-bootstrap
spring-boot-camel
spring-boot-client
+ spring-boot-config-jpa-error
spring-boot-crud
spring-boot-ctx-fluent
spring-boot-custom-starter
+ spring-boot-data
+ spring-boot-deployment
+ spring-boot-di
+ spring-boot-environment
+ spring-boot-flowable
spring-boot-jasypt
spring-boot-keycloak
+ spring-boot-kotlin
+ spring-boot-libraries
spring-boot-logging-log4j2
spring-boot-mvc
+ spring-boot-mvc-2
spring-boot-mvc-birt
- spring-boot-environment
- spring-boot-deployment
+ spring-boot-nashorn
+ spring-boot-parent
+ spring-boot-performance
+ spring-boot-properties
+ spring-boot-property-exp
+
+ spring-boot-rest
spring-boot-runtime
spring-boot-runtime/disabling-console-jul
spring-boot-runtime/disabling-console-log4j2
spring-boot-runtime/disabling-console-logback
- spring-boot-artifacts
- spring-boot-rest
- spring-boot-data
- spring-boot-parent
- spring-boot-property-exp
spring-boot-security
spring-boot-springdoc
+ spring-boot-testing
spring-boot-vue
+
spring-caching
+
spring-cloud
spring-cloud-bus
@@ -1359,9 +1234,9 @@
spring-data-rest
spring-data-rest-querydsl
+ spring-di
spring-dispatcher-servlet
spring-drools
- spring-di
spring-ehcache
spring-ejb
@@ -1386,60 +1261,41 @@
spring-mobile
spring-mockito
- spring-websockets
+
+ spring-mvc-basics
+ spring-mvc-basics-2
+ spring-mvc-basics-3
+ spring-mvc-basics-4
+
spring-mvc-forms-jsp
spring-mvc-forms-thymeleaf
spring-mvc-java
spring-mvc-kotlin
- spring-mvc-basics-2
- spring-mvc-basics-3
- spring-mvc-basics-4
- spring-mvc-views
+
spring-mvc-velocity
+ spring-mvc-views
spring-mvc-webflow
spring-mvc-xml
spring-protobuf
-
-
spring-quartz
spring-reactive-kotlin
spring-reactor
spring-remoting
- spring-rest-http
spring-rest-angular
spring-rest-compress
- spring-rest-testing
spring-rest-hal-browser
+ spring-rest-http
spring-rest-query-language
spring-rest-shell
spring-rest-simple
spring-resttemplate
-
+ spring-rest-testing
+ spring-roo
spring-scheduling
- spring-security-modules/spring-security-acl
- spring-security-modules/spring-security-angular/server
- spring-security-modules/spring-security-cache-control
- spring-security-modules/spring-security-core
- spring-security-modules/spring-security-mvc
- spring-security-modules/spring-security-mvc-boot
- spring-security-modules/spring-security-mvc-custom
- spring-security-modules/spring-security-mvc-digest-auth
- spring-security-modules/spring-security-mvc-ldap
- spring-security-modules/spring-security-mvc-login
- spring-security-modules/spring-security-mvc-persisted-remember-me
- spring-security-modules/spring-security-mvc-socket
- spring-security-modules/spring-security-oidc
-
- spring-security-modules/spring-security-rest
- spring-security-modules/spring-security-rest-basic-auth
- spring-security-modules/spring-security-rest-custom
- spring-security-modules/spring-security-sso
- spring-security-modules/spring-security-stormpath
- spring-security-modules/spring-security-thymeleaf
- spring-security-modules/spring-security-x509
+ spring-security-modules
spring-session
spring-shell
spring-sleuth
@@ -1451,17 +1307,20 @@
spring-swagger-codegen
spring-thymeleaf
+ spring-thymeleaf-2
spring-vault
spring-vertx
spring-webflux-amqp
+ spring-websockets
static-analysis
stripe
structurizr
struts-2
+ tensorflow-java
testing-modules
twilio
@@ -1474,8 +1333,9 @@
video-tutorials
vraptor
+ webrtc
wicket
-
+ wildfly
xml
xstream
@@ -1512,11 +1372,6 @@
parent-java
parent-kotlin
- core-java-modules/core-java
- core-java-modules/core-java-jar
- core-java-modules/core-java-concurrency-advanced
- core-java-modules/core-java-concurrency-advanced-2
- core-java-modules/core-java-concurrency-advanced-3
core-kotlin
core-kotlin-2
@@ -1526,13 +1381,6 @@
libraries
- persistence-modules/hibernate5
- persistence-modules/hibernate-mapping
- persistence-modules/java-jpa
- persistence-modules/java-jpa-2
- persistence-modules/java-mongodb
- persistence-modules/jnosql
-
vaadin
vavr
diff --git a/slack/pom.xml b/slack/pom.xml
new file mode 100644
index 0000000000..ebe5ce2f60
--- /dev/null
+++ b/slack/pom.xml
@@ -0,0 +1,61 @@
+
+
+ 4.0.0
+ com.baeldung.examples
+ slack
+ 1.0
+ slack
+ jar
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ com.hubspot.slack
+ slack-base
+ ${slack.version}
+
+
+ com.hubspot.slack
+ slack-java-client
+ ${slack.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ ${maven-jar-plugin.version}
+
+
+
+ true
+ com.baeldung.examples.slack.MainClass
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.6.0
+
+ com.baeldung.examples.slack.MainClass
+
+
+
+
+
+
+ 1.4
+ 2.4
+
+
+
diff --git a/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java b/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java
new file mode 100644
index 0000000000..7a3f5cd607
--- /dev/null
+++ b/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java
@@ -0,0 +1,42 @@
+package com.baeldung.examples.slack;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DiskSpaceErrorChecker implements ErrorChecker {
+ private static final Logger LOG = LoggerFactory.getLogger(DiskSpaceErrorChecker.class);
+
+ private final ErrorReporter errorReporter;
+
+ private final double limit;
+
+ public DiskSpaceErrorChecker(ErrorReporter errorReporter, double limit) {
+ this.errorReporter = errorReporter;
+ this.limit = limit;
+ }
+
+ @Override
+ public void check() {
+ LOG.info("Checking disk space");
+ FileSystems.getDefault().getFileStores().forEach(fileStore -> {
+ try {
+ long totalSpace = fileStore.getTotalSpace();
+ long usableSpace = fileStore.getUsableSpace();
+ double usablePercentage = ((double) usableSpace) / totalSpace;
+ LOG.debug("File store {} has {} of {} ({}) usable space",
+ fileStore, usableSpace, totalSpace, usablePercentage);
+
+ if (totalSpace > 0 && usablePercentage < limit) {
+ String error = String.format("File store %s only has %d%% usable disk space",
+ fileStore.name(), (int)(usablePercentage * 100));
+ errorReporter.reportProblem(error);
+ }
+ } catch (IOException e) {
+ LOG.error("Error getting disk space for file store {}", fileStore, e);
+ }
+ });
+ }
+}
diff --git a/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java b/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java
new file mode 100644
index 0000000000..08db9a7817
--- /dev/null
+++ b/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java
@@ -0,0 +1,5 @@
+package com.baeldung.examples.slack;
+
+public interface ErrorChecker {
+ void check();
+}
diff --git a/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java b/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java
new file mode 100644
index 0000000000..ba6165af9b
--- /dev/null
+++ b/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java
@@ -0,0 +1,5 @@
+package com.baeldung.examples.slack;
+
+public interface ErrorReporter {
+ void reportProblem(String problem);
+}
diff --git a/slack/src/main/java/com/baeldung/examples/slack/MainClass.java b/slack/src/main/java/com/baeldung/examples/slack/MainClass.java
new file mode 100644
index 0000000000..ac25e97cf6
--- /dev/null
+++ b/slack/src/main/java/com/baeldung/examples/slack/MainClass.java
@@ -0,0 +1,41 @@
+package com.baeldung.examples.slack;
+
+import java.io.IOException;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import com.hubspot.slack.client.SlackClient;
+import com.hubspot.slack.client.SlackClientFactory;
+import com.hubspot.slack.client.SlackClientRuntimeConfig;
+
+public class MainClass {
+ public static final long MINUTES = 1000 * 60;
+
+ public static void main(String[] args) throws IOException {
+ SlackClientRuntimeConfig runtimeConfig = SlackClientRuntimeConfig.builder()
+ .setTokenSupplier(() -> "")
+ .build();
+
+ SlackClient slackClient = SlackClientFactory.defaultFactory().build(runtimeConfig);
+
+ ErrorReporter slackChannelErrorReporter = new SlackChannelErrorReporter(slackClient, "general");
+ ErrorReporter slackUserErrorReporter = new SlackUserErrorReporter(slackClient, "testuser@baeldung.com");
+
+ ErrorChecker diskSpaceErrorChecker10pct = new DiskSpaceErrorChecker(slackChannelErrorReporter, 0.1);
+ ErrorChecker diskSpaceErrorChecker2pct = new DiskSpaceErrorChecker(slackUserErrorReporter, 0.02);
+
+ Timer timer = new Timer();
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ diskSpaceErrorChecker10pct.check();
+ }
+ }, 0, 5 * MINUTES);
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ diskSpaceErrorChecker2pct.check();
+ }
+ }, 0, 5 * MINUTES);
+ }
+}
diff --git a/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java b/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java
new file mode 100644
index 0000000000..f7abcecc2e
--- /dev/null
+++ b/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java
@@ -0,0 +1,30 @@
+package com.baeldung.examples.slack;
+
+import com.hubspot.slack.client.SlackClient;
+import com.hubspot.slack.client.methods.params.chat.ChatPostMessageParams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SlackChannelErrorReporter implements ErrorReporter {
+ private static final Logger LOG = LoggerFactory.getLogger(SlackChannelErrorReporter.class);
+
+ private final SlackClient slackClient;
+
+ private final String channel;
+
+ public SlackChannelErrorReporter(SlackClient slackClient, String channel) {
+ this.slackClient = slackClient;
+ this.channel = channel;
+ }
+
+ @Override
+ public void reportProblem(String problem) {
+ LOG.debug("Sending message to channel {}: {}", channel, problem);
+ slackClient.postMessage(
+ ChatPostMessageParams.builder()
+ .setText(problem)
+ .setChannelId(channel)
+ .build()
+ ).join().unwrapOrElseThrow();
+ }
+}
diff --git a/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java b/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java
new file mode 100644
index 0000000000..8fa4f9016b
--- /dev/null
+++ b/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java
@@ -0,0 +1,52 @@
+package com.baeldung.examples.slack;
+
+import java.util.List;
+
+import com.hubspot.slack.client.SlackClient;
+import com.hubspot.slack.client.methods.params.chat.ChatPostMessageParams;
+import com.hubspot.slack.client.methods.params.conversations.ConversationCreateParams;
+import com.hubspot.slack.client.methods.params.im.ImOpenParams;
+import com.hubspot.slack.client.methods.params.users.UserEmailParams;
+import com.hubspot.slack.client.methods.params.users.UsersInfoParams;
+import com.hubspot.slack.client.models.response.im.ImOpenResponse;
+import com.hubspot.slack.client.models.response.users.UsersInfoResponse;
+import com.hubspot.slack.client.models.users.SlackUser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SlackUserErrorReporter implements ErrorReporter {
+ private static final Logger LOG = LoggerFactory.getLogger(SlackUserErrorReporter.class);
+
+ private final SlackClient slackClient;
+
+ private final String user;
+
+ public SlackUserErrorReporter(SlackClient slackClient, String user) {
+ this.slackClient = slackClient;
+ this.user = user;
+ }
+
+ @Override
+ public void reportProblem(String problem) {
+ LOG.debug("Sending message to user {}: {}", user, problem);
+ UsersInfoResponse usersInfoResponse = slackClient
+ .lookupUserByEmail(UserEmailParams.builder()
+ .setEmail(user)
+ .build()
+ ).join().unwrapOrElseThrow();
+
+ ImOpenResponse imOpenResponse = slackClient.openIm(ImOpenParams.builder()
+ .setUserId(usersInfoResponse.getUser().getId())
+ .build()
+ ).join().unwrapOrElseThrow();
+
+ imOpenResponse.getChannel().ifPresent(channel -> {
+ slackClient.postMessage(
+ ChatPostMessageParams.builder()
+ .setText(problem)
+ .setChannelId(channel.getId())
+ .build()
+ ).join().unwrapOrElseThrow();
+ });
+ }
+}
diff --git a/slack/src/main/resources/logback.xml b/slack/src/main/resources/logback.xml
new file mode 100644
index 0000000000..c8c077ba1d
--- /dev/null
+++ b/slack/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-gateway/pom.xml b/spring-cloud/spring-cloud-gateway/pom.xml
index 10cd49cc04..0f62c031cf 100644
--- a/spring-cloud/spring-cloud-gateway/pom.xml
+++ b/spring-cloud/spring-cloud-gateway/pom.xml
@@ -68,6 +68,10 @@
spring-boot-starter-test
test
+