Merge branch 'eugenp:master' into master
This commit is contained in:
commit
b2d7045e84
|
@ -8,6 +8,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.spark.sql.Dataset;
|
import org.apache.spark.sql.Dataset;
|
||||||
import org.apache.spark.sql.Row;
|
import org.apache.spark.sql.Row;
|
||||||
|
import org.apache.spark.sql.SparkSession;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class CustomerToDataFrameConverterAppUnitTest {
|
class CustomerToDataFrameConverterAppUnitTest {
|
||||||
|
@ -59,4 +61,9 @@ class CustomerToDataFrameConverterAppUnitTest {
|
||||||
assertEquals( "Male", row2.getAs("gender"));
|
assertEquals( "Male", row2.getAs("gender"));
|
||||||
assertEquals( 1200, (int)row2.getAs("transaction_amount"));
|
assertEquals( 1200, (int)row2.getAs("transaction_amount"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void cleanup() {
|
||||||
|
SparkSession.getActiveSession().get().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
|
@ -21,5 +21,3 @@
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,3 +11,4 @@ This module contains articles about Java 14.
|
||||||
- [Foreign Memory Access API in Java 14](https://www.baeldung.com/java-foreign-memory-access)
|
- [Foreign Memory Access API in Java 14](https://www.baeldung.com/java-foreign-memory-access)
|
||||||
- [Java 14 Record Keyword](https://www.baeldung.com/java-record-keyword)
|
- [Java 14 Record Keyword](https://www.baeldung.com/java-record-keyword)
|
||||||
- [New Features in Java 14](https://www.baeldung.com/java-14-new-features)
|
- [New Features in Java 14](https://www.baeldung.com/java-14-new-features)
|
||||||
|
- [Java 14 Record vs. Lombok](https://www.baeldung.com/java-record-vs-lombok)
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class BlogPost {
|
||||||
private BlogPostType type;
|
private BlogPostType type;
|
||||||
private int likes;
|
private int likes;
|
||||||
record AuthPostTypesLikes(String author, BlogPostType type, int likes) {};
|
record AuthPostTypesLikes(String author, BlogPostType type, int likes) {};
|
||||||
record PostcountTitlesLikesStats(long postCount, String titles, IntSummaryStatistics likesStats){};
|
record PostCountTitlesLikesStats(long postCount, String titles, IntSummaryStatistics likesStats){};
|
||||||
record TitlesBoundedSumOfLikes(String titles, int boundedSumOfLikes) {};
|
record TitlesBoundedSumOfLikes(String titles, int boundedSumOfLikes) {};
|
||||||
|
|
||||||
public BlogPost(String title, String author, BlogPostType type, int likes) {
|
public BlogPost(String title, String author, BlogPostType type, int likes) {
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class JavaGroupingByCollectorUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenListOfPosts_whenGroupedByAuthor_thenGetAMapUsingCollectingAndThen() {
|
public void givenListOfPosts_whenGroupedByAuthor_thenGetAMapUsingCollectingAndThen() {
|
||||||
|
|
||||||
Map<String, BlogPost.PostcountTitlesLikesStats> postsPerAuthor = posts.stream()
|
Map<String, BlogPost.PostCountTitlesLikesStats> postsPerAuthor = posts.stream()
|
||||||
.collect(groupingBy(BlogPost::getAuthor, collectingAndThen(toList(), list -> {
|
.collect(groupingBy(BlogPost::getAuthor, collectingAndThen(toList(), list -> {
|
||||||
long count = list.stream()
|
long count = list.stream()
|
||||||
.map(BlogPost::getTitle)
|
.map(BlogPost::getTitle)
|
||||||
|
@ -267,10 +267,10 @@ public class JavaGroupingByCollectorUnitTest {
|
||||||
.collect(joining(" : "));
|
.collect(joining(" : "));
|
||||||
IntSummaryStatistics summary = list.stream()
|
IntSummaryStatistics summary = list.stream()
|
||||||
.collect(summarizingInt(BlogPost::getLikes));
|
.collect(summarizingInt(BlogPost::getLikes));
|
||||||
return new BlogPost.PostcountTitlesLikesStats(count, titles, summary);
|
return new BlogPost.PostCountTitlesLikesStats(count, titles, summary);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
BlogPost.PostcountTitlesLikesStats result = postsPerAuthor.get("Author 1");
|
BlogPost.PostCountTitlesLikesStats result = postsPerAuthor.get("Author 1");
|
||||||
assertThat(result.postCount()).isEqualTo(3L);
|
assertThat(result.postCount()).isEqualTo(3L);
|
||||||
assertThat(result.titles()).isEqualTo("News item 1 : Programming guide : Tech review 2");
|
assertThat(result.titles()).isEqualTo("News item 1 : Programming guide : Tech review 2");
|
||||||
assertThat(result.likesStats().getMax()).isEqualTo(20);
|
assertThat(result.likesStats().getMax()).isEqualTo(20);
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class InputStreamToOutputStreamUnitTest {
|
||||||
void copy(InputStream source, OutputStream target) throws IOException {
|
void copy(InputStream source, OutputStream target) throws IOException {
|
||||||
byte[] buf = new byte[8192];
|
byte[] buf = new byte[8192];
|
||||||
int length;
|
int length;
|
||||||
while ((length = source.read(buf)) > 0) {
|
while ((length = source.read(buf)) != -1) {
|
||||||
target.write(buf, 0, length);
|
target.write(buf, 0, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,5 @@
|
||||||
<properties>
|
<properties>
|
||||||
<commons-lang.version>2.2</commons-lang.version>
|
<commons-lang.version>2.2</commons-lang.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -57,6 +57,7 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<trove4j.version>3.0.2</trove4j.version>
|
<trove4j.version>3.0.2</trove4j.version>
|
||||||
<fastutil.version>8.1.0</fastutil.version>
|
<fastutil.version>8.1.0</fastutil.version>
|
||||||
|
|
|
@ -10,3 +10,5 @@ This module contains articles about JAR files
|
||||||
- [Get Names of Classes Inside a JAR File](https://www.baeldung.com/jar-file-get-class-names)
|
- [Get Names of Classes Inside a JAR File](https://www.baeldung.com/jar-file-get-class-names)
|
||||||
- [Find All Jars Containing Given Class](https://baeldung.com/find-all-jars-containing-given-class/)
|
- [Find All Jars Containing Given Class](https://baeldung.com/find-all-jars-containing-given-class/)
|
||||||
- [Creating JAR Files Programmatically](https://www.baeldung.com/jar-create-programatically)
|
- [Creating JAR Files Programmatically](https://www.baeldung.com/jar-create-programatically)
|
||||||
|
- [Guide to Creating Jar Executables and Windows Executables from Java](https://www.baeldung.com/jar-windows-executables)
|
||||||
|
- [Get the Full Path of a JAR File From a Class](https://www.baeldung.com/java-full-path-of-jar-from-class)
|
||||||
|
|
|
@ -5,3 +5,4 @@ This module contains articles about core features in the Java language
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
|
|
||||||
- [Difference Between == and equals() in Java](https://www.baeldung.com/java-equals-method-operator-difference)
|
- [Difference Between == and equals() in Java](https://www.baeldung.com/java-equals-method-operator-difference)
|
||||||
|
- [Advantages and Disadvantages of Using Java Wildcard Imports](https://www.baeldung.com/java-wildcard-imports)
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
<version>3.23.1</version>
|
<version>3.23.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -11,3 +11,4 @@ This module contains articles about string APIs.
|
||||||
- [StringBuilder vs StringBuffer in Java](https://www.baeldung.com/java-string-builder-string-buffer)
|
- [StringBuilder vs StringBuffer in Java](https://www.baeldung.com/java-string-builder-string-buffer)
|
||||||
- [Generate a Secure Random Password in Java](https://www.baeldung.com/java-generate-secure-password)
|
- [Generate a Secure Random Password in Java](https://www.baeldung.com/java-generate-secure-password)
|
||||||
- [Getting a Character by Index From a String in Java](https://www.baeldung.com/java-character-at-position)
|
- [Getting a Character by Index From a String in Java](https://www.baeldung.com/java-character-at-position)
|
||||||
|
- [Clearing a StringBuilder or StringBuffer](https://www.baeldung.com/java-clear-stringbuilder-stringbuffer)
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
- [String equals() Vs contentEquals() in Java](https://www.baeldung.com/java-string-equals-vs-contentequals)
|
- [String equals() Vs contentEquals() in Java](https://www.baeldung.com/java-string-equals-vs-contentequals)
|
||||||
- [Check if a String Ends with a Certain Pattern in Java](https://www.baeldung.com/java-string-ends-pattern)
|
- [Check if a String Ends with a Certain Pattern in Java](https://www.baeldung.com/java-string-ends-pattern)
|
||||||
- [Check if a Character is a Vowel in Java](https://www.baeldung.com/java-check-character-vowel)
|
- [Check if a Character is a Vowel in Java](https://www.baeldung.com/java-check-character-vowel)
|
||||||
|
- [How to Truncate a String in Java](https://www.baeldung.com/java-truncating-strings)
|
||||||
|
|
|
@ -96,7 +96,23 @@ public class Java8EncodeDecodeUnitTest {
|
||||||
assertNotNull(decodedMime);
|
assertNotNull(decodedMime);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
@Test
|
||||||
|
public void whenEncodedStringHasValidCharacters_thenStringCanBeDecoded() {
|
||||||
|
final String encodedString = "dGVzdCMkaW5wdXQ+";
|
||||||
|
final byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
|
||||||
|
final String decodedString = new String(decodedBytes);
|
||||||
|
|
||||||
|
assertNotNull(decodedString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void whenEncodedStringHasInvalidCharacters_thenIllegalArgumentException() {
|
||||||
|
final String encodedString = "dGVzdCMkaW5wdXQ#";
|
||||||
|
final byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
|
||||||
|
final String decodedString = new String(decodedBytes);
|
||||||
|
|
||||||
|
assertNotNull(decodedString);
|
||||||
|
}
|
||||||
|
|
||||||
private static StringBuilder getMimeBuffer() {
|
private static StringBuilder getMimeBuffer() {
|
||||||
final StringBuilder buffer = new StringBuilder();
|
final StringBuilder buffer = new StringBuilder();
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
|
|
@ -14,12 +14,6 @@
|
||||||
<relativePath>../parent-boot-2</relativePath>
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<feign.version>11.8</feign.version>
|
|
||||||
<wsdl4j.version>1.6.3</wsdl4j.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.openfeign</groupId>
|
<groupId>io.github.openfeign</groupId>
|
||||||
|
@ -121,4 +115,10 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<feign.version>11.8</feign.version>
|
||||||
|
<wsdl4j.version>1.6.3</wsdl4j.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,3 @@
|
||||||
|
## Gradle Modules
|
||||||
|
|
||||||
|
This module contains submodules of Gradle.
|
|
@ -1,4 +1,4 @@
|
||||||
rootProject.name='gradle-5-articles'
|
rootProject.name='gradle-5'
|
||||||
include 'java-exec'
|
include 'java-exec'
|
||||||
include 'unused-dependencies'
|
include 'unused-dependencies'
|
||||||
include 'source-sets'
|
include 'source-sets'
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue