Merge branch 'master' into master
This commit is contained in:
+23
-5
@@ -35,12 +35,12 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.flink</groupId>
|
||||
<artifactId>flink-connector-kafka-0.11_2.11</artifactId>
|
||||
<artifactId>flink-connector-kafka</artifactId>
|
||||
<version>${flink.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.flink</groupId>
|
||||
<artifactId>flink-streaming-java_2.11</artifactId>
|
||||
<artifactId>flink-streaming-java</artifactId>
|
||||
<version>${flink.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -67,7 +67,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.flink</groupId>
|
||||
<artifactId>flink-test-utils_2.11</artifactId>
|
||||
<artifactId>flink-test-utils</artifactId>
|
||||
<version>${flink.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@@ -163,11 +163,29 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>
|
||||
--add-opens java.base/java.time=ALL-UNNAMED
|
||||
--add-opens java.base/java.nio=ALL-UNNAMED
|
||||
--add-opens java.base/java.util=ALL-UNNAMED
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
<properties>
|
||||
<kafka.version>2.8.0</kafka.version>
|
||||
<kafka.version>3.4.0</kafka.version>
|
||||
<testcontainers-kafka.version>1.15.3</testcontainers-kafka.version>
|
||||
<testcontainers-jupiter.version>1.15.3</testcontainers-jupiter.version>
|
||||
<flink.version>1.5.0</flink.version>
|
||||
<flink.version>1.16.1</flink.version>
|
||||
<awaitility.version>3.0.0</awaitility.version>
|
||||
<org.apache.spark.spark-core.version>2.4.8</org.apache.spark.spark-core.version>
|
||||
<graphframes.version>0.8.1-spark3.0-s_2.12</graphframes.version>
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.apache.flink.streaming.api.TimeCharacteristic;
|
||||
import org.apache.flink.streaming.api.datastream.DataStream;
|
||||
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
|
||||
import org.apache.flink.streaming.api.windowing.time.Time;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer011;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer;
|
||||
|
||||
import static com.baeldung.flink.connector.Consumers.*;
|
||||
import static com.baeldung.flink.connector.Producers.*;
|
||||
@@ -25,12 +25,12 @@ public class FlinkDataPipeline {
|
||||
|
||||
StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();
|
||||
|
||||
FlinkKafkaConsumer011<String> flinkKafkaConsumer = createStringConsumerForTopic(inputTopic, address, consumerGroup);
|
||||
FlinkKafkaConsumer<String> flinkKafkaConsumer = createStringConsumerForTopic(inputTopic, address, consumerGroup);
|
||||
flinkKafkaConsumer.setStartFromEarliest();
|
||||
|
||||
DataStream<String> stringInputStream = environment.addSource(flinkKafkaConsumer);
|
||||
|
||||
FlinkKafkaProducer011<String> flinkKafkaProducer = createStringProducer(outputTopic, address);
|
||||
FlinkKafkaProducer<String> flinkKafkaProducer = createStringProducer(outputTopic, address);
|
||||
|
||||
stringInputStream.map(new WordsCapitalizer())
|
||||
.addSink(flinkKafkaProducer);
|
||||
@@ -48,11 +48,11 @@ public class FlinkDataPipeline {
|
||||
|
||||
environment.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
|
||||
|
||||
FlinkKafkaConsumer011<InputMessage> flinkKafkaConsumer = createInputMessageConsumer(inputTopic, kafkaAddress, consumerGroup);
|
||||
FlinkKafkaConsumer<InputMessage> flinkKafkaConsumer = createInputMessageConsumer(inputTopic, kafkaAddress, consumerGroup);
|
||||
flinkKafkaConsumer.setStartFromEarliest();
|
||||
|
||||
flinkKafkaConsumer.assignTimestampsAndWatermarks(new InputMessageTimestampAssigner());
|
||||
FlinkKafkaProducer011<Backup> flinkKafkaProducer = createBackupProducer(outputTopic, kafkaAddress);
|
||||
FlinkKafkaProducer<Backup> flinkKafkaProducer = createBackupProducer(outputTopic, kafkaAddress);
|
||||
|
||||
DataStream<InputMessage> inputMessagesStream = environment.addSource(flinkKafkaConsumer);
|
||||
|
||||
|
||||
@@ -3,26 +3,26 @@ package com.baeldung.flink.connector;
|
||||
import com.baeldung.flink.model.InputMessage;
|
||||
import com.baeldung.flink.schema.InputMessageDeserializationSchema;
|
||||
import org.apache.flink.api.common.serialization.SimpleStringSchema;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer011;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class Consumers {
|
||||
|
||||
public static FlinkKafkaConsumer011<String> createStringConsumerForTopic(String topic, String kafkaAddress, String kafkaGroup) {
|
||||
public static FlinkKafkaConsumer<String> createStringConsumerForTopic(String topic, String kafkaAddress, String kafkaGroup) {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("bootstrap.servers", kafkaAddress);
|
||||
props.setProperty("group.id", kafkaGroup);
|
||||
FlinkKafkaConsumer011<String> consumer = new FlinkKafkaConsumer011<>(topic, new SimpleStringSchema(), props);
|
||||
FlinkKafkaConsumer<String> consumer = new FlinkKafkaConsumer<>(topic, new SimpleStringSchema(), props);
|
||||
|
||||
return consumer;
|
||||
}
|
||||
|
||||
public static FlinkKafkaConsumer011<InputMessage> createInputMessageConsumer(String topic, String kafkaAddress, String kafkaGroup) {
|
||||
public static FlinkKafkaConsumer<InputMessage> createInputMessageConsumer(String topic, String kafkaAddress, String kafkaGroup) {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("bootstrap.servers", kafkaAddress);
|
||||
properties.setProperty("group.id", kafkaGroup);
|
||||
FlinkKafkaConsumer011<InputMessage> consumer = new FlinkKafkaConsumer011<InputMessage>(topic, new InputMessageDeserializationSchema(), properties);
|
||||
FlinkKafkaConsumer<InputMessage> consumer = new FlinkKafkaConsumer<InputMessage>(topic, new InputMessageDeserializationSchema(), properties);
|
||||
|
||||
return consumer;
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ package com.baeldung.flink.connector;
|
||||
import com.baeldung.flink.model.Backup;
|
||||
import com.baeldung.flink.schema.BackupSerializationSchema;
|
||||
import org.apache.flink.api.common.serialization.SimpleStringSchema;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer;
|
||||
|
||||
public class Producers {
|
||||
|
||||
public static FlinkKafkaProducer011<String> createStringProducer(String topic, String kafkaAddress) {
|
||||
return new FlinkKafkaProducer011<>(kafkaAddress, topic, new SimpleStringSchema());
|
||||
public static FlinkKafkaProducer<String> createStringProducer(String topic, String kafkaAddress) {
|
||||
return new FlinkKafkaProducer<>(kafkaAddress, topic, new SimpleStringSchema());
|
||||
}
|
||||
|
||||
public static FlinkKafkaProducer011<Backup> createBackupProducer(String topic, String kafkaAddress) {
|
||||
return new FlinkKafkaProducer011<Backup>(kafkaAddress, topic, new BackupSerializationSchema());
|
||||
public static FlinkKafkaProducer<Backup> createBackupProducer(String topic, String kafkaAddress) {
|
||||
return new FlinkKafkaProducer<Backup>(kafkaAddress, topic, new BackupSerializationSchema());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
<docker.image.prefix>${azure.containerRegistry}.azurecr.io</docker.image.prefix>
|
||||
<docker-maven-plugin.version>1.1.0</docker-maven-plugin.version>
|
||||
<azure-webapp-maven-plugin.version>1.1.0</azure-webapp-maven-plugin.version>
|
||||
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1 @@
|
||||
### Relevant Articles:
|
||||
@@ -0,0 +1,25 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-conversions.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-numbers-conversions</artifactId>
|
||||
<name>core-java-numbers-conversions</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<finalName>core-java-numbers-conversions</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.baeldung.numtoletter;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
||||
public class ConvertNumberToLetterUnitTest {
|
||||
|
||||
static char numToLetterBySubstr(int i) {
|
||||
String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
if (i > 0 && i <= 25) {
|
||||
return LETTERS.substring(i, i + 1).charAt(0);
|
||||
} else {
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
static char numToLetterByAsciiCode(int i) {
|
||||
if (i > 0 && i <= 25) {
|
||||
return (char) ('A' + i);
|
||||
} else {
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenANumber_whenConvertToLetterUsingSubstring_shouldGetExpectedResult() {
|
||||
char negativeInputResult = numToLetterBySubstr(-7);
|
||||
assertEquals('?', negativeInputResult);
|
||||
|
||||
char tooLargeInputResult = numToLetterBySubstr(42);
|
||||
assertEquals('?', tooLargeInputResult);
|
||||
|
||||
char result = numToLetterBySubstr(10);
|
||||
assertEquals('K', result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenANumber_whenConvertToLetterUsingAscii_shouldGetExpectedResult() {
|
||||
char negativeInputResult = numToLetterByAsciiCode(-7);
|
||||
assertEquals('?', negativeInputResult);
|
||||
|
||||
char tooLargeInputResult = numToLetterByAsciiCode(42);
|
||||
assertEquals('?', tooLargeInputResult);
|
||||
|
||||
char charResult = numToLetterByAsciiCode(10);
|
||||
assertEquals('K', charResult);
|
||||
|
||||
assertEquals("K", String.valueOf(charResult));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -40,6 +40,6 @@ public class CharacterEncodingExamples {
|
||||
charsetDecoder.onMalformedInput(codingErrorAction);
|
||||
return new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new ByteArrayInputStream(input.getBytes()), charsetDecoder)).readLine();
|
||||
new ByteArrayInputStream(input.getBytes(charset)), charsetDecoder)).readLine();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -75,7 +75,7 @@ public class CharacterEncodingExamplesUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenUTF8String_whenDecodeByUS_ASCII_thenIgnoreMalformedInputSequence() throws IOException {
|
||||
Assertions.assertEquals("The faade pattern is a software design pattern.", CharacterEncodingExamples.decodeText("The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.IGNORE));
|
||||
Assertions.assertEquals("The fa?ade pattern is a software design pattern.", CharacterEncodingExamples.decodeText("The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.IGNORE));
|
||||
}
|
||||
|
||||
//@Test
|
||||
@@ -89,7 +89,8 @@ public class CharacterEncodingExamplesUnitTest {
|
||||
CodingErrorAction.REPLACE));
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
// run this manually as it's dependent on platform encoding
|
||||
public void givenUTF8String_whenDecodeByUS_ASCII_thenReportMalformedInputSequence() {
|
||||
Assertions.assertThrows(
|
||||
MalformedInputException.class,
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
<module>core-java-numbers-3</module>
|
||||
<module>core-java-numbers-4</module>
|
||||
<module>core-java-numbers-5</module>
|
||||
<module>core-java-numbers-conversions</module>
|
||||
<module>core-java-optional</module>
|
||||
<module>core-java-perf</module>
|
||||
<module>core-java-reflection</module>
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@
|
||||
<configuration>
|
||||
<packageName>com.baeldung.feign.soap</packageName>
|
||||
<sources>
|
||||
<source>src/main/resources/users.xsd</source>
|
||||
<source>${project.basedir}/src/main/resources/users.xsd</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<properties>
|
||||
<javax.websocket-api.version>1.1</javax.websocket-api.version>
|
||||
<gson.version>2.8.0</gson.version>
|
||||
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,5 @@
|
||||
## Jetbrains
|
||||
|
||||
This module contains articles about Jetbrains' libraries.
|
||||
|
||||
### Relevant articles:
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jetbrains</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>jetbrains</name>
|
||||
<packaging>jar</packaging>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${apache.commons.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>${jetbrains.annotations.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<apache.commons.version>3.12.0</apache.commons.version>
|
||||
<jetbrains.annotations.version>24.0.1</jetbrains.annotations.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class Demo {
|
||||
|
||||
@Contract("_ -> new")
|
||||
Person fromName(String name) {
|
||||
return new Person().withName(name);
|
||||
}
|
||||
|
||||
@Contract(" -> fail")
|
||||
void alwaysFail() {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Contract(" -> fail")
|
||||
void doNothingWithWrongContract() {
|
||||
|
||||
}
|
||||
|
||||
@Contract("_, null -> null; null, _ -> param2; _, !null -> !null")
|
||||
String concatenateOnlyIfSecondArgumentIsNotNull(String head, String tail) {
|
||||
if (tail == null) {
|
||||
return null;
|
||||
}
|
||||
if (head == null) {
|
||||
return tail;
|
||||
}
|
||||
return head + tail;
|
||||
}
|
||||
|
||||
void uselessNullCheck() {
|
||||
String head = "1234";
|
||||
String tail = "5678";
|
||||
String concatenation = concatenateOnlyIfSecondArgumentIsNotNull(head, tail);
|
||||
if (concatenation != null) {
|
||||
System.out.println(concatenation);
|
||||
}
|
||||
}
|
||||
|
||||
void uselessNullCheckOnInferredAnnotation() {
|
||||
if (StringUtils.isEmpty(null)) {
|
||||
System.out.println("baeldung");
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
String replace(String string, char oldChar, char newChar) {
|
||||
return string.replace(oldChar, newChar);
|
||||
}
|
||||
|
||||
@Contract(value = "true -> false; false -> true", pure = true)
|
||||
boolean not(boolean input) {
|
||||
return !input;
|
||||
}
|
||||
|
||||
@Contract("true -> new")
|
||||
void contractExpectsWrongParameterType(List<Integer> integers) {
|
||||
|
||||
}
|
||||
|
||||
@Contract("_, _ -> new")
|
||||
void contractExpectsMoreParametersThanMethodHas(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Contract("_ -> _; null -> !null")
|
||||
String secondContractClauseNotReachable(String s) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Contract("_ -> true")
|
||||
void contractExpectsWrongReturnType(String s) {
|
||||
|
||||
}
|
||||
|
||||
// NB: the following examples demonstrate how to use the mutates attribute of the annotation
|
||||
// This attribute is currently experimental and could be changed or removed in the future
|
||||
@Contract(mutates = "param")
|
||||
void incrementArrayFirstElement(Integer[] integers) {
|
||||
if (integers.length > 0) {
|
||||
integers[0] = integers[0] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(pure = true, mutates = "param")
|
||||
void impossibleToMutateParamInPureFunction(List<String> strings) {
|
||||
if (strings != null) {
|
||||
strings.forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(mutates = "param3")
|
||||
void impossibleToMutateThirdParamWhenMethodHasOnlyTwoParams(int a, int b) {
|
||||
|
||||
}
|
||||
|
||||
@Contract(mutates = "param")
|
||||
void impossibleToMutableImmutableType(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Contract(mutates = "this")
|
||||
static void impossibleToMutateThisInStaticMethod() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class Person {
|
||||
|
||||
String name;
|
||||
|
||||
@Contract("_ -> this")
|
||||
Person withName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+8
-2
@@ -48,8 +48,15 @@
|
||||
<plugin>
|
||||
<groupId>com.lazerycode.jmeter</groupId>
|
||||
<artifactId>jmeter-maven-plugin</artifactId>
|
||||
<version>${jmeter.version}</version>
|
||||
<version>3.7.0</version>
|
||||
<executions>
|
||||
<!-- Generate JMeter configuration -->
|
||||
<execution>
|
||||
<id>configuration</id>
|
||||
<goals>
|
||||
<goal>configure</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jmeter-tests</id>
|
||||
<goals>
|
||||
@@ -66,7 +73,6 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<jmeter.version>2.6.0</jmeter.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<stringProp name="filename"></stringProp>
|
||||
<stringProp name="parameters"></stringProp>
|
||||
<boolProp name="resetInterpreter">false</boolProp>
|
||||
<stringProp name="script">FileWriter fWriter = new FileWriter("<path>/result.txt", true);
|
||||
<stringProp name="script">FileWriter fWriter = new FileWriter("<path>/result.txt", true);
|
||||
BufferedWriter buff = new BufferedWriter(fWriter);
|
||||
|
||||
buff.write("Response Code : " + ctx.getPreviousResult().getResponseCode());
|
||||
|
||||
@@ -47,7 +47,7 @@ public class JsoupParserIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void examplesSelectors() {
|
||||
public void examplesSelectors() throws IOException {
|
||||
Elements links = doc.select("a");
|
||||
Elements logo = doc.select(".spring-logo--container");
|
||||
Elements pagination = doc.select("#pagination_control");
|
||||
@@ -57,52 +57,46 @@ public class JsoupParserIntegrationTest {
|
||||
Element pag = doc.getElementById("pagination_control");
|
||||
Elements desktopOnly = doc.getElementsByClass("desktopOnly");
|
||||
|
||||
Elements sections = doc.select("section");
|
||||
Element firstSection = sections.first();
|
||||
Elements sectionParagraphs = firstSection.select(".paragraph");
|
||||
Elements articles = doc.select("article");
|
||||
Element firstArticle = articles.first();
|
||||
Elements sectionParagraphs = firstArticle.select(".paragraph");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void examplesTraversing() {
|
||||
Elements sections = doc.select("section");
|
||||
public void examplesTraversing() throws IOException {
|
||||
Elements articles = doc.select("article");
|
||||
|
||||
Element firstSection = sections.first();
|
||||
Element lastSection = sections.last();
|
||||
Element secondSection = sections.get(2);
|
||||
Elements allParents = firstSection.parents();
|
||||
Element parent = firstSection.parent();
|
||||
Elements children = firstSection.children();
|
||||
Elements siblings = firstSection.siblingElements();
|
||||
Element firstArticle = articles.first();
|
||||
Element lastSection = articles.last();
|
||||
Element secondSection = articles.get(2);
|
||||
Elements allParents = firstArticle.parents();
|
||||
Element parent = firstArticle.parent();
|
||||
Elements children = firstArticle.children();
|
||||
Elements siblings = firstArticle.siblingElements();
|
||||
|
||||
sections.forEach(el -> System.out.println("section: " + el));
|
||||
articles.forEach(el -> System.out.println("article: " + el));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void examplesExtracting() {
|
||||
public void examplesExtracting() throws IOException {
|
||||
Element firstArticle = doc.select("article")
|
||||
.first();
|
||||
Element timeElement = firstArticle.select("time")
|
||||
Element titleElement = firstArticle.select("h1 a")
|
||||
.first();
|
||||
String dateTimeOfFirstArticle = timeElement.attr("datetime");
|
||||
Element sectionDiv = firstArticle.select("section div")
|
||||
.first();
|
||||
String sectionDivText = sectionDiv.text();
|
||||
|
||||
String titleText = titleElement.text();
|
||||
String articleHtml = firstArticle.html();
|
||||
String outerHtml = firstArticle.outerHtml();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void examplesModifying() {
|
||||
public void examplesModifying() throws IOException {
|
||||
Element firstArticle = doc.select("article")
|
||||
.first();
|
||||
Element timeElement = firstArticle.select("time")
|
||||
.first();
|
||||
Element sectionDiv = firstArticle.select("section div")
|
||||
Element h1Element = firstArticle.select("h1")
|
||||
.first();
|
||||
|
||||
String dateTimeOfFirstArticle = timeElement.attr("datetime");
|
||||
timeElement.attr("datetime", "2016-12-16 15:19:54.3");
|
||||
sectionDiv.text("foo bar");
|
||||
h1Element.text("foo bar");
|
||||
firstArticle.select("h2")
|
||||
.html("<div><span></span></div>");
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
<modules>
|
||||
<module>k8s-intro</module>
|
||||
<module>k8s-admission-controller</module>
|
||||
<!-- <module>kubernetes-spring</module> --> <!-- JDK-11 Module -->
|
||||
<module>k8s-java-heap-dump</module>
|
||||
<module>kubernetes-spring</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
+1
-1
@@ -132,7 +132,7 @@
|
||||
<properties>
|
||||
<mapdb.version>3.0.8</mapdb.version>
|
||||
<classgraph.version>4.8.153</classgraph.version>
|
||||
<jbpm.version>7.1.0.Final</jbpm.version>
|
||||
<jbpm.version>7.20.0.Final</jbpm.version>
|
||||
<picocli.version>4.7.0</picocli.version>
|
||||
<chronicle.map.version>3.24ea1</chronicle.map.version>
|
||||
<crawler4j.version>4.4.0</crawler4j.version>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<process processType="Private" isExecutable="true" id="com.baeldung.bpmn.helloworld" name="HelloWorld Process" tns:packageName="com.baeldung.bpmn.process" >
|
||||
|
||||
<!-- nodes -->
|
||||
<scriptTask id="_jbpm-unique-1" name="HelloWorld" scriptFormat="http://www.java.com/java" >
|
||||
<scriptTask id="_jbpm-unique-1" name="HelloWorld">
|
||||
<script>System.out.println("Hello World");</script>
|
||||
</scriptTask>
|
||||
<endEvent id="_jbpm-unique-2" name="End" >
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.baeldung.jbpm;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.jbpm.test.JbpmJUnitBaseTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -47,6 +50,6 @@ public class WorkflowEngineIntegrationTest extends JbpmJUnitBaseTestCase {
|
||||
@Test
|
||||
public void givenProcessInstance_whenExecutionCompleted_thenVerifyProcessInstanceStatus() {
|
||||
assertProcessInstanceCompleted(processInstance.getId(), ksession);
|
||||
assertTrue("ProcessInstance completed with status 2", processInstance.getState() == 2);
|
||||
assertEquals("ProcessInstance completed with status 2", 2, processInstance.getState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<module>jgroups</module>
|
||||
<module>rabbitmq</module>
|
||||
<module>spring-amqp</module>
|
||||
<module>spring-apache-camel</module>
|
||||
<module>spring-jms</module>
|
||||
</modules>
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>${maven-war-plugin.version}</version>
|
||||
<configuration>
|
||||
<warSourceDirectory>src/main/webapp</warSourceDirectory>
|
||||
<warName>spring-jms</warName>
|
||||
@@ -83,6 +82,7 @@
|
||||
<springframework.version>4.3.4.RELEASE</springframework.version>
|
||||
<activemq.version>5.14.1</activemq.version>
|
||||
<spring-boot-test.version>1.5.10.RELEASE</spring-boot-test.version>
|
||||
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.baeldung.fluentinterface;
|
||||
|
||||
import static java.util.Arrays.stream;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
public class HtmlDocument {
|
||||
private final String content;
|
||||
|
||||
private HtmlDocument(String html) {
|
||||
this.content = html;
|
||||
}
|
||||
|
||||
public HtmlDocument() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public String html() {
|
||||
return String.format("<html>%s</html>", content);
|
||||
}
|
||||
|
||||
public HtmlDocument header(String header) {
|
||||
return new HtmlDocument(String.format("%s <h1>%s</h1>", content, header));
|
||||
}
|
||||
|
||||
public HtmlDocument secondaryHeader(String header) {
|
||||
return new HtmlDocument(String.format("%s <h2>%s</h2>", content, header));
|
||||
}
|
||||
|
||||
public HtmlDocument paragraph(String paragraph) {
|
||||
return new HtmlDocument(String.format("%s <p>%s</p>", content, paragraph));
|
||||
}
|
||||
|
||||
public HtmlDocument horizontalLine() {
|
||||
return new HtmlDocument(String.format("%s <hr>", content));
|
||||
}
|
||||
|
||||
public HtmlDocument orderedList(String... items) {
|
||||
String listItems = stream(items).map(el -> String.format("<li>%s</li>", el)).collect(joining());
|
||||
return new HtmlDocument(String.format("%s <ol>%s</ol>", content, listItems));
|
||||
}
|
||||
|
||||
public HtmlDocument unorderedList(String... items) {
|
||||
String listItems = stream(items).map(el -> String.format("<li>%s</li>", el)).collect(joining());
|
||||
return new HtmlDocument(String.format("%s <ul>%s</ul>", content, listItems));
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.baeldung.fluentinterface;
|
||||
|
||||
import com.baeldung.fluentinterface.components.HtmlElement;
|
||||
import com.baeldung.fluentinterface.components.HtmlHeader;
|
||||
import com.baeldung.fluentinterface.components.HtmlList;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Arrays.stream;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
public class LargeHtmlDocument {
|
||||
private final String content;
|
||||
|
||||
private LargeHtmlDocument(String html) {
|
||||
this.content = html;
|
||||
}
|
||||
|
||||
public LargeHtmlDocument() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public String html() {
|
||||
return format("<html>%s</html>", content);
|
||||
}
|
||||
|
||||
public LargeHtmlDocument head(HtmlElement head) {
|
||||
return new LargeHtmlDocument(format("%s <head>%s</head>", content, head.html()));
|
||||
}
|
||||
public LargeHtmlDocument body(HtmlElement body) {
|
||||
return new LargeHtmlDocument(format("%s <body>%s</body>", content, body.html()));
|
||||
}
|
||||
public LargeHtmlDocument footer(HtmlElement footer) {
|
||||
return new LargeHtmlDocument(format("%s <footer>%s</footer>", content, footer.html()));
|
||||
}
|
||||
|
||||
private LargeHtmlDocument append(String html) {
|
||||
return new LargeHtmlDocument(format("%s %s", content, html));
|
||||
}
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.baeldung.fluentinterface;
|
||||
|
||||
public class User {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private String username;
|
||||
private Long id;
|
||||
|
||||
public String name() {
|
||||
return firstName + " " + lastName;
|
||||
}
|
||||
|
||||
public User(String firstName, String lastName, String email, String username, Long id) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
this.username = username;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private String username;
|
||||
private Long id;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public Builder firstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder lastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder email(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public User build() {
|
||||
return new User(firstName, lastName, email, username, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.baeldung.fluentinterface.components;
|
||||
|
||||
public class HorizontalLine implements HtmlElement {
|
||||
@Override
|
||||
public String html() {
|
||||
return "<hr>";
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user