From b19ab4d2bb1aa1c81b50809532707b440054b72b Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Fri, 3 Jan 2020 21:35:30 +0200 Subject: [PATCH 01/30] BAEL-3451: First samples --- .../functions/src/main/bash/functions.sh | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 linux-bash/functions/src/main/bash/functions.sh diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh new file mode 100644 index 0000000000..5c994e88be --- /dev/null +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -0,0 +1,72 @@ +#!/bin/bash + + +# simple input and output +# variable shadowing +# nesting and recursion + + +function simple_inputs() { + echo "This is the first argument [$1]" + echo "This is the second argument [$2]" + echo "Calling function with $# aruments" +} + +global_variable="lorem" +function simple_outputs() { + sum=$(($1+$2)) + echo "Sum is $sum" + global_variable="dolor" + # this is just the status code + # does not work if we want to return + # other than numerical + return $sum +} + +# missing brackets still works +# as long as we have compound commands +function simple_for_loop() + # echo "Looping through numbers" + for ((i=0;i<5;++i)) do + echo -n " "$i; + done + +function simple_comparison() + if [[ "$1" -lt 5 ]]; then + echo "$1 is smaller than 5" + else + echo "$1 is greater than 5" + fi + +# command groups with subshells +# with the limitation of new enviornments +function simple_subshell() + ( + echo "I'm a little tea pot" + simple_comparison 10 + cd .. + global_variable="ipsum" + ) + +function fibonnaci_recursion() { + argument=$1 + if [[ "$argument" -eq 0 ]] || [[ "$argument" -eq 1 ]]; then + echo $argument + else + first=$(fibonnaci_recursion $(($argument-1))) + second=$(fibonnaci_recursion $(($argument-2))) + echo $(( $first + $second )) + fi +} + + + +simple_inputs one two three +simple_outputs 1 2 +simple_for_loop +simple_comparison 6 +simple_comparison 4 +simple_subshell +echo $global_variable + +#echo $(fibonnaci_recursion 7) From 827f0e4a3d2128ac7ad0384cc2e128964f25f488 Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Sun, 5 Jan 2020 00:35:53 +0200 Subject: [PATCH 02/30] BAEL-3451: Some more examples --- .../functions/src/main/bash/functions.sh | 60 ++++++++++++++----- 1 file changed, 45 insertions(+), 15 deletions(-) mode change 100644 => 100755 linux-bash/functions/src/main/bash/functions.sh diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh old mode 100644 new mode 100755 index 5c994e88be..33af9d3fcb --- a/linux-bash/functions/src/main/bash/functions.sh +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -5,6 +5,26 @@ # variable shadowing # nesting and recursion +simple_function() { + echo "First" + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done +} + +function simple_function { + echo "Second" + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done +} + +# missing brackets still works +# as long as we have compound commands +function simple_for_loop() + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done function simple_inputs() { echo "This is the first argument [$1]" @@ -12,15 +32,21 @@ function simple_inputs() { echo "Calling function with $# aruments" } -global_variable="lorem" +# global_variable="lorem" +# sum=0 +# function simple_outputs() { +# sum=$(($1+$2)) +# global_variable="dolor" +# } + function simple_outputs() { sum=$(($1+$2)) - echo "Sum is $sum" - global_variable="dolor" - # this is just the status code - # does not work if we want to return - # other than numerical - return $sum + echo $sum +} + +function ref_outputs() { + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) } # missing brackets still works @@ -60,13 +86,17 @@ function fibonnaci_recursion() { } - -simple_inputs one two three -simple_outputs 1 2 -simple_for_loop -simple_comparison 6 -simple_comparison 4 -simple_subshell -echo $global_variable +#simple_function +# simple_inputs one 'two three' +# sum=$(simple_outputs 1 2) +# echo "Sum is $sum" +# sum=0 +ref_outputs 1 9 sumt +echo "Sum is $sumt" +# simple_for_loop +# simple_comparison 6 +# simple_comparison 4 +# simple_subshell +# echo $global_variable #echo $(fibonnaci_recursion 7) From 5259814b16d4e0fa33069e5a77af34dd6b9ac17f Mon Sep 17 00:00:00 2001 From: Vikas Ramsingh Rajput Date: Tue, 7 Jan 2020 21:08:42 +0300 Subject: [PATCH 03/30] BAEL-3504: Article - what causes invocation-target-exception : done --- .../InvocationTargetDemo.java | 19 +++++++++++++++++++ .../InvocationTargetExample.java | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetDemo.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetDemo.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetDemo.java new file mode 100644 index 0000000000..125a5d649f --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetDemo.java @@ -0,0 +1,19 @@ +package com.baeldung.reflection.exception.invocationtarget; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class InvocationTargetDemo { + public static void main(String[] args) throws Throwable { + + try { + + InvocationTargetExample targetExample = new InvocationTargetExample(); + Method method = InvocationTargetExample.class.getMethod("divideByZeroExample"); + method.invoke(targetExample); + } catch (InvocationTargetException e) { + + throw e.getCause(); + } + } +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java new file mode 100644 index 0000000000..a20ee527f8 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java @@ -0,0 +1,7 @@ +package com.baeldung.reflection.exception.invocationtarget; + +public class InvocationTargetExample { + public int divideByZeroExample() { + return 1 / 0; + } +} \ No newline at end of file From fbf82f63759efa3b13ce62a80c57bd08144947a7 Mon Sep 17 00:00:00 2001 From: Vikas Ramsingh Rajput Date: Thu, 9 Jan 2020 23:22:47 +0300 Subject: [PATCH 04/30] BAEL-3655: Article Find vs Matches in Java Regex API - done --- .../RegexMatcherFindVsMatchesTest.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/RegexMatcherFindVsMatchesTest.java diff --git a/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/RegexMatcherFindVsMatchesTest.java b/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/RegexMatcherFindVsMatchesTest.java new file mode 100644 index 0000000000..95a2a39209 --- /dev/null +++ b/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/RegexMatcherFindVsMatchesTest.java @@ -0,0 +1,63 @@ +package com.baeldung.regex.matcher; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.jupiter.api.Test; + +public class RegexMatcherFindVsMatchesTest { + + @Test + public void whenFindFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + + assertTrue(m.find()); + assertEquals(8, m.start()); + assertEquals("2019", m.group()); + assertEquals(12, m.end()); + + assertTrue(m.find()); + assertEquals(25, m.start()); + assertEquals("2020", m.group()); + assertEquals(29, m.end()); + + assertFalse(m.find()); + } + + @Test + public void givenStartIndex_whenFindFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + + assertTrue(m.find(20)); + assertEquals(25, m.start()); + assertEquals("2020", m.group()); + assertEquals(29, m.end()); + } + + @Test + public void whenMatchFourDigitWorks_thenFail() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + assertFalse(m.matches()); + } + + @Test + public void whenMatchFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("2019"); + + assertTrue(m.matches()); + assertEquals(0, m.start()); + assertEquals("2019", m.group()); + assertEquals(4, m.end()); + + assertTrue(m.matches());// matches will always return the same return + } + +} From 3f61fa10a9166915667129175912f74c8d0ce272 Mon Sep 17 00:00:00 2001 From: sampada Date: Fri, 10 Jan 2020 17:43:48 +0530 Subject: [PATCH 05/30] BAEL-3602 : Java 13 New Features --- .../SwitchExpressionsWithYieldUnitTest.java | 27 +++++++++++++++++++ .../newfeatures/TextBlocksUnitTest.java | 25 +++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java create mode 100644 core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java diff --git a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java new file mode 100644 index 0000000000..33dea53985 --- /dev/null +++ b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.newfeatures; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class SwitchExpressionsWithYieldUnitTest { + + @Test + @SuppressWarnings("preview") + public void whenSwitchingOnOperationSquareMe_thenWillReturnSquare() { + var me = 4; + var operation = "squareMe"; + var result = switch (operation) { + case "doubleMe" -> { + yield me * 2; + } + case "squareMe" -> { + yield me * me; + } + default -> me; + }; + + assertEquals(result, 16); + } + +} diff --git a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java new file mode 100644 index 0000000000..02ae8b7d9c --- /dev/null +++ b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.newfeatures; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class TextBlocksUnitTest { + + @SuppressWarnings("preview") + private static final String TEXT_BLOCK_JSON = """ + { + "name" : "Baeldung", + "website" : "https://www.baeldung.com/" + } + """; + + @Test + public void whenTextBlocks_thenStringOperationsWork() { + + assertThat(TEXT_BLOCK_JSON.contains("Baeldung")).isTrue(); + assertThat(TEXT_BLOCK_JSON.indexOf("www")).isGreaterThan(0); + assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0); + + } +} From 920f83a2a6b6ae05a080315d0a3eab6adba7ae8f Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Sat, 11 Jan 2020 22:51:19 +0200 Subject: [PATCH 06/30] BAEL-3451: More samples --- .../functions/src/main/bash/functions.sh | 75 ++++++++++++++++--- linux-bash/functions/src/main/bash/infile | 3 + 2 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 linux-bash/functions/src/main/bash/infile diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh index 33af9d3fcb..affe168310 100755 --- a/linux-bash/functions/src/main/bash/functions.sh +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -66,14 +66,32 @@ function simple_comparison() # command groups with subshells # with the limitation of new enviornments +sum=0 function simple_subshell() ( - echo "I'm a little tea pot" - simple_comparison 10 - cd .. - global_variable="ipsum" + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) + # sum=$(($1+$2)) ) +# variable shadowing +variable="baeldung" +function variable_scope(){ + local variable="lorem" + echo "Variable inside function variable_scope : [$variable]" + variable_scope2 +} + +function variable_scope2(){ + echo "Variable inside function variable_scope2 : [$variable]" + local variable="ipsum" + variable_scope3 +} + +function variable_scope3(){ + echo "Variable inside function variable_scope3 : [$variable]" +} + function fibonnaci_recursion() { argument=$1 if [[ "$argument" -eq 0 ]] || [[ "$argument" -eq 1 ]]; then @@ -85,18 +103,57 @@ function fibonnaci_recursion() { fi } +function redirection_in() { + # echo "$1" + while read input; + do + echo "$input" + done +} < infile + +function redirection_in_ps() { + while read input; + do + echo "$input" + done +} < <(ls -ll /) + + +function redirection_out_ps(){ + declare -a output=("baeldung" "lorem" "ipsum" "caracg") + for element in "${output[@]}" + do + echo "$element" + done +} > >(grep "g") + +function redirection_out() { + declare -a output=("baeldung" "lorem" "ipsum") + for element in "${output[@]}" + do + echo "$element" + done +} > outfile #simple_function # simple_inputs one 'two three' # sum=$(simple_outputs 1 2) # echo "Sum is $sum" # sum=0 -ref_outputs 1 9 sumt -echo "Sum is $sumt" +# ref_outputs 1 9 sumt +# echo "Sum is $sumt" # simple_for_loop # simple_comparison 6 # simple_comparison 4 -# simple_subshell -# echo $global_variable +simple_subshell 1 2 sum +echo "Sum is $sum" -#echo $(fibonnaci_recursion 7) +#variable_scope +# echo "Variable outside function variable_scope : [$variable]" +# FUNCNEST=5 +# echo $(fibonnaci_recursion 7) +# echo $(fibonnaci_recursion 15) +# redirection_in +# redirection_in_ps +# redirection_out +# redirection_out_ps diff --git a/linux-bash/functions/src/main/bash/infile b/linux-bash/functions/src/main/bash/infile new file mode 100644 index 0000000000..b1fa680af4 --- /dev/null +++ b/linux-bash/functions/src/main/bash/infile @@ -0,0 +1,3 @@ +Honda Insight 2010 +Honda Element 2006 +Chevrolet Avalanche 2002 From e9d867a5e9d89296c21d658344e91743e16abaf0 Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Sun, 12 Jan 2020 11:13:00 +0200 Subject: [PATCH 07/30] BAEL-3451: Organized code snippets --- .../functions/src/main/bash/functions.sh | 132 ++++++++---------- 1 file changed, 59 insertions(+), 73 deletions(-) diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh index affe168310..64007f38d8 100755 --- a/linux-bash/functions/src/main/bash/functions.sh +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -1,10 +1,6 @@ #!/bin/bash - -# simple input and output -# variable shadowing -# nesting and recursion - +# Subsection 2.1 simple_function() { echo "First" for ((i=0;i<5;++i)) do @@ -19,44 +15,11 @@ function simple_function { done } -# missing brackets still works -# as long as we have compound commands function simple_for_loop() for ((i=0;i<5;++i)) do echo -n " "$i" "; done -function simple_inputs() { - echo "This is the first argument [$1]" - echo "This is the second argument [$2]" - echo "Calling function with $# aruments" -} - -# global_variable="lorem" -# sum=0 -# function simple_outputs() { -# sum=$(($1+$2)) -# global_variable="dolor" -# } - -function simple_outputs() { - sum=$(($1+$2)) - echo $sum -} - -function ref_outputs() { - declare -n sum_ref=$3 - sum_ref=$(($1+$2)) -} - -# missing brackets still works -# as long as we have compound commands -function simple_for_loop() - # echo "Looping through numbers" - for ((i=0;i<5;++i)) do - echo -n " "$i; - done - function simple_comparison() if [[ "$1" -lt 5 ]]; then echo "$1 is smaller than 5" @@ -64,47 +27,58 @@ function simple_comparison() echo "$1 is greater than 5" fi -# command groups with subshells -# with the limitation of new enviornments -sum=0 -function simple_subshell() - ( - declare -n sum_ref=$3 - sum_ref=$(($1+$2)) - # sum=$(($1+$2)) - ) +# Subsection 2.2 +function simple_inputs() { + echo "This is the first argument [$1]" + echo "This is the second argument [$2]" + echo "Calling function with $# aruments" +} -# variable shadowing +# Subsection 2.3 +sum=0 +function simple_outputs() { + sum=$(($1+$2)) +} + +function simple_outputs() { + sum=$(($1+$2)) + echo $sum +} + +# Subsection 2.4 +function ref_outputs() { + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) +} + +# Subsection 3.1 variable="baeldung" +function variable_scope2(){ + echo "Variable inside function variable_scope2 : [$variable]" + local variable="ipsum" +} + function variable_scope(){ local variable="lorem" echo "Variable inside function variable_scope : [$variable]" variable_scope2 } -function variable_scope2(){ - echo "Variable inside function variable_scope2 : [$variable]" - local variable="ipsum" - variable_scope3 -} +# Subsection 3.2 +sum=0 +function simple_subshell() + ( + sum=$(($1+$2)) + ) -function variable_scope3(){ - echo "Variable inside function variable_scope3 : [$variable]" -} - -function fibonnaci_recursion() { - argument=$1 - if [[ "$argument" -eq 0 ]] || [[ "$argument" -eq 1 ]]; then - echo $argument - else - first=$(fibonnaci_recursion $(($argument-1))) - second=$(fibonnaci_recursion $(($argument-2))) - echo $(( $first + $second )) - fi -} +function simple_subshell_ref() + ( + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) + ) +# Subsection 3.3 function redirection_in() { - # echo "$1" while read input; do echo "$input" @@ -112,13 +86,13 @@ function redirection_in() { } < infile function redirection_in_ps() { - while read input; + read + while read -a input; do - echo "$input" + echo "${input[2]} ${input[8]}" done } < <(ls -ll /) - function redirection_out_ps(){ declare -a output=("baeldung" "lorem" "ipsum" "caracg") for element in "${output[@]}" @@ -135,6 +109,18 @@ function redirection_out() { done } > outfile +# Subsection 3.4 +function fibonnaci_recursion() { + argument=$1 + if [[ "$argument" -eq 0 ]] || [[ "$argument" -eq 1 ]]; then + echo $argument + else + first=$(fibonnaci_recursion $(($argument-1))) + second=$(fibonnaci_recursion $(($argument-2))) + echo $(( $first + $second )) + fi +} + #simple_function # simple_inputs one 'two three' # sum=$(simple_outputs 1 2) @@ -145,8 +131,8 @@ function redirection_out() { # simple_for_loop # simple_comparison 6 # simple_comparison 4 -simple_subshell 1 2 sum -echo "Sum is $sum" +# simple_subshell 1 2 sum +# echo "Sum is $sum" #variable_scope # echo "Variable outside function variable_scope : [$variable]" From d32956171dec58e9905c761accbeca659ba0bec1 Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Sun, 12 Jan 2020 12:14:36 +0200 Subject: [PATCH 08/30] BAEL-3451: Included menu. Not complete --- .../functions/src/main/bash/functions.sh | 110 +++++++++++++++--- 1 file changed, 95 insertions(+), 15 deletions(-) diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh index 64007f38d8..4446113ab3 100755 --- a/linux-bash/functions/src/main/bash/functions.sh +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -2,14 +2,12 @@ # Subsection 2.1 simple_function() { - echo "First" for ((i=0;i<5;++i)) do echo -n " "$i" "; done } -function simple_function { - echo "Second" +function simple_function_no_parantheses { for ((i=0;i<5;++i)) do echo -n " "$i" "; done @@ -35,18 +33,18 @@ function simple_inputs() { } # Subsection 2.3 -sum=0 -function simple_outputs() { - sum=$(($1+$2)) +global_sum=0 +function global_sum_outputs() { + global_sum=$(($1+$2)) } -function simple_outputs() { - sum=$(($1+$2)) +function cs_sum_outputs() { + sum=$(($1+$2)) echo $sum } # Subsection 2.4 -function ref_outputs() { +function arg_ref_sum_outputs() { declare -n sum_ref=$3 sum_ref=$(($1+$2)) } @@ -54,27 +52,29 @@ function ref_outputs() { # Subsection 3.1 variable="baeldung" function variable_scope2(){ - echo "Variable inside function variable_scope2 : [$variable]" + echo "Variable inside function variable_scope2: [$variable]" local variable="ipsum" } function variable_scope(){ local variable="lorem" - echo "Variable inside function variable_scope : [$variable]" + echo "Variable inside function variable_scope: [$variable]" variable_scope2 } # Subsection 3.2 -sum=0 -function simple_subshell() +subshell_sum=0 +function simple_subshell_sum() ( - sum=$(($1+$2)) + subshell_sum=$(($1+$2)) + echo "Value of sum in function with global variables: [$subshell_sum]" ) -function simple_subshell_ref() +function simple_subshell_ref_sum() ( declare -n sum_ref=$3 sum_ref=$(($1+$2)) + echo "Value of sum in function with ref arguments: [$sum_ref]" ) # Subsection 3.3 @@ -121,6 +121,86 @@ function fibonnaci_recursion() { fi } +# main menu entry point +echo "****Functions samples menu*****" +PS3="Your choice (1,2,3 etc.):" +options=("function_definitions" "function_input_args" "function_outputs" \ + "function_variables" "function_subshells" "function_redirections" \ + "function_recursion" "quit") +select option in "${options[@]}" +do + case $option in + "function_definitions") + echo -e "\n" + echo "**Different ways to define a function**" + echo -e "No function keyword:" + simple_function + echo -e "\nNo function parantheses:" + simple_function_no_parantheses + echo -e "\nOmitting curly braces:" + simple_for_loop + echo -e "\n" + ;; + "function_input_args") + echo -e "\n" + echo "**Passing inputs to a function**" + simple_inputs lorem ipsum + echo -e "\n" + ;; + "function_outputs") + echo -e "\n" + echo "**Getting outputs from a function**" + global_sum_outputs 1 2 + echo -e "1+2 using global variables: [$global_sum]" + cs_sum=$(cs_sum_outputs 1 2) + echo -e "1+2 using command substitution: [$cs_sum]" + arg_ref_sum_outputs 1 2 arg_ref_sum + echo -e "1+2 using argument references: [$arg_ref_sum]" + echo -e "\n" + ;; + "function_variables") + echo -e "\n" + echo "**Overriding variable scopes**" + echo "Global value of variable: [$variable]" + variable_scope + echo -e "\n" + ;; + "function_subshells") + echo -e "\n" + echo "**Running function in subshell**" + echo "Global value of sum: [$subshell_sum]" + simple_subshell_sum 1 2 + echo "Value of sum after subshell function with \ +global variables: [$subshell_sum]" + subshell_sum_arg_ref=0 + simple_subshell_ref_sum 1 2 subshell_sum_arg_ref + echo "Value of sum after subshell function with \ +ref arguments: [$subshell_sum_arg_ref]" + echo -e "\n" + ;; + "function_redirections") + echo -e "\n" + echo "**Function redirections**" + echo -e "File input redirection:" + redirection_in + echo -e "Command input redirection:" + redirection_in_ps + ;; + # "timeout_input_read") + # echo "Enter something in 5 seconds or less" + # timeout_input_read + # ;; + # "exactly_n_read") + # echo "Enter at least 11 characters or wait 5 seconds" + # exactly_n_read + # ;; + "quit") + break + ;; + *) echo "Invalid option";; + esac +done + #simple_function # simple_inputs one 'two three' # sum=$(simple_outputs 1 2) From 043033ea005c4c82224ce39400f6b37e713c9ed2 Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Sun, 12 Jan 2020 15:08:54 +0200 Subject: [PATCH 09/30] BAEL-3451: Working version --- .../functions/src/main/bash/functions.sh | 61 +++++++------------ 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh index 4446113ab3..4b90de0959 100755 --- a/linux-bash/functions/src/main/bash/functions.sh +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -89,7 +89,7 @@ function redirection_in_ps() { read while read -a input; do - echo "${input[2]} ${input[8]}" + echo "User[${input[2]}]->File[${input[8]}]" done } < <(ls -ll /) @@ -151,11 +151,11 @@ do echo -e "\n" echo "**Getting outputs from a function**" global_sum_outputs 1 2 - echo -e "1+2 using global variables: [$global_sum]" + echo -e ">1+2 using global variables: [$global_sum]" cs_sum=$(cs_sum_outputs 1 2) - echo -e "1+2 using command substitution: [$cs_sum]" + echo -e ">1+2 using command substitution: [$cs_sum]" arg_ref_sum_outputs 1 2 arg_ref_sum - echo -e "1+2 using argument references: [$arg_ref_sum]" + echo -e ">1+2 using argument references: [$arg_ref_sum]" echo -e "\n" ;; "function_variables") @@ -181,45 +181,30 @@ ref arguments: [$subshell_sum_arg_ref]" "function_redirections") echo -e "\n" echo "**Function redirections**" - echo -e "File input redirection:" + echo -e ">Function input redirection from file:" redirection_in - echo -e "Command input redirection:" + echo -e ">Function input redirection from command:" redirection_in_ps + echo -e ">Function output redirection to file:" + redirection_out + cat outfile + echo -e ">Function output redirection to command:" + red_ps=$(redirection_out_ps) + echo "$red_ps" + echo -e "\n" + ;; + "function_recursion") + echo -e "\n" + echo "**Function recursion**" + fibo_res1=$(fibonnaci_recursion 7) + echo "The 7th Fibonnaci number: [$fibo_res1]" + fibo_res2=$(fibonnaci_recursion 15) + echo "The 15th Fibonnaci number: [$fibo_res2]" + echo -e "\n" ;; - # "timeout_input_read") - # echo "Enter something in 5 seconds or less" - # timeout_input_read - # ;; - # "exactly_n_read") - # echo "Enter at least 11 characters or wait 5 seconds" - # exactly_n_read - # ;; "quit") break ;; *) echo "Invalid option";; esac -done - -#simple_function -# simple_inputs one 'two three' -# sum=$(simple_outputs 1 2) -# echo "Sum is $sum" -# sum=0 -# ref_outputs 1 9 sumt -# echo "Sum is $sumt" -# simple_for_loop -# simple_comparison 6 -# simple_comparison 4 -# simple_subshell 1 2 sum -# echo "Sum is $sum" - -#variable_scope -# echo "Variable outside function variable_scope : [$variable]" -# FUNCNEST=5 -# echo $(fibonnaci_recursion 7) -# echo $(fibonnaci_recursion 15) -# redirection_in -# redirection_in_ps -# redirection_out -# redirection_out_ps +done \ No newline at end of file From 23874fb31e5207f4a23f7a7a8381a1e790c06e91 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Mon, 13 Jan 2020 06:24:24 +0100 Subject: [PATCH 10/30] BAEL-3729: Use entityManagerFactory method name to match the code in the article (#8519) --- .../main/java/com/baeldung/config/PersistenceJPAConfig.java | 5 +++-- .../transactional/PersistenceTransactionalTestConfig.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java index e202e45b32..7d3a881827 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java @@ -15,6 +15,7 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; @@ -39,12 +40,12 @@ public class PersistenceJPAConfig { // beans @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java index fde1857ca2..72031a2232 100644 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java +++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java @@ -14,6 +14,7 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; @@ -91,12 +92,12 @@ public class PersistenceTransactionalTestConfig { // beans @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); From d1db78f5c1b1ad18c880b533c7c55ff74e8ebf28 Mon Sep 17 00:00:00 2001 From: sampada Date: Mon, 13 Jan 2020 12:04:35 +0530 Subject: [PATCH 11/30] BAEL-3602 : Added test for formatted() --- .../baeldung/newfeatures/TextBlocksUnitTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java index 02ae8b7d9c..1f8ddcbfb4 100644 --- a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java +++ b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java @@ -6,11 +6,13 @@ import org.junit.Test; public class TextBlocksUnitTest { + private static final String JSON_STRING = "{\r\n" + "\"name\" : \"Baeldung\",\r\n" + "\"website\" : \"https://www.%s.com/\"\r\n" + "}"; + @SuppressWarnings("preview") private static final String TEXT_BLOCK_JSON = """ { "name" : "Baeldung", - "website" : "https://www.baeldung.com/" + "website" : "https://www.%s.com/" } """; @@ -22,4 +24,16 @@ public class TextBlocksUnitTest { assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0); } + + @SuppressWarnings("removal") + @Test + public void whenTextBlocks_thenFormattedWorksAsFormat() { + assertThat(TEXT_BLOCK_JSON.formatted("baeldung") + .contains("www.baeldung.com")).isTrue(); + + assertThat(String.format(JSON_STRING, "baeldung") + .contains("www.baeldung.com")).isTrue(); + + } + } From 8530388c5cc91cffbbdbfcb4527cced0ebc31d56 Mon Sep 17 00:00:00 2001 From: aitorcuesta <56877414+aitorcuesta@users.noreply.github.com> Date: Mon, 13 Jan 2020 18:26:57 +0100 Subject: [PATCH 12/30] BAEL-3678 - Moving from java-numbers-2 to java-numbers-3 (#8521) --- java-numbers-2/pom.xml | 5 ---- java-numbers-3/pom.xml | 8 +++++++ .../randomnumbers/RandomNumbersGenerator.java | 12 ++++++++++ .../RandomNumbersGeneratorUnitTest.java | 23 ++++++++++++++++--- 4 files changed, 40 insertions(+), 8 deletions(-) rename {java-numbers-2 => java-numbers-3}/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java (83%) rename {java-numbers-2 => java-numbers-3}/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java (84%) diff --git a/java-numbers-2/pom.xml b/java-numbers-2/pom.xml index f5f10d9364..ba40ef0a38 100644 --- a/java-numbers-2/pom.xml +++ b/java-numbers-2/pom.xml @@ -21,11 +21,6 @@ jmh-generator-annprocess ${jmh-generator.version} - - it.unimi.dsi - dsiutils - 2.6.0 - diff --git a/java-numbers-3/pom.xml b/java-numbers-3/pom.xml index 3dd8e16bc7..e3c64064c7 100644 --- a/java-numbers-3/pom.xml +++ b/java-numbers-3/pom.xml @@ -12,6 +12,14 @@ 0.0.1-SNAPSHOT ../parent-java + + + + it.unimi.dsi + dsiutils + 2.6.0 + + java-numbers-3 diff --git a/java-numbers-2/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java b/java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java similarity index 83% rename from java-numbers-2/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java rename to java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java index 84cd3eecb6..50a072371e 100644 --- a/java-numbers-2/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java +++ b/java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java @@ -70,12 +70,24 @@ public class RandomNumbersGenerator { return randomWithSplittableRandom; } + public IntStream generateRandomWithSplittableRandomLimitedIntStreamWithinARange(int min, int max, long streamSize) { + SplittableRandom splittableRandom = new SplittableRandom(); + IntStream limitedIntStreamWithinARangeWithSplittableRandom = splittableRandom.ints(streamSize, min, max); + return limitedIntStreamWithinARangeWithSplittableRandom; + } + public Integer generateRandomWithSecureRandom() { SecureRandom secureRandom = new SecureRandom(); int randomWithSecureRandom = secureRandom.nextInt(); return randomWithSecureRandom; } + public Integer generateRandomWithSecureRandomWithinARange(int min, int max) { + SecureRandom secureRandom = new SecureRandom(); + int randomWithSecureRandomWithinARange = secureRandom.nextInt(max - min) + min; + return randomWithSecureRandomWithinARange; + } + public Integer generateRandomWithRandomDataGenerator(int min, int max) { RandomDataGenerator randomDataGenerator = new RandomDataGenerator(); int randomWithRandomDataGenerator = randomDataGenerator.nextInt(min, max); diff --git a/java-numbers-2/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java b/java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java similarity index 84% rename from java-numbers-2/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java rename to java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java index 31d334f8b8..bdd955a4ee 100644 --- a/java-numbers-2/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java +++ b/java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java @@ -11,6 +11,7 @@ public class RandomNumbersGeneratorUnitTest { private static final int MIN_RANGE = 1; private static final int MAX_RANGE = 10; + private static final int MIN_RANGE_NEGATIVE = -10; private static final int ITERATIONS = 50; private static final long STREAM_SIZE = 50; @@ -19,7 +20,7 @@ public class RandomNumbersGeneratorUnitTest { RandomNumbersGenerator generator = new RandomNumbersGenerator(); for (int i = 0; i < ITERATIONS; i++) { int randomNumer = generator.generateRandomWithMathRandom(MIN_RANGE, MAX_RANGE); - assertTrue(isInRange(randomNumer, Integer.MIN_VALUE, Integer.MAX_VALUE)); + assertTrue(isInRange(randomNumer, MIN_RANGE, MAX_RANGE)); } } @@ -97,10 +98,17 @@ public class RandomNumbersGeneratorUnitTest { public void whenGenerateRandomWithSplittableRandom_returnsSuccessfully() { RandomNumbersGenerator generator = new RandomNumbersGenerator(); for (int i = 0; i < ITERATIONS; i++) { - int randomNumber = generator.generateRandomWithSplittableRandom(MIN_RANGE, MAX_RANGE); - assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + int randomNumber = generator.generateRandomWithSplittableRandom(MIN_RANGE_NEGATIVE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE_NEGATIVE, MAX_RANGE)); } } + + @Test + public void whenGenerateRandomWithSplittableRandomLimitedIntStreamWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + generator.generateRandomWithSplittableRandomLimitedIntStreamWithinARange(MIN_RANGE, MAX_RANGE, STREAM_SIZE) + .forEach(randomNumber -> assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE))); + } @Test public void whenGenerateRandomWithSecureRandom_returnsSuccessfully() { @@ -110,6 +118,15 @@ public class RandomNumbersGeneratorUnitTest { assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); } } + + @Test + public void whenGenerateRandomWithSecureRandomWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithSecureRandomWithinARange(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } @Test public void whenGenerateRandomWithRandomDataGenerator_returnsSuccessfully() { From 969d502c50ccd982c790a459f5914cd2cda2ebec Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Mon, 13 Jan 2020 23:12:31 +0530 Subject: [PATCH 13/30] go through the integration test results and see what NEW failing tests we have - Fixed integration tests --- .../src/test/resources/configprops-test.properties | 2 ++ spring-boot-properties/src/test/resources/foo.properties | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-boot-properties/src/test/resources/configprops-test.properties b/spring-boot-properties/src/test/resources/configprops-test.properties index 5eed93a22b..3fc1195b98 100644 --- a/spring-boot-properties/src/test/resources/configprops-test.properties +++ b/spring-boot-properties/src/test/resources/configprops-test.properties @@ -24,3 +24,5 @@ item.size=21 #Additional properties additional.unit=km additional.max=100 + +key.something=val \ No newline at end of file diff --git a/spring-boot-properties/src/test/resources/foo.properties b/spring-boot-properties/src/test/resources/foo.properties index c9f0304f65..b5ae2aedd4 100644 --- a/spring-boot-properties/src/test/resources/foo.properties +++ b/spring-boot-properties/src/test/resources/foo.properties @@ -1 +1,2 @@ -foo=bar \ No newline at end of file +foo=bar +key.something=val \ No newline at end of file From 210e4b05d07e3fca3782c43d18fca877dbaf763f Mon Sep 17 00:00:00 2001 From: chris9408 <58786016+chris9408@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:17:54 +0200 Subject: [PATCH 14/30] [BAEL-3463] - Big Queue (#8517) --- data-structures/pom.xml | 15 ++++ .../baeldung/bigqueue/BigQueueLiveTest.java | 82 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java diff --git a/data-structures/pom.xml b/data-structures/pom.xml index e8f4628062..f4a8ea3a14 100644 --- a/data-structures/pom.xml +++ b/data-structures/pom.xml @@ -12,6 +12,21 @@ 1.0.0-SNAPSHOT + + + github.release.repo + https://raw.github.com/bulldog2011/bulldog-repo/master/repo/releases/ + + + + + + com.leansoft + bigqueue + 0.7.0 + + + diff --git a/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java b/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java new file mode 100644 index 0000000000..c0305a7ca3 --- /dev/null +++ b/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java @@ -0,0 +1,82 @@ +package com.baeldung.bigqueue; + +import com.leansoft.bigqueue.BigQueueImpl; +import com.leansoft.bigqueue.IBigQueue; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(JUnit4.class) +public class BigQueueLiveTest { + + private IBigQueue bigQueue; + + @Before + public void setup() throws IOException { + String queueDir = System.getProperty("user.home"); + String queueName = "baeldung-queue"; + bigQueue = new BigQueueImpl(queueDir, queueName); + } + + @After + public void emptyQueue() throws IOException { + bigQueue.removeAll(); + bigQueue.gc(); + bigQueue.close(); + } + + @Test + public void whenAddingRecords_ThenTheSizeIsCorrect() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + + assertEquals(100, bigQueue.size()); + } + + @Test + public void whenAddingRecords_ThenTheyCanBeRetrieved() throws IOException { + bigQueue.enqueue(String.valueOf("new_record").getBytes()); + + String record = new String(bigQueue.dequeue()); + assertEquals("new_record", record); + } + + @Test + public void whenDequeueingRecords_ThenTheyAreConsumed() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + bigQueue.dequeue(); + + assertEquals(99, bigQueue.size()); + } + + @Test + public void whenPeekingRecords_ThenSizeDoesntChange() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + String firstRecord = new String(bigQueue.peek()); + + assertEquals("1", firstRecord); + assertEquals(100, bigQueue.size()); + } + + @Test + public void whenEmptyingTheQueue_ThenItSizeIs0() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + bigQueue.removeAll(); + + assertEquals(0, bigQueue.size()); + } + +} From f83994f5165ec0b35568ddadc0cb11077a3ab191 Mon Sep 17 00:00:00 2001 From: Paturi Radhe Sravan Date: Tue, 14 Jan 2020 22:34:07 +0530 Subject: [PATCH 15/30] BAEL-3597 Cactoos (#8512) * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3597 Cactoos --- libraries-3/pom.xml | 8 ++- .../cactoos/CactoosCollectionUtils.java | 28 ++++++++++ .../baeldung/cactoos/CactoosStringUtils.java | 37 +++++++++++++ .../CactoosCollectionUtilsUnitTest.java | 35 ++++++++++++ .../cactoos/CactoosStringUtilsUnitTest.java | 54 +++++++++++++++++++ 5 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java create mode 100644 libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java create mode 100644 libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java create mode 100644 libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index c8980fd309..6942aa736d 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -23,10 +23,16 @@ lombok ${lombok.version} + + org.cactoos + cactoos + ${cactoos.version} + 1.78 1.18.6 + 0.43 - + \ No newline at end of file diff --git a/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java new file mode 100644 index 0000000000..717c63ae63 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java @@ -0,0 +1,28 @@ +package com.baeldung.cactoos; + +import java.util.Collection; +import java.util.List; + +import org.cactoos.collection.Filtered; +import org.cactoos.iterable.IterableOf; +import org.cactoos.list.ListOf; +import org.cactoos.scalar.And; +import org.cactoos.text.FormattedText; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CactoosCollectionUtils { + + final Logger LOGGER = LoggerFactory.getLogger(CactoosCollectionUtils.class); + + public void iterateCollection(List strings) throws Exception { + new And((String input) -> LOGGER.info(new FormattedText("%s\n", input).asString()), strings).value(); + } + + public Collection getFilteredList(List strings) { + Collection filteredStrings = new ListOf<>( + new Filtered<>(string -> string.length() == 5, new IterableOf<>(strings))); + return filteredStrings; + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java new file mode 100644 index 0000000000..3e2903ebf4 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java @@ -0,0 +1,37 @@ +package com.baeldung.cactoos; + +import java.io.IOException; + +import org.cactoos.text.FormattedText; +import org.cactoos.text.IsBlank; +import org.cactoos.text.Lowered; +import org.cactoos.text.TextOf; +import org.cactoos.text.Upper; + +public class CactoosStringUtils { + + public String createString() throws IOException { + String testString = new TextOf("Test String").asString(); + return testString; + } + + public String createdFormattedString(String stringToFormat) throws IOException { + String formattedString = new FormattedText("Hello %s", stringToFormat).asString(); + return formattedString; + } + + public String toLowerCase(String testString) throws IOException { + String lowerCaseString = new Lowered(new TextOf(testString)).asString(); + return lowerCaseString; + } + + public String toUpperCase(String testString) throws Exception { + String upperCaseString = new Upper(new TextOf(testString)).asString(); + return upperCaseString; + } + + public boolean isBlank(String testString) throws Exception { + return new IsBlank(new TextOf(testString)) != null; + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java new file mode 100644 index 0000000000..c6bcbd7df7 --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java @@ -0,0 +1,35 @@ +package com.baeldung.cactoos; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.util.List; +import java.util.ArrayList; + +import org.junit.Test; + +public class CactoosCollectionUtilsUnitTest { + + @Test + public void whenFilteredClassIsCalledWithSpecificArgs_thenCorrespondingFilteredCollectionShouldBeReturned() throws IOException { + + CactoosCollectionUtils obj = new CactoosCollectionUtils(); + + // when + List strings = new ArrayList() { + { + add("Hello"); + add("John"); + add("Smith"); + add("Eric"); + add("Dizzy"); + } + }; + int size = obj.getFilteredList(strings).size(); + + // then + assertEquals(3, size); + + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java new file mode 100644 index 0000000000..67dd6d91e4 --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java @@ -0,0 +1,54 @@ +package com.baeldung.cactoos; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; + +import org.junit.Test; + +public class CactoosStringUtilsUnitTest { + + @Test + public void whenFormattedTextIsPassedWithArgs_thenFormattedStringIsReturned() throws IOException { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + String formattedString = obj.createdFormattedString("John"); + + // then + assertEquals("Hello John", formattedString); + + } + + @Test + public void whenStringIsPassesdToLoweredOrUpperClass_thenCorrespondingStringIsReturned() throws Exception { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + String lowerCaseString = obj.toLowerCase("TeSt StrIng"); + String upperCaseString = obj.toUpperCase("TeSt StrIng"); + + // then + assertEquals("test string", lowerCaseString); + assertEquals("TEST STRING", upperCaseString); + + } + + @Test + public void whenEmptyStringIsPassesd_thenIsBlankReturnsTrue() throws Exception { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + boolean isBlankEmptyString = obj.isBlank(""); + boolean isBlankNull = obj.isBlank(null); + + // then + assertEquals(true, isBlankEmptyString); + assertEquals(true, isBlankNull); + + } + +} From 55dc396ec5f3e5108f555baeb706d1d1801da646 Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Tue, 14 Jan 2020 22:27:23 +0200 Subject: [PATCH 16/30] BAEL-3451: Fixed formatting --- .../functions/src/main/bash/functions.sh | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh index 4b90de0959..41ff0ca434 100755 --- a/linux-bash/functions/src/main/bash/functions.sh +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -51,12 +51,12 @@ function arg_ref_sum_outputs() { # Subsection 3.1 variable="baeldung" -function variable_scope2(){ +function variable_scope2() { echo "Variable inside function variable_scope2: [$variable]" local variable="ipsum" } -function variable_scope(){ +function variable_scope() { local variable="lorem" echo "Variable inside function variable_scope: [$variable]" variable_scope2 @@ -64,18 +64,16 @@ function variable_scope(){ # Subsection 3.2 subshell_sum=0 -function simple_subshell_sum() - ( - subshell_sum=$(($1+$2)) - echo "Value of sum in function with global variables: [$subshell_sum]" - ) +function simple_subshell_sum() ( + subshell_sum=$(($1+$2)) + echo "Value of sum in function with global variables: [$subshell_sum]" +) -function simple_subshell_ref_sum() - ( - declare -n sum_ref=$3 - sum_ref=$(($1+$2)) - echo "Value of sum in function with ref arguments: [$sum_ref]" - ) +function simple_subshell_ref_sum() ( + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) + echo "Value of sum in function with ref arguments: [$sum_ref]" +) # Subsection 3.3 function redirection_in() { @@ -93,7 +91,7 @@ function redirection_in_ps() { done } < <(ls -ll /) -function redirection_out_ps(){ +function redirection_out_ps() { declare -a output=("baeldung" "lorem" "ipsum" "caracg") for element in "${output[@]}" do From fde0c09c5703338d4e0c917e4f48c6f20f548ab4 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 15 Jan 2020 06:38:32 +0100 Subject: [PATCH 17/30] BAEL-3778: Add tests to verify if 2 is prime number or not (#8520) --- .../primechecker/BruteForcePrimeChecker.java | 2 +- .../primechecker/OptimisedPrimeChecker.java | 2 +- .../primechecker/PrimeCheckerUnitTest.java | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java index 68382c26ea..7af8c5d58d 100644 --- a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java +++ b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java @@ -7,7 +7,7 @@ public class BruteForcePrimeChecker implements PrimeChecker { @Override public boolean isPrime(Integer number) { - return number > 2 ? IntStream.range(2, number) + return number > 1 ? IntStream.range(2, number) .noneMatch(n -> (number % n == 0)) : false; } diff --git a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java index 3dc372ad22..3019c76eb4 100644 --- a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java +++ b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java @@ -6,7 +6,7 @@ public class OptimisedPrimeChecker implements PrimeChecker { @Override public boolean isPrime(Integer number) { - return number > 2 ? IntStream.rangeClosed(2, (int) Math.sqrt(number)) + return number > 1 ? IntStream.rangeClosed(2, (int) Math.sqrt(number)) .noneMatch(n -> (number % n == 0)) : false; } diff --git a/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java b/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java index 9f8ba8defd..6e425b3051 100644 --- a/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java +++ b/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java @@ -11,22 +11,24 @@ public class PrimeCheckerUnitTest { @Test public void whenCheckIsPrime_thenTrue() { - assertTrue(primeChecker.isPrime(13l)); + assertTrue(primeChecker.isPrime(2L)); + assertTrue(primeChecker.isPrime(13L)); assertTrue(primeChecker.isPrime(1009L)); assertTrue(primeChecker.isPrime(74207281L)); } @Test public void whenCheckIsPrime_thenFalse() { - assertTrue(!primeChecker.isPrime(50L)); - assertTrue(!primeChecker.isPrime(1001L)); - assertTrue(!primeChecker.isPrime(74207282L)); + assertFalse(primeChecker.isPrime(50L)); + assertFalse(primeChecker.isPrime(1001L)); + assertFalse(primeChecker.isPrime(74207282L)); } private final BruteForcePrimeChecker bfPrimeChecker = new BruteForcePrimeChecker(); @Test public void whenBFCheckIsPrime_thenTrue() { + assertTrue(bfPrimeChecker.isPrime(2)); assertTrue(bfPrimeChecker.isPrime(13)); assertTrue(bfPrimeChecker.isPrime(1009)); } @@ -41,6 +43,7 @@ public class PrimeCheckerUnitTest { @Test public void whenOptCheckIsPrime_thenTrue() { + assertTrue(optimisedPrimeChecker.isPrime(2)); assertTrue(optimisedPrimeChecker.isPrime(13)); assertTrue(optimisedPrimeChecker.isPrime(1009)); } @@ -55,6 +58,7 @@ public class PrimeCheckerUnitTest { @Test public void whenPrimesCheckIsPrime_thenTrue() { + assertTrue(primesPrimeChecker.isPrime(2)); assertTrue(primesPrimeChecker.isPrime(13)); assertTrue(primesPrimeChecker.isPrime(1009)); } From f004b3f4bc608aede73985edd0d0f8c33003a65e Mon Sep 17 00:00:00 2001 From: Priyesh Mashelkar Date: Wed, 15 Jan 2020 05:39:43 +0000 Subject: [PATCH 18/30] BAEL-3387 Moved test class to the correct package (#8533) --- .../logging}/HibernateLoggingIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename persistence-modules/hibernate5-2/src/test/java/com/baeldung/{hibernatelogging => hibernate/logging}/HibernateLoggingIntegrationTest.java (97%) diff --git a/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java b/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java similarity index 97% rename from persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java rename to persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java index 8ec722671d..f609c75834 100644 --- a/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java +++ b/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.hibernatelogging; +package com.baeldung.hibernate.logging; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; From b315bf35c68cfc9b37b5c496ca8337a83e8ff6a3 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Thu, 16 Jan 2020 01:53:26 +0530 Subject: [PATCH 19/30] move versions in properties --- algorithms-miscellaneous-1/pom.xml | 3 ++- algorithms-miscellaneous-3/pom.xml | 6 +++-- algorithms-miscellaneous-5/pom.xml | 3 ++- apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml | 9 ++++--- apache-rocketmq/pom.xml | 3 ++- apache-tapestry/pom.xml | 15 +++++++---- aws-reactive/pom.xml | 6 +++-- blade/pom.xml | 3 ++- core-groovy-2/pom.xml | 12 ++++++--- core-groovy-collections/pom.xml | 3 ++- core-java-modules/core-java-11/pom.xml | 5 ++-- core-java-modules/core-java-13/pom.xml | 3 ++- core-java-modules/core-java-14/pom.xml | 3 ++- core-java-modules/core-java-arrays-2/pom.xml | 3 ++- core-java-modules/core-java-arrays/pom.xml | 6 +++-- core-java-modules/core-java-jar/pom.xml | 6 +++-- core-java-modules/core-java-jndi/pom.xml | 24 +++++++++++------ .../consumermodule/pom.xml | 6 ++++- .../decoupling-pattern1/pom.xml | 9 ++++--- .../consumermodule/pom.xml | 9 +++++-- .../decoupling-pattern2/pom.xml | 12 ++++++--- .../providermodule/pom.xml | 7 ++++- core-java-modules/core-java-lang-2/pom.xml | 3 ++- .../core-java-reflection/pom.xml | 6 +++-- .../core-java-string-algorithms-3/pom.xml | 4 +-- core-java-modules/core-java/pom.xml | 6 +++-- .../mainappmodule/pom.xml | 9 ++++--- .../multimodulemavenproject/pom.xml | 9 ++++--- .../userdaomodule/pom.xml | 6 +++-- core-java-modules/pre-jpms/pom.xml | 15 ++++++++--- core-scala/pom.xml | 3 ++- deeplearning4j/pom.xml | 3 ++- ethereum/pom.xml | 9 ++++--- google-web-toolkit/pom.xml | 8 +++--- guest/core-kotlin/pom.xml | 9 ++++--- intelliJ/remote-debugging/pom.xml | 3 ++- .../app-auth-form-store-ldap/pom.xml | 6 ++++- java-numbers-2/pom.xml | 6 ++++- jee-7/pom.xml | 6 +++-- jee-kotlin/pom.xml | 3 ++- .../jhipster-microservice/car-app/pom.xml | 3 ++- .../jhipster-microservice/dealer-app/pom.xml | 3 ++- .../jhipster-microservice/gateway-app/pom.xml | 3 ++- jhipster/jhipster-monolithic/pom.xml | 9 ++++--- jhipster/jhipster-uaa/gateway/pom.xml | 6 +++-- jhipster/jhipster-uaa/uaa/pom.xml | 6 +++-- kotlin-libraries/pom.xml | 7 ++--- kotlin-quasar/pom.xml | 9 ++++--- libraries-data-db/pom.xml | 3 ++- libraries-data/pom.xml | 12 ++++++--- libraries-http/pom.xml | 3 ++- libraries-testing/pom.xml | 5 ++-- libraries/pom.xml | 3 ++- logging-modules/flogger/pom.xml | 17 +++++++----- machine-learning/pom.xml | 27 ++++++++++++------- maven-all/compiler-plugin-java-9/pom.xml | 12 ++++++--- .../maven-custom-plugin/usage-example/pom.xml | 9 +++++-- maven-all/maven-war-plugin/pom.xml | 3 ++- maven-all/versions-maven-plugin/pom.xml | 15 +++++++---- .../resources/archetype-resources/pom.xml | 6 +++-- .../mainppmodule/pom.xml | 9 ++++--- .../multimodule-maven-project/pom.xml | 15 +++++++---- .../userdaomodule/pom.xml | 9 +++++-- .../maven-polyglot-json-extension/pom.xml | 3 ++- micronaut/pom.xml | 21 ++++++++++----- ninja/pom.xml | 9 ++++--- 66 files changed, 339 insertions(+), 158 deletions(-) diff --git a/algorithms-miscellaneous-1/pom.xml b/algorithms-miscellaneous-1/pom.xml index a2183f7474..b7c32bda43 100644 --- a/algorithms-miscellaneous-1/pom.xml +++ b/algorithms-miscellaneous-1/pom.xml @@ -64,7 +64,7 @@ org.codehaus.mojo cobertura-maven-plugin - 2.7 + ${cobertura.plugin.version} @@ -85,6 +85,7 @@ 1.11 27.0.1-jre 3.3.0 + 2.7 \ No newline at end of file diff --git a/algorithms-miscellaneous-3/pom.xml b/algorithms-miscellaneous-3/pom.xml index a893f0a045..673ac0121d 100644 --- a/algorithms-miscellaneous-3/pom.xml +++ b/algorithms-miscellaneous-3/pom.xml @@ -46,13 +46,13 @@ org.apache.commons commons-lang3 - 3.8.1 + ${commons.lang3.version} pl.pragmatists JUnitParams - 1.1.0 + ${JUnitParams.version} test @@ -91,6 +91,8 @@ 2.6.0 1.19 1.19 + 3.8.1 + 1.1.0 \ No newline at end of file diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 95036da775..4f9cc8b711 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -37,7 +37,7 @@ com.google.guava guava - 28.1-jre + ${guava.version} @@ -65,6 +65,7 @@ 3.9.0 1.11 3.6.1 + 28.1-jre \ No newline at end of file diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml index 43bbcf1ef4..1d7ecdb58f 100644 --- a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml +++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml @@ -18,19 +18,19 @@ javax.ws.rs javax.ws.rs-api - 2.1 + ${rs-api.version} provided javax.enterprise cdi-api - 2.0 + ${cdi-api.version} provided javax.json.bind javax.json.bind-api - 1.0 + ${bind-api.version} provided @@ -80,6 +80,9 @@ 2.4.2 false 18.0.0.2 + 2.1 + 2.0 + 1.0 diff --git a/apache-rocketmq/pom.xml b/apache-rocketmq/pom.xml index 59c204dddf..f15dd0e61c 100644 --- a/apache-rocketmq/pom.xml +++ b/apache-rocketmq/pom.xml @@ -17,11 +17,12 @@ org.apache.rocketmq rocketmq-spring-boot-starter - 2.0.4 + ${rocketmq.version} 1.6.0 + 2.0.4 diff --git a/apache-tapestry/pom.xml b/apache-tapestry/pom.xml index e306b56b4a..a4124b07df 100644 --- a/apache-tapestry/pom.xml +++ b/apache-tapestry/pom.xml @@ -81,10 +81,10 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + ${compiler.plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} true @@ -92,7 +92,7 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.apache.maven.plugins maven-surefire-plugin - 2.7.2 + ${compiler.surefire.version} Qa @@ -104,7 +104,7 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.mortbay.jetty maven-jetty-plugin - 6.1.16 + ${compiler.jetty.version} @@ -140,6 +140,11 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's + 6.1.16 + 2.7.2 + 2.3.2 + 1.8 + 1.8 5.4.5 2.5 6.8.21 diff --git a/aws-reactive/pom.xml b/aws-reactive/pom.xml index b3fcb24902..046825130a 100644 --- a/aws-reactive/pom.xml +++ b/aws-reactive/pom.xml @@ -17,6 +17,8 @@ 1.8 + 2.2.1.RELEASE + 2.10.27 @@ -26,7 +28,7 @@ org.springframework.boot spring-boot-dependencies - 2.2.1.RELEASE + ${spring.version} pom import @@ -34,7 +36,7 @@ software.amazon.awssdk bom - 2.10.27 + ${awssdk.version} pom import diff --git a/blade/pom.xml b/blade/pom.xml index e302f33c51..6d73913e25 100644 --- a/blade/pom.xml +++ b/blade/pom.xml @@ -124,7 +124,7 @@ maven-assembly-plugin - 3.1.0 + ${assembly.plugin.version} ${project.build.finalName} false @@ -161,6 +161,7 @@ 3.11.1 3.0.0-M3 0.7 + 3.1.0 diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index e0987de4b3..752b6945b3 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -62,12 +62,12 @@ org.codehaus.groovy groovy-eclipse-compiler - 3.3.0-01 + ${groovy.compiler.version} true maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} groovy-eclipse-compiler ${java.version} @@ -113,7 +113,7 @@ maven-surefire-plugin - 2.20.1 + ${surefire.plugin.version} false @@ -126,7 +126,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.1.0 + ${assembly.plugin.version} @@ -183,6 +183,10 @@ 1.1.3 1.2.3 2.5.7 + 3.1.0 + 2.20.1 + 3.8.0 + 3.3.0-01 diff --git a/core-groovy-collections/pom.xml b/core-groovy-collections/pom.xml index 423be5e977..4e591970b0 100644 --- a/core-groovy-collections/pom.xml +++ b/core-groovy-collections/pom.xml @@ -99,7 +99,7 @@ maven-surefire-plugin - 2.20.1 + ${surefire.plugin.version} false @@ -126,6 +126,7 @@ 2.4.0 1.1-groovy-2.4 1.6 + 2.20.1 diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index 5bebaae00d..32bc68fa66 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -42,12 +42,12 @@ org.eclipse.collections eclipse-collections - 10.0.0 + ${eclipse.collections.version} org.eclipse.collections eclipse-collections-api - 10.0.0 + ${eclipse.collections.version} @@ -108,6 +108,7 @@ 3.11.1 benchmarks 1.22 + 10.0.0 diff --git a/core-java-modules/core-java-13/pom.xml b/core-java-modules/core-java-13/pom.xml index 1f215ae6b0..9469f49411 100644 --- a/core-java-modules/core-java-13/pom.xml +++ b/core-java-modules/core-java-13/pom.xml @@ -41,7 +41,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M3 + ${surefire.plugin.version} --enable-preview @@ -53,6 +53,7 @@ 13 13 3.6.1 + 3.0.0-M3 \ No newline at end of file diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index 48ec627416..b985ada5e6 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -36,7 +36,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M3 + ${surefire.plugin.version} --enable-preview @@ -47,6 +47,7 @@ 14 14 + 3.0.0-M3 \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-2/pom.xml b/core-java-modules/core-java-arrays-2/pom.xml index 532f0a6144..b300de511a 100644 --- a/core-java-modules/core-java-arrays-2/pom.xml +++ b/core-java-modules/core-java-arrays-2/pom.xml @@ -51,7 +51,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.0 + ${shade.plugin.version} package @@ -79,6 +79,7 @@ 3.9 3.10.0 + 3.2.0 diff --git a/core-java-modules/core-java-arrays/pom.xml b/core-java-modules/core-java-arrays/pom.xml index 20a835594f..02d82e4af6 100644 --- a/core-java-modules/core-java-arrays/pom.xml +++ b/core-java-modules/core-java-arrays/pom.xml @@ -183,8 +183,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -373,6 +373,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml index a3e8941622..fe94a6d8a8 100644 --- a/core-java-modules/core-java-jar/pom.xml +++ b/core-java-modules/core-java-jar/pom.xml @@ -207,8 +207,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -397,6 +397,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/core-java-jndi/pom.xml b/core-java-modules/core-java-jndi/pom.xml index 13504886d6..5f1d01a9f5 100644 --- a/core-java-modules/core-java-jndi/pom.xml +++ b/core-java-modules/core-java-jndi/pom.xml @@ -19,34 +19,34 @@ org.junit.jupiter junit-jupiter - 5.5.1 + ${jupiter.version} test org.springframework spring-core - 5.0.9.RELEASE + ${spring.version} org.springframework spring-context - 5.0.9.RELEASE + ${spring.version} org.springframework spring-jdbc - 5.0.9.RELEASE + ${spring.version} org.springframework spring-test - 5.0.9.RELEASE + ${spring.version} test com.h2database h2 - 1.4.199 + ${h2.version} @@ -56,11 +56,19 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${source.version} + ${target.version} + + + 5.0.9.RELEASE + 1.4.199 + 5.5.1 + 1.8 + 1.8 + diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml index ddf52d8fef..e708502dee 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml @@ -16,7 +16,7 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} @@ -29,4 +29,8 @@ + + 1.0 + + diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml index 78a9d1eaad..3c03643a2c 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml @@ -19,10 +19,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} @@ -31,6 +31,9 @@ UTF-8 + 3.8.0 + 11 + 11 \ No newline at end of file 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 734774af0e..6f1038767d 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 @@ -17,12 +17,12 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} com.baeldung.providermodule providermodule - 1.0 + ${providermodule.version} @@ -34,5 +34,10 @@ + + + 1.0 + 1.0 + \ No newline at end of file diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml index 2f84c69fd6..f6b4e5b0df 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml @@ -20,14 +20,20 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} + + + 3.8.0 + 11 + 11 + \ No newline at end of file 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 5ec36c581e..64766b9aff 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 @@ -17,7 +17,7 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} @@ -30,4 +30,9 @@ + + 1.0 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-2/pom.xml b/core-java-modules/core-java-lang-2/pom.xml index 5657e64b17..4702b7350b 100644 --- a/core-java-modules/core-java-lang-2/pom.xml +++ b/core-java-modules/core-java-lang-2/pom.xml @@ -18,7 +18,7 @@ commons-beanutils commons-beanutils - 1.9.4 + ${commons.beanutils.version} org.openjdk.jmh @@ -57,6 +57,7 @@ 1.19 1.19 3.12.2 + 1.9.4 diff --git a/core-java-modules/core-java-reflection/pom.xml b/core-java-modules/core-java-reflection/pom.xml index b3c3390df8..64086ef5b8 100644 --- a/core-java-modules/core-java-reflection/pom.xml +++ b/core-java-modules/core-java-reflection/pom.xml @@ -37,8 +37,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} -parameters @@ -48,5 +48,7 @@ 3.8.0 3.10.0 + 1.8 + 1.8 \ No newline at end of file diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index a5dd31c762..43dc040591 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -25,7 +25,7 @@ com.google.guava guava - 28.1-jre + ${guava.version} @@ -62,7 +62,7 @@ 3.8.1 3.6.1 - 27.0.1-jre + 28.1-jre 5.3.1 diff --git a/core-java-modules/core-java/pom.xml b/core-java-modules/core-java/pom.xml index 341363f8ed..2442d81559 100644 --- a/core-java-modules/core-java/pom.xml +++ b/core-java-modules/core-java/pom.xml @@ -207,8 +207,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -397,6 +397,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml index fa2d92d67f..e8a8203f33 100644 --- a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml @@ -17,17 +17,17 @@ com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} com.baeldung.userdaomodule userdaomodule - 1.0 + ${userdaomodule.version} @@ -43,6 +43,9 @@ 9 9 + 1.0 + 1.0 + 1.0 \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/pom.xml b/core-java-modules/multimodulemavenproject/pom.xml index 1d4aebf32e..dcf9f7311e 100644 --- a/core-java-modules/multimodulemavenproject/pom.xml +++ b/core-java-modules/multimodulemavenproject/pom.xml @@ -45,10 +45,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 1.9 - 1.9 + ${source.version} + ${target.version} @@ -56,6 +56,9 @@ + 3.8.0 + 1.9 + 1.9 UTF-8 3.12.2 diff --git a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml index 19012708cf..8f4cc3d945 100644 --- a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml @@ -17,12 +17,12 @@ com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} @@ -38,6 +38,8 @@ 9 9 + 1.0 + 1.0 \ No newline at end of file diff --git a/core-java-modules/pre-jpms/pom.xml b/core-java-modules/pre-jpms/pom.xml index cb23427138..9833dc2ff7 100644 --- a/core-java-modules/pre-jpms/pom.xml +++ b/core-java-modules/pre-jpms/pom.xml @@ -29,16 +29,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} org.apache.maven.plugins maven-dependency-plugin - 3.1.1 + ${dependency.plugin.version} copy-dependencies @@ -69,5 +69,12 @@ + + + 3.1.1 + 3.8.0 + 1.8 + 1.8 + diff --git a/core-scala/pom.xml b/core-scala/pom.xml index d6793cf4c6..d72727dd39 100644 --- a/core-scala/pom.xml +++ b/core-scala/pom.xml @@ -28,7 +28,7 @@ net.alchim31.maven scala-maven-plugin - 3.3.2 + ${scala.plugin.version} @@ -49,6 +49,7 @@ 2.12.7 + 3.3.2 diff --git a/deeplearning4j/pom.xml b/deeplearning4j/pom.xml index 0e84fa1516..c143b86ff8 100644 --- a/deeplearning4j/pom.xml +++ b/deeplearning4j/pom.xml @@ -44,12 +44,13 @@ org.apache.httpcomponents httpclient - 4.3.5 + ${httpclient.version} 0.9.1 + 4.3.5 diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 6fc31208d2..da0a7ebda8 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -175,10 +175,10 @@ maven-compiler-plugin - 3.1 + ${compiler.plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -215,5 +215,8 @@ 1.2.3 1.7.25 2.0.4.RELEASE + 3.1 + 1.8 + 1.8 diff --git a/google-web-toolkit/pom.xml b/google-web-toolkit/pom.xml index e79b43c5e5..37e423b3af 100644 --- a/google-web-toolkit/pom.xml +++ b/google-web-toolkit/pom.xml @@ -63,7 +63,7 @@ net.ltgt.gwt.maven gwt-maven-plugin - 1.0-rc-8 + ${gwt.plugin.version} @@ -78,7 +78,7 @@ true - 1.8 + ${maven.compiler.source} @@ -98,7 +98,7 @@ maven-surefire-plugin - 2.17 + ${surefire.plugin.version} true @@ -119,6 +119,8 @@ UTF-8 UTF-8 2.8.2 + 1.0-rc-8 + 2.17 diff --git a/guest/core-kotlin/pom.xml b/guest/core-kotlin/pom.xml index 2d4a0c6144..ad0368c6ab 100644 --- a/guest/core-kotlin/pom.xml +++ b/guest/core-kotlin/pom.xml @@ -46,19 +46,19 @@ org.jetbrains.spek spek-api - 1.1.5 + ${spek.api.version} test org.jetbrains.spek spek-subject-extension - 1.1.5 + ${spek.subject.version} test org.jetbrains.spek spek-junit-platform-engine - 1.1.5 + ${spek.junit.version} test @@ -195,6 +195,9 @@ 5.2.0 3.10.0 3.7.0 + 1.1.5 + 1.1.5 + 1.1.5 diff --git a/intelliJ/remote-debugging/pom.xml b/intelliJ/remote-debugging/pom.xml index d18625e8f6..43b9a44d13 100644 --- a/intelliJ/remote-debugging/pom.xml +++ b/intelliJ/remote-debugging/pom.xml @@ -16,6 +16,7 @@ 1.8 + 3.1.2 @@ -31,7 +32,7 @@ org.awaitility awaitility - 3.1.2 + ${awaitility.version} test diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml b/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml index 912a2cabac..a2d9443d67 100644 --- a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml +++ b/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml @@ -12,12 +12,16 @@ java-ee-8-security-api 1.0-SNAPSHOT + + + 4.0.4 + com.unboundid unboundid-ldapsdk - 4.0.4 + ${unboundid.ldapsdk.version} diff --git a/java-numbers-2/pom.xml b/java-numbers-2/pom.xml index f5f10d9364..5c81b00756 100644 --- a/java-numbers-2/pom.xml +++ b/java-numbers-2/pom.xml @@ -24,7 +24,7 @@ it.unimi.dsi dsiutils - 2.6.0 + ${dsiutils.version} @@ -38,4 +38,8 @@ + + 2.6.0 + + diff --git a/jee-7/pom.xml b/jee-7/pom.xml index 635d820c2b..a2593e46a5 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -118,7 +118,7 @@ javax.mvc javax.mvc-api - 20160715 + ${mvc.api.version} org.glassfish.ozark @@ -215,7 +215,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -506,6 +506,8 @@ + 1.0.0 + 20160715 1.8 3.0.0 7.0 diff --git a/jee-kotlin/pom.xml b/jee-kotlin/pom.xml index 80c5ea4e22..9191885bd4 100644 --- a/jee-kotlin/pom.xml +++ b/jee-kotlin/pom.xml @@ -253,7 +253,7 @@ org.wildfly.arquillian wildfly-arquillian-container-remote - 2.2.0.Final + ${wildfly.arquillian.version} test @@ -261,6 +261,7 @@ + 2.2.0.Final UTF-8 false 8.0 diff --git a/jhipster/jhipster-microservice/car-app/pom.xml b/jhipster/jhipster-microservice/car-app/pom.xml index 86d94d0a44..c53ea8358e 100644 --- a/jhipster/jhipster-microservice/car-app/pom.xml +++ b/jhipster/jhipster-microservice/car-app/pom.xml @@ -17,6 +17,7 @@ + 1.0.0 -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 @@ -433,7 +434,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-microservice/dealer-app/pom.xml b/jhipster/jhipster-microservice/dealer-app/pom.xml index 3051399ae6..a0bcc73e31 100644 --- a/jhipster/jhipster-microservice/dealer-app/pom.xml +++ b/jhipster/jhipster-microservice/dealer-app/pom.xml @@ -92,6 +92,7 @@ 1.4.10.Final 1.1.0.Final v0.21.3 + 1.0.0 @@ -427,7 +428,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-microservice/gateway-app/pom.xml b/jhipster/jhipster-microservice/gateway-app/pom.xml index 4e2c19ed2d..c6dcbb3f3e 100644 --- a/jhipster/jhipster-microservice/gateway-app/pom.xml +++ b/jhipster/jhipster-microservice/gateway-app/pom.xml @@ -96,6 +96,7 @@ 1.4.10.Final 1.1.0.Final v0.21.3 + 1.0.0 @@ -469,7 +470,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-monolithic/pom.xml b/jhipster/jhipster-monolithic/pom.xml index 12dead99df..04f790faf5 100644 --- a/jhipster/jhipster-monolithic/pom.xml +++ b/jhipster/jhipster-monolithic/pom.xml @@ -302,7 +302,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -398,8 +398,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} org.mapstruct @@ -881,6 +881,9 @@ + 1.8 + 1.8 + 1.0.0 -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 diff --git a/jhipster/jhipster-uaa/gateway/pom.xml b/jhipster/jhipster-uaa/gateway/pom.xml index 0f815bedad..1b85877a9b 100644 --- a/jhipster/jhipster-uaa/gateway/pom.xml +++ b/jhipster/jhipster-uaa/gateway/pom.xml @@ -236,7 +236,7 @@ org.zalando problem-spring-web - 0.24.0-RC.0 + ${spring.web.version} org.springframework.security.oauth @@ -559,7 +559,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -1012,6 +1012,8 @@ + 1.0.0 + 0.24.0-RC.0 3.0.0 1.8 diff --git a/jhipster/jhipster-uaa/uaa/pom.xml b/jhipster/jhipster-uaa/uaa/pom.xml index 2c4dd9d0f0..27a056820d 100644 --- a/jhipster/jhipster-uaa/uaa/pom.xml +++ b/jhipster/jhipster-uaa/uaa/pom.xml @@ -232,7 +232,7 @@ org.zalando problem-spring-web - 0.24.0-RC.0 + ${spring.web.version} org.springframework.security.oauth @@ -543,7 +543,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -834,6 +834,8 @@ + 1.0.0 + 0.24.0-RC.0 3.0.0 1.8 diff --git a/kotlin-libraries/pom.xml b/kotlin-libraries/pom.xml index dfd1dc363f..0d6e589377 100644 --- a/kotlin-libraries/pom.xml +++ b/kotlin-libraries/pom.xml @@ -33,19 +33,19 @@ org.jetbrains.spek spek-api - 1.1.5 + ${spek.version} test org.jetbrains.spek spek-subject-extension - 1.1.5 + ${spek.version} test org.jetbrains.spek spek-junit-platform-engine - 1.1.5 + ${spek.version} test @@ -166,6 +166,7 @@ 2.6 2.3.0 0.7.3 + 1.1.5 diff --git a/kotlin-quasar/pom.xml b/kotlin-quasar/pom.xml index a12d27c565..f5fbce6ed7 100644 --- a/kotlin-quasar/pom.xml +++ b/kotlin-quasar/pom.xml @@ -103,7 +103,7 @@ maven-dependency-plugin - 3.1.1 + ${dependency.plugin.version} getClasspathFilenames @@ -116,7 +116,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.1 + ${surefire.plugin.version} -Dco.paralleluniverse.fibers.verifyInstrumentation=true -javaagent:${co.paralleluniverse:quasar-core:jar} @@ -125,7 +125,7 @@ org.codehaus.mojo exec-maven-plugin - 1.3.2 + ${exec.plugin.version} target/classes echo @@ -145,6 +145,9 @@ 1.3.31 1.7.21 1.1.7 + 3.1.1 + 2.22.1 + 1.3.2 diff --git a/libraries-data-db/pom.xml b/libraries-data-db/pom.xml index 682a6ed185..f028ffe8c3 100644 --- a/libraries-data-db/pom.xml +++ b/libraries-data-db/pom.xml @@ -183,7 +183,7 @@ io.ebean ebean-maven-plugin - 11.11.2 + ${ebean.plugin.version} @@ -202,6 +202,7 @@ + 11.11.2 16.5.1 3.0.0 1.8 diff --git a/libraries-data/pom.xml b/libraries-data/pom.xml index 2086ecb614..1267982c49 100644 --- a/libraries-data/pom.xml +++ b/libraries-data/pom.xml @@ -74,19 +74,19 @@ commons-cli commons-cli - 1.2 + ${commons.cli.version} provided commons-io commons-io - 2.1 + ${commons.io.version} provided commons-httpclient commons-httpclient - 3.0.1 + ${httpclient.version} provided @@ -133,7 +133,7 @@ org.apache.maven.plugins maven-assembly-plugin - 2.3 + ${assembly.plugin.version} src/main/resources/assembly/hadoop-job.xml @@ -158,6 +158,10 @@ + 2.3 + 1.2 + 2.1 + 3.0.1 1.2.2 1.0.0 2.4.0 diff --git a/libraries-http/pom.xml b/libraries-http/pom.xml index 6261456486..cbc74ce132 100644 --- a/libraries-http/pom.xml +++ b/libraries-http/pom.xml @@ -71,7 +71,7 @@ com.google.code.gson gson - 2.8.5 + ${gson.version} @@ -116,6 +116,7 @@ + 2.8.5 4.5.3 2.9.8 3.6.2 diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index c84f8dda76..3ffbb291a0 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -127,7 +127,7 @@ org.asciidoctor asciidoctor-maven-plugin - 1.5.7.1 + ${asciidoctor.version} @@ -154,7 +154,8 @@ - 1.9.9 + 1.5.7.1 + 1.9.9 1.9.0 1.9.0 1.9.27 diff --git a/libraries/pom.xml b/libraries/pom.xml index 13f91711fd..b5340d1ebb 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -523,7 +523,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.2 + ${shade.plugin.version} package @@ -556,6 +556,7 @@ + 2.2 0.7.0 3.2.7 1.2 diff --git a/logging-modules/flogger/pom.xml b/logging-modules/flogger/pom.xml index c27e2c8d7a..f553a4a961 100644 --- a/logging-modules/flogger/pom.xml +++ b/logging-modules/flogger/pom.xml @@ -15,26 +15,26 @@ com.google.flogger flogger - 0.4 + ${flogger.version} com.google.flogger flogger-system-backend - 0.4 + ${flogger.version} runtime com.google.flogger flogger-slf4j-backend - 0.4 + ${flogger.version} com.google.flogger flogger-log4j-backend - 0.4 + ${flogger.version} com.sun.jmx @@ -54,13 +54,18 @@ log4j log4j - 1.2.17 + ${log4j.version} log4j apache-log4j-extras - 1.2.17 + ${log4j.version} + + 0.4 + 1.2.17 + + \ No newline at end of file diff --git a/machine-learning/pom.xml b/machine-learning/pom.xml index 7bc0332012..24162b7b9c 100644 --- a/machine-learning/pom.xml +++ b/machine-learning/pom.xml @@ -19,6 +19,15 @@ 1.7 1.3.50 0.9.1 + 3.1.0 + 3.0.2 + 3.0.2 + 3.8.0 + 2.22.1 + 2.5.2 + 2.8.2 + 3.7.1 + 3.0.0 @@ -63,41 +72,41 @@ maven-clean-plugin - 3.1.0 + ${clean.plugin.version} maven-resources-plugin - 3.0.2 + ${resources.plugin.version} maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} maven-surefire-plugin - 2.22.1 + ${surefire.plugin.version} maven-jar-plugin - 3.0.2 + ${jar.plugin.version} maven-install-plugin - 2.5.2 + ${install.plugin.version} maven-deploy-plugin - 2.8.2 + ${deploy.plugin.version} maven-site-plugin - 3.7.1 + ${site.plugin.version} maven-project-info-reports-plugin - 3.0.0 + ${report.plugin.version} diff --git a/maven-all/compiler-plugin-java-9/pom.xml b/maven-all/compiler-plugin-java-9/pom.xml index 1975e1f7cd..6baadb451c 100644 --- a/maven-all/compiler-plugin-java-9/pom.xml +++ b/maven-all/compiler-plugin-java-9/pom.xml @@ -12,13 +12,19 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 9 - 9 + ${source.version} + ${target.version} + + 3.8.0 + 9 + 9 + + \ No newline at end of file diff --git a/maven-all/maven-custom-plugin/usage-example/pom.xml b/maven-all/maven-custom-plugin/usage-example/pom.xml index 542a02b3eb..bd2b16475e 100644 --- a/maven-all/maven-custom-plugin/usage-example/pom.xml +++ b/maven-all/maven-custom-plugin/usage-example/pom.xml @@ -8,16 +8,21 @@ 0.0.1-SNAPSHOT pom + + 3.9 + 4.12 + + org.apache.commons commons-lang3 - 3.9 + ${commons.lang3.version} junit junit - 4.12 + ${junit.version} test diff --git a/maven-all/maven-war-plugin/pom.xml b/maven-all/maven-war-plugin/pom.xml index 233a9f3571..915be306ca 100644 --- a/maven-all/maven-war-plugin/pom.xml +++ b/maven-all/maven-war-plugin/pom.xml @@ -14,7 +14,7 @@ maven-war-plugin - 3.1.0 + ${war.plugin.version} false @@ -26,6 +26,7 @@ false + 3.1.0 \ No newline at end of file diff --git a/maven-all/versions-maven-plugin/pom.xml b/maven-all/versions-maven-plugin/pom.xml index 3ce25d16f9..9793f55b28 100644 --- a/maven-all/versions-maven-plugin/pom.xml +++ b/maven-all/versions-maven-plugin/pom.xml @@ -12,19 +12,19 @@ commons-io commons-io - 2.3 + ${commons.io.version} org.apache.commons commons-collections4 - 4.0 + ${commons.collections4.version} org.apache.commons commons-lang3 - 3.0 + ${commons.lang3.version} @@ -36,7 +36,7 @@ commons-beanutils commons-beanutils - 1.9.1 + ${commons.beanutils.version} @@ -45,7 +45,7 @@ org.codehaus.mojo versions-maven-plugin - 2.7 + ${versions.plugin.version} org.apache.commons:commons-collections4 @@ -71,6 +71,11 @@ 1.15 + 2.3 + 2.7 + 1.9.1 + 3.0 + 4.0 \ No newline at end of file diff --git a/maven-archetype/src/main/resources/archetype-resources/pom.xml b/maven-archetype/src/main/resources/archetype-resources/pom.xml index a5c813652d..2a73687e2c 100644 --- a/maven-archetype/src/main/resources/archetype-resources/pom.xml +++ b/maven-archetype/src/main/resources/archetype-resources/pom.xml @@ -14,6 +14,8 @@ ${liberty-plugin-version} 9080 9443 + 2.0 + 2.1 @@ -65,14 +67,14 @@ javax.enterprise cdi-api - 2.0 + ${cdi.api.version} provided javax.ws.rs javax.ws.rs-api - 2.1 + ${rsapi.api.version} provided diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml b/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml index 42b06bbebd..a4a6575906 100644 --- a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml +++ b/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml @@ -12,23 +12,26 @@ com.baeldung.multimodule-maven-project multimodule-maven-project 1.0 + 1.0 + 1.0 + 1.0 com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} com.baeldung.userdaomodule userdaomodule - 1.0 + ${userdaomodule.version} diff --git a/maven-java-11/multimodule-maven-project/pom.xml b/maven-java-11/multimodule-maven-project/pom.xml index a79dff93d3..65f5b7a814 100644 --- a/maven-java-11/multimodule-maven-project/pom.xml +++ b/maven-java-11/multimodule-maven-project/pom.xml @@ -26,13 +26,13 @@ junit junit - 4.12 + ${junit.version} test org.assertj assertj-core - 3.12.2 + ${assertj.version} test @@ -44,10 +44,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} @@ -56,6 +56,11 @@ UTF-8 + 4.12 + 3.12.2 + 3.8.0 + 11 + 11 diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml b/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml index 3eb5897f8b..cfa59bdc39 100644 --- a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml +++ b/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml @@ -14,16 +14,21 @@ 1.0 + + 1.0 + 1.0 + + com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version}1.0 com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} junit diff --git a/maven-polyglot/maven-polyglot-json-extension/pom.xml b/maven-polyglot/maven-polyglot-json-extension/pom.xml index 0043bae151..15166046c1 100644 --- a/maven-polyglot/maven-polyglot-json-extension/pom.xml +++ b/maven-polyglot/maven-polyglot-json-extension/pom.xml @@ -34,7 +34,7 @@ org.codehaus.plexus plexus-component-metadata - 1.7.1 + ${plexus.component.version} @@ -48,6 +48,7 @@ 3.5.4 + 1.7.1 \ No newline at end of file diff --git a/micronaut/pom.xml b/micronaut/pom.xml index 13639c11ff..2cb05cc1b9 100644 --- a/micronaut/pom.xml +++ b/micronaut/pom.xml @@ -49,7 +49,7 @@ javax.annotation javax.annotation-api - 1.3.2 + ${annotation.api.version} compile @@ -60,19 +60,19 @@ ch.qos.logback logback-classic - 1.2.3 + ${lombok.version} runtime junit junit - 4.12 + ${junit.version} test io.projectreactor reactor-core - 3.1.6.RELEASE + ${reactor.version} @@ -81,7 +81,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + ${shade.plugin.version} package @@ -102,7 +102,7 @@ org.codehaus.mojo exec-maven-plugin - 1.6.0 + ${exec.plugin.version} java @@ -118,7 +118,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + ${compiler.plugin.version} ${jdk.version} ${jdk.version} @@ -142,6 +142,13 @@ com.baeldung.micronaut.helloworld.server.ServerApplication 1.0.0.RC2 1.8 + 1.3.2 + 1.2.3 + 4.12 + 3.1.6.RELEASE + 3.7.0 + 1.6.0 + 3.1.0 diff --git a/ninja/pom.xml b/ninja/pom.xml index 8ec2422d9f..b66225f693 100644 --- a/ninja/pom.xml +++ b/ninja/pom.xml @@ -13,6 +13,9 @@ 6.5.0 9.4.18.v20190429 + 3.3.4 + 2.1.3 + 1.4.186 @@ -156,17 +159,17 @@ org.webjars bootstrap - 3.3.4 + ${bootstrap.version} org.webjars jquery - 2.1.3 + ${jquery.version} com.h2database h2 - 1.4.186 + ${h2.version} org.ninjaframework From d38ab2f4cc82fbf41cd9d4a689e6f3e2d7778387 Mon Sep 17 00:00:00 2001 From: petershatunov Date: Thu, 16 Jan 2020 21:18:01 +0300 Subject: [PATCH 20/30] sequences in kotlin (#8515) * sequences in kotlin * fix readme * fix naming * fix naming --- .../com/baeldung/sequences/SequencesTest.kt | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt new file mode 100644 index 0000000000..a41e213c44 --- /dev/null +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt @@ -0,0 +1,54 @@ +package com.baeldung.sequeces + +import org.junit.Test +import kotlin.test.assertEquals +import java.time.Instant + +class SequencesTest { + + @Test + fun shouldBuildSequenceWhenUsingFromElements() { + val seqOfElements = sequenceOf("first" ,"second", "third") + .toList() + assertEquals(3, seqOfElements.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromFunction() { + val seqFromFunction = generateSequence(Instant.now()) {it.plusSeconds(1)} + .take(3) + .toList() + assertEquals(3, seqFromFunction.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromChunks() { + val seqFromChunks = sequence { + yield(1) + yieldAll((2..5).toList()) + }.toList() + assertEquals(5, seqFromChunks.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromCollection() { + val seqFromIterable = (1..10) + .asSequence() + .toList() + assertEquals(10, seqFromIterable.count()) + } + + @Test + fun shouldShowNoCountDiffWhenUsingWithAndWithoutSequence() { + val withSequence = (1..10).asSequence() + .filter{it % 2 == 1} + .map { it * 2 } + .toList() + val withoutSequence = (1..10) + .filter{it % 2 == 1} + .map { it * 2 } + .toList() + assertEquals(withSequence.count(), withoutSequence.count()) + } + +} \ No newline at end of file From e19c356bf97fefea8be76e414fe01f68b56ea9e0 Mon Sep 17 00:00:00 2001 From: Vikas Ramsingh Rajput Date: Fri, 17 Jan 2020 23:38:53 +0300 Subject: [PATCH 21/30] BAEL-3504: Added Unit test file and removed old class file --- .../InvocationTargetDemo.java | 19 ------------------ .../InvocationTargetUnitTest.java | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) delete mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetDemo.java create mode 100644 core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetDemo.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetDemo.java deleted file mode 100644 index 125a5d649f..0000000000 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetDemo.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.reflection.exception.invocationtarget; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class InvocationTargetDemo { - public static void main(String[] args) throws Throwable { - - try { - - InvocationTargetExample targetExample = new InvocationTargetExample(); - Method method = InvocationTargetExample.class.getMethod("divideByZeroExample"); - method.invoke(targetExample); - } catch (InvocationTargetException e) { - - throw e.getCause(); - } - } -} diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java new file mode 100644 index 0000000000..938dff87d4 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java @@ -0,0 +1,20 @@ +package com.baeldung.reflection.exception.invocationtarget; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.jupiter.api.Test; + +public class InvocationTargetUnitTest { + + @Test + public void whenCallingMethodThrowsException_thenAssertTrue() throws Exception { + InvocationTargetExample targetExample = new InvocationTargetExample(); + Method method = InvocationTargetExample.class.getMethod("divideByZeroExample"); + Exception exception = assertThrows(InvocationTargetException.class, () -> method.invoke(targetExample)); + assertEquals(ArithmeticException.class, exception.getCause().getClass()); + } +} From bcb2ce10da5feb559257748a711f3915b81b9e15 Mon Sep 17 00:00:00 2001 From: Vikas Ramsingh Rajput Date: Fri, 17 Jan 2020 23:54:00 +0300 Subject: [PATCH 22/30] BAEL-3655: Renamed the JUnit test file as the proper naming convention --- ...{RegexMatcherFindVsMatchesTest.java => MatcherUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/{RegexMatcherFindVsMatchesTest.java => MatcherUnitTest.java} (97%) diff --git a/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/RegexMatcherFindVsMatchesTest.java b/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java similarity index 97% rename from core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/RegexMatcherFindVsMatchesTest.java rename to core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java index 95a2a39209..304b9f2f1d 100644 --- a/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/RegexMatcherFindVsMatchesTest.java +++ b/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java @@ -9,7 +9,7 @@ import java.util.regex.Pattern; import org.junit.jupiter.api.Test; -public class RegexMatcherFindVsMatchesTest { +public class MatcherUnitTest { @Test public void whenFindFourDigitWorks_thenCorrect() { From b2cdd4db7ec749ab962d3773869d6e086960dd2f Mon Sep 17 00:00:00 2001 From: sampada Date: Sat, 18 Jan 2020 20:19:34 +0530 Subject: [PATCH 23/30] BAEL-3602 : swapped order of args in assertEquals call --- .../newfeatures/SwitchExpressionsWithYieldUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java index 33dea53985..be1fcfd167 100644 --- a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java +++ b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java @@ -21,7 +21,7 @@ public class SwitchExpressionsWithYieldUnitTest { default -> me; }; - assertEquals(result, 16); + assertEquals(16, result); } } From b7ffef72fb45c11bdad4de5ee6d736602be2740b Mon Sep 17 00:00:00 2001 From: Vikas Rajput Date: Sun, 19 Jan 2020 10:52:37 +0300 Subject: [PATCH 24/30] BAEL-3504: Update core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java Co-Authored-By: KevinGilmore --- .../exception/invocationtarget/InvocationTargetUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java index 938dff87d4..f7297b0f0b 100644 --- a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test; public class InvocationTargetUnitTest { @Test - public void whenCallingMethodThrowsException_thenAssertTrue() throws Exception { + public void whenCallingMethodThrowsException_thenAssertCauseOfInvocationTargetException() throws Exception { InvocationTargetExample targetExample = new InvocationTargetExample(); Method method = InvocationTargetExample.class.getMethod("divideByZeroExample"); Exception exception = assertThrows(InvocationTargetException.class, () -> method.invoke(targetExample)); From ca464ab4433ca06d405c56039eea973d504a502b Mon Sep 17 00:00:00 2001 From: Vikas Ramsingh Rajput Date: Sun, 19 Jan 2020 11:56:33 +0300 Subject: [PATCH 25/30] BAEL-3504: Added blank lines before when and then in unit test --- .../exception/invocationtarget/InvocationTargetUnitTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java index f7297b0f0b..b4cabebcef 100644 --- a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java @@ -12,9 +12,12 @@ public class InvocationTargetUnitTest { @Test public void whenCallingMethodThrowsException_thenAssertCauseOfInvocationTargetException() throws Exception { + InvocationTargetExample targetExample = new InvocationTargetExample(); Method method = InvocationTargetExample.class.getMethod("divideByZeroExample"); + Exception exception = assertThrows(InvocationTargetException.class, () -> method.invoke(targetExample)); + assertEquals(ArithmeticException.class, exception.getCause().getClass()); } } From 9bf8da01439cc99cf3c545049609984e5b51ee3b Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 19 Jan 2020 11:30:01 +0100 Subject: [PATCH 26/30] BAEL-21120: Disable failing spring-roo module --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 71e5d21b02..666ef838dd 100644 --- a/pom.xml +++ b/pom.xml @@ -814,7 +814,7 @@ spring-rest-shell spring-rest-simple spring-resttemplate - spring-roo + spring-scheduling spring-security-modules/spring-security-acl spring-security-modules/spring-security-angular/server @@ -1416,7 +1416,7 @@ spring-rest-shell spring-rest-simple spring-resttemplate - spring-roo + spring-scheduling spring-security-modules/spring-security-acl From 66c23eb2809032bb122b7f1eb106e11894c57c4d Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 20 Jan 2020 07:02:07 +0100 Subject: [PATCH 27/30] BAEL-21120: Enable spring-roo module --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 666ef838dd..71e5d21b02 100644 --- a/pom.xml +++ b/pom.xml @@ -814,7 +814,7 @@ spring-rest-shell spring-rest-simple spring-resttemplate - + spring-roo spring-scheduling spring-security-modules/spring-security-acl spring-security-modules/spring-security-angular/server @@ -1416,7 +1416,7 @@ spring-rest-shell spring-rest-simple spring-resttemplate - + spring-roo spring-scheduling spring-security-modules/spring-security-acl From 6a74022ae02ab0c3469bf089544459b385ba23a9 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 20 Jan 2020 07:09:38 +0100 Subject: [PATCH 28/30] BAEL-21120: Use https for repo.spring.io --- spring-roo/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-roo/pom.xml b/spring-roo/pom.xml index 456642b1f0..448574ed19 100644 --- a/spring-roo/pom.xml +++ b/spring-roo/pom.xml @@ -413,7 +413,7 @@ spring-roo-repository Spring Roo Repository - http://repo.spring.io/spring-roo + https://repo.spring.io/spring-roo From e7ddc7d9e32b55178273b4d919637c516f994870 Mon Sep 17 00:00:00 2001 From: Maiklins Date: Tue, 21 Jan 2020 10:03:23 +0100 Subject: [PATCH 29/30] http://jira.baeldung.com/browse/BAEL-3707 (#8535) Missing Code - Guide To Java 8 Optional --- .../java/com/baeldung/optional/Person.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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()); + } } From dd173ec585cb70f256fdc327970a390750354624 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Tue, 21 Jan 2020 10:28:22 +0100 Subject: [PATCH 30/30] BAEL-3683: Rename ProductMultipleDB entity to Product (#8557) --- .../dao/product/ProductRepository.java | 6 +-- .../{ProductMultipleDB.java => Product.java} | 10 ++--- .../ProductRepositoryIntegrationTest.java | 40 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) rename persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/{ProductMultipleDB.java => Product.java} (80%) 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))); }