Skip to content

Commit eb244dd

Browse files
Merge remote-tracking branch 'origin/master'
2 parents 85410e3 + e3b1d3a commit eb244dd

118 files changed

Lines changed: 3093 additions & 611 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ target/
2727

2828
spring-openid/src/main/resources/application.properties
2929
.recommenders/
30-

‎assertj/pom.xml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,28 @@
99
<version>1.0.0-SNAPSHOT</version>
1010

1111
<dependencies>
12+
<dependency>
13+
<groupId>com.google.guava</groupId>
14+
<artifactId>guava</artifactId>
15+
<version>19.0</version>
16+
</dependency>
1217
<dependency>
1318
<groupId>junit</groupId>
1419
<artifactId>junit</artifactId>
1520
<version>4.12</version>
21+
<scope>test</scope>
1622
</dependency>
1723
<dependency>
1824
<groupId>org.assertj</groupId>
1925
<artifactId>assertj-core</artifactId>
2026
<version>3.4.1</version>
2127
<scope>test</scope>
2228
</dependency>
29+
<dependency>
30+
<groupId>org.assertj</groupId>
31+
<artifactId>assertj-guava</artifactId>
32+
<version>3.0.0</version>
33+
</dependency>
2334
</dependencies>
2435

2536
<build>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package com.baeldung.assertj.introduction;
2+
3+
import com.google.common.base.Optional;
4+
import com.google.common.collect.HashBasedTable;
5+
import com.google.common.collect.Multimap;
6+
import com.google.common.collect.Multimaps;
7+
import com.google.common.collect.Range;
8+
import com.google.common.collect.Sets;
9+
import com.google.common.collect.TreeRangeMap;
10+
import com.google.common.io.Files;
11+
import org.assertj.guava.data.MapEntry;
12+
import org.junit.Test;
13+
14+
import java.io.File;
15+
import java.util.HashMap;
16+
17+
import static org.assertj.guava.api.Assertions.assertThat;
18+
import static org.assertj.guava.api.Assertions.entry;
19+
20+
public class AssertJGuavaTest {
21+
22+
@Test
23+
public void givenTwoEmptyFiles_whenComparingContent_thenEqual() throws Exception {
24+
final File temp = File.createTempFile("bael", "dung");
25+
final File temp2 = File.createTempFile("bael", "dung2");
26+
27+
assertThat(Files.asByteSource(temp))
28+
.hasSize(0)
29+
.hasSameContentAs(Files.asByteSource(temp2));
30+
}
31+
32+
@Test
33+
public void givenMultimap_whenVerifying_thenCorrect() throws Exception {
34+
final Multimap<Integer, String> mmap = Multimaps.newMultimap(new HashMap<>(), Sets::newHashSet);
35+
mmap.put(1, "one");
36+
mmap.put(1, "1");
37+
38+
assertThat(mmap)
39+
.hasSize(2)
40+
.containsKeys(1)
41+
.contains(entry(1, "one"))
42+
.contains(entry(1, "1"));
43+
}
44+
45+
@Test
46+
public void givenOptional_whenVerifyingContent_thenShouldBeEqual() throws Exception {
47+
final Optional<String> something = Optional.of("something");
48+
49+
assertThat(something)
50+
.isPresent()
51+
.extractingValue()
52+
.isEqualTo("something");
53+
}
54+
55+
@Test
56+
public void givenRange_whenVerifying_thenShouldBeCorrect() throws Exception {
57+
final Range<String> range = Range.openClosed("a", "g");
58+
59+
assertThat(range)
60+
.hasOpenedLowerBound()
61+
.isNotEmpty()
62+
.hasClosedUpperBound()
63+
.contains("b");
64+
}
65+
66+
@Test
67+
public void givenRangeMap_whenVerifying_thenShouldBeCorrect() throws Exception {
68+
final TreeRangeMap<Integer, String> map = TreeRangeMap.create();
69+
70+
map.put(Range.closed(0, 60), "F");
71+
map.put(Range.closed(61, 70), "D");
72+
73+
assertThat(map)
74+
.isNotEmpty()
75+
.containsKeys(0)
76+
.contains(MapEntry.entry(34, "F"));
77+
}
78+
79+
@Test
80+
public void givenTable_whenVerifying_thenShouldBeCorrect() throws Exception {
81+
final HashBasedTable<Integer, String, String> table = HashBasedTable.create(2, 2);
82+
83+
table.put(1, "A", "PRESENT");
84+
table.put(1, "B", "ABSENT");
85+
86+
assertThat(table)
87+
.hasRowCount(1)
88+
.containsValues("ABSENT")
89+
.containsCell(1, "B", "ABSENT");
90+
}
91+
92+
93+
94+
95+
}

‎dependency-injection/build.gradle‎

Lines changed: 0 additions & 43 deletions
This file was deleted.
-47.6 KB
Binary file not shown.
-22.7 KB
Binary file not shown.

‎dependency-injection/docs/autowired-type-demo-classdiagram.xml‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
-37.8 KB
Binary file not shown.
-18.9 KB
Binary file not shown.

‎dependency-injection/docs/inject-field-demo-classdiagram.xml‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)