Skip to content

Commit cc55418

Browse files
authored
Merge branch 'master' into BAEL-981_pact
2 parents a0acc40 + 7ee3e57 commit cc55418

13 files changed

Lines changed: 207 additions & 93 deletions

File tree

‎asciidoctor/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Relevant articles
2+
3+
- [Introduction to Asciidoctor](http://www.baeldung.com/introduction-to-asciidoctor)

‎asciidoctor/log4j.properties‎

Whitespace-only changes.

‎asciidoctor/pom.xml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<parent>
5+
<artifactId>parent-modules</artifactId>
6+
<groupId>com.baeldung</groupId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
11+
<artifactId>asciidoctor</artifactId>
12+
<name>asciidoctor</name>
13+
<build>
14+
<plugins>
15+
<plugin>
16+
<groupId>org.asciidoctor</groupId>
17+
<artifactId>asciidoctor-maven-plugin</artifactId>
18+
<version>1.5.5</version>
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.asciidoctor</groupId>
22+
<artifactId>asciidoctorj-pdf</artifactId>
23+
<version>1.5.0-alpha.15</version>
24+
</dependency>
25+
</dependencies>
26+
<executions>
27+
<execution>
28+
<id>output-pdf</id>
29+
<phase>generate-resources</phase>
30+
<goals>
31+
<goal>process-asciidoc</goal>
32+
</goals>
33+
</execution>
34+
</executions>
35+
<configuration>
36+
<sourceDirectory>src/docs/asciidoc</sourceDirectory>
37+
<outputDirectory>target/docs/asciidoc</outputDirectory>
38+
<backend>pdf</backend>
39+
</configuration>
40+
</plugin>
41+
</plugins>
42+
</build>
43+
44+
<dependencies>
45+
<dependency>
46+
<groupId>org.asciidoctor</groupId>
47+
<artifactId>asciidoctorj</artifactId>
48+
<version>1.5.4</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.asciidoctor</groupId>
52+
<artifactId>asciidoctorj-pdf</artifactId>
53+
<version>1.5.0-alpha.11</version>
54+
</dependency>
55+
</dependencies>
56+
</project>

libraries/src/main/java/com/baeldung/asciidoctor/AsciidoctorDemo.java renamed to asciidoctor/src/main/java/com/baeldung/asciidoctor/AsciidoctorDemo.java

File renamed without changes.

libraries/src/test/java/com/baeldung/asciidoctor/AsciidoctorDemoTest.java renamed to asciidoctor/src/test/java/com/baeldung/asciidoctor/AsciidoctorDemoTest.java

File renamed without changes.

‎core-java/src/test/java/com/baeldung/string/StringToCharStreamUnitTest.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import static org.junit.Assert.assertEquals;
1313
import static org.junit.Assert.assertNotNull;
1414
import static org.junit.Assert.assertThat;
15-
import static org.junit.Assert.assertTrue;
1615

1716
public class StringToCharStreamUnitTest {
1817

@@ -44,7 +43,6 @@ public void givenIntStream_whenMapToObj_thenReturnCharacterStream() {
4443
.mapToObj(c -> (char) c);
4544
Stream<Character> characterStream1 = testString.codePoints()
4645
.mapToObj(c -> (char) c);
47-
4846
assertNotNull("IntStream returned by chars() did not map to Stream<Character>", characterStream);
4947
assertNotNull("IntStream returned by codePoints() did not map to Stream<Character>", characterStream1);
5048
}

‎libraries/pom.xml‎

Lines changed: 27 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<parent>
55
<artifactId>parent-modules</artifactId>
66
<groupId>com.baeldung</groupId>
@@ -59,7 +59,7 @@
5959
<props>${basedir}/datanucleus.properties</props>
6060
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
6161
<verbose>true</verbose>
62-
<fork>false</fork> <!-- Solve windows line too long error -->
62+
<fork>false</fork> <!-- Solve windows line too long error -->
6363
</configuration>
6464
<executions>
6565
<execution>
@@ -70,32 +70,6 @@
7070
</execution>
7171
</executions>
7272
</plugin>
73-
<plugin>
74-
<groupId>org.asciidoctor</groupId>
75-
<artifactId>asciidoctor-maven-plugin</artifactId>
76-
<version>1.5.5</version>
77-
<dependencies>
78-
<dependency>
79-
<groupId>org.asciidoctor</groupId>
80-
<artifactId>asciidoctorj-pdf</artifactId>
81-
<version>1.5.0-alpha.15</version>
82-
</dependency>
83-
</dependencies>
84-
<executions>
85-
<execution>
86-
<id>output-pdf</id>
87-
<phase>generate-resources</phase>
88-
<goals>
89-
<goal>process-asciidoc</goal>
90-
</goals>
91-
</execution>
92-
</executions>
93-
<configuration>
94-
<sourceDirectory>src/docs/asciidoc</sourceDirectory>
95-
<outputDirectory>target/docs/asciidoc</outputDirectory>
96-
<backend>pdf</backend>
97-
</configuration>
98-
</plugin>
9973
</plugins>
10074
</build>
10175

@@ -107,15 +81,20 @@
10781
<version>${cglib.version}</version>
10882
</dependency>
10983
<dependency>
110-
<groupId>commons-beanutils</groupId>
111-
<artifactId>commons-beanutils</artifactId>
112-
<version>${commons-beanutils.version}</version>
113-
</dependency>
84+
<groupId>commons-beanutils</groupId>
85+
<artifactId>commons-beanutils</artifactId>
86+
<version>${commons-beanutils.version}</version>
87+
</dependency>
11488
<dependency>
11589
<groupId>org.apache.commons</groupId>
11690
<artifactId>commons-lang3</artifactId>
11791
<version>${commons-lang.version}</version>
11892
</dependency>
93+
<dependency>
94+
<groupId>org.apache.commons</groupId>
95+
<artifactId>commons-collections4</artifactId>
96+
<version>${commons.collections.version}</version>
97+
</dependency>
11998
<dependency>
12099
<groupId>org.jasypt</groupId>
121100
<artifactId>jasypt</artifactId>
@@ -211,12 +190,6 @@
211190
<artifactId>serenity-core</artifactId>
212191
<version>${serenity.version}</version>
213192
<scope>test</scope>
214-
<exclusions>
215-
<exclusion>
216-
<groupId>org.asciidoctor</groupId>
217-
<artifactId>asciidoctor-java-integration</artifactId>
218-
</exclusion>
219-
</exclusions>
220193
</dependency>
221194
<dependency>
222195
<groupId>net.serenity-bdd</groupId>
@@ -272,7 +245,7 @@
272245
<groupId>org.datanucleus</groupId>
273246
<artifactId>datanucleus-maven-plugin</artifactId>
274247
<version>5.0.2</version>
275-
</dependency>
248+
</dependency>
276249
<dependency>
277250
<groupId>org.datanucleus</groupId>
278251
<artifactId>datanucleus-xml</artifactId>
@@ -324,11 +297,11 @@
324297
<version>1.4.195</version>
325298
</dependency>
326299
<dependency>
327-
<groupId>pl.pragmatists</groupId>
328-
<artifactId>JUnitParams</artifactId>
329-
<version>${jUnitParams.version}</version>
330-
<scope>test</scope>
331-
</dependency>
300+
<groupId>pl.pragmatists</groupId>
301+
<artifactId>JUnitParams</artifactId>
302+
<version>${jUnitParams.version}</version>
303+
<scope>test</scope>
304+
</dependency>
332305
<dependency>
333306
<groupId>org.quartz-scheduler</groupId>
334307
<artifactId>quartz</artifactId>
@@ -360,22 +333,18 @@
360333
<artifactId>netty-all</artifactId>
361334
<version>${netty.version}</version>
362335
</dependency>
363-
<dependency>
364-
<groupId>org.asciidoctor</groupId>
365-
<artifactId>asciidoctorj</artifactId>
366-
<version>1.5.4</version>
367-
</dependency>
368-
<dependency>
369-
<groupId>org.asciidoctor</groupId>
370-
<artifactId>asciidoctorj-pdf</artifactId>
371-
<version>1.5.0-alpha.11</version>
372-
</dependency>
373-
<!-- OpenNLP -->
336+
<!-- OpenNLP -->
374337
<dependency>
375338
<groupId>org.apache.opennlp</groupId>
376339
<artifactId>opennlp-tools</artifactId>
377340
<version>1.8.0</version>
378341
</dependency>
342+
<dependency>
343+
<groupId>junit</groupId>
344+
<artifactId>junit</artifactId>
345+
<version>${junit.version}</version>
346+
<scope>test</scope>
347+
</dependency>
379348
<dependency>
380349
<groupId>info.debatty</groupId>
381350
<artifactId>java-lsh</artifactId>
@@ -392,14 +361,12 @@
392361
<artifactId>groovy-all</artifactId>
393362
<version>2.4.10</version>
394363
</dependency>
395-
396-
397364
</dependencies>
398365
<properties>
399366
<multiverse.version>0.7.0</multiverse.version>
400367
<cglib.version>3.2.4</cglib.version>
401368
<commons-lang.version>3.5</commons-lang.version>
402-
<commons-beanutils.version>1.9.3</commons-beanutils.version>
369+
<commons-beanutils.version>1.9.3</commons-beanutils.version>
403370
<jasypt.version>1.9.2</jasypt.version>
404371
<javatuples.version>1.2</javatuples.version>
405372
<javaassist.version>3.21.0-GA</javaassist.version>
@@ -420,6 +387,8 @@
420387
<serenity.plugin.version>1.4.0</serenity.plugin.version>
421388
<jUnitParams.version>1.1.0</jUnitParams.version>
422389
<netty.version>4.1.10.Final</netty.version>
390+
<commons.collections.version>4.1</commons.collections.version>
391+
<junit.version>4.12</junit.version>
423392
<java-lsh.version>0.10</java-lsh.version>
424393
<pact.version>3.5.0</pact.version>
425394
</properties>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.baeldung.commons.collections;
2+
3+
import org.apache.commons.collections4.SetUtils;
4+
import org.apache.commons.collections4.set.TransformedSet;
5+
import org.junit.Test;
6+
7+
import java.util.Arrays;
8+
import java.util.HashSet;
9+
import java.util.Set;
10+
11+
import static org.junit.Assert.assertEquals;
12+
import static org.junit.Assert.assertTrue;
13+
14+
/**
15+
* Created by smatt on 21/06/2017.
16+
*/
17+
public class SetUtilsUnitTest {
18+
19+
@Test(expected = IllegalArgumentException.class)
20+
public void givenSetAndPredicate_whenPredicatedSet_thenValidateSet_and_throw_IllegalArgumentException() {
21+
Set<String> sourceSet = new HashSet<>();
22+
sourceSet.addAll(Arrays.asList("London", "Lagos", "Err Source1"));
23+
Set<String> validatingSet
24+
= SetUtils.predicatedSet(sourceSet, (s) -> s.startsWith("L"));
25+
validatingSet.add("Err Source2");
26+
}
27+
28+
@Test
29+
public void givenTwoSets_whenDifference_thenSetView() {
30+
Set<Integer> a = new HashSet<>(Arrays.asList(1,2,5));
31+
Set<Integer> b = new HashSet<>(Arrays.asList(1,2));
32+
SetUtils.SetView<Integer> result = SetUtils.difference(a, b);
33+
assertTrue(result.size() == 1 && result.contains(5));
34+
}
35+
36+
@Test
37+
public void givenTwoSets_whenUnion_thenUnionResult() {
38+
Set<Integer> a = new HashSet<>(Arrays.asList(1,2,5));
39+
Set<Integer> b = new HashSet<>(Arrays.asList(1,2));
40+
Set<Integer> expected = new HashSet<>(Arrays.asList(1,2,5));
41+
SetUtils.SetView<Integer> union = SetUtils.union(a, b);
42+
assertTrue(SetUtils.isEqualSet(expected, union));
43+
}
44+
45+
@Test
46+
public void givenTwoSets_whenIntersection_thenIntersectionResult() {
47+
Set<Integer> a = new HashSet<>(Arrays.asList(1,2,5));
48+
Set<Integer> b = new HashSet<>(Arrays.asList(1,2));
49+
Set<Integer> expected = new HashSet<>(Arrays.asList(1,2));
50+
SetUtils.SetView<Integer> intersect = SetUtils.intersection(a, b);
51+
assertTrue(SetUtils.isEqualSet(expected, intersect));
52+
}
53+
54+
@Test
55+
public void givenSet_whenTransformedSet_thenTransformedResult() {
56+
Set<Integer> a = SetUtils.transformedSet(new HashSet<>(), (e) -> e * 2 );
57+
a.add(2);
58+
assertEquals(a.toArray()[0], 4);
59+
60+
Set<Integer> source = new HashSet<>(Arrays.asList(1));
61+
Set<Integer> newSet = TransformedSet.transformedSet(source, (e) -> e * 2);
62+
assertEquals(newSet.toArray()[0], 2);
63+
assertEquals(source.toArray()[0], 2);
64+
}
65+
66+
@Test
67+
public void givenTwoSet_whenDisjunction_thenDisjunctionSet() {
68+
Set<Integer> a = new HashSet<>(Arrays.asList(1,2,5));
69+
Set<Integer> b = new HashSet<>(Arrays.asList(1,2,3));
70+
SetUtils.SetView<Integer> result = SetUtils.disjunction(a, b);
71+
assertTrue(result.toSet().contains(5) && result.toSet().contains(3));
72+
}
73+
74+
@Test
75+
public void givenSet_when_OrderedSet_thenMaintainElementOrder() {
76+
Set<Integer> set = new HashSet<>(Arrays.asList(10,1,5));
77+
System.out.println("unordered set: " + set);
78+
79+
Set<Integer> orderedSet = SetUtils.orderedSet(new HashSet<>());
80+
orderedSet.addAll(Arrays.asList(10,1,5));
81+
System.out.println("ordered set = " + orderedSet);
82+
}
83+
}

0 commit comments

Comments
 (0)