Skip to content

Commit be5bfec

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 1203bb5 + f78ba65 commit be5bfec

230 files changed

Lines changed: 11079 additions & 748 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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77

88
# Eclipse
99
.settings/
10+
*.project
11+
*.classpath
1012
.prefs
1113
*.prefs
14+
.metadata/
1215

1316
# Intellij
1417
.idea/
@@ -23,3 +26,4 @@ log/
2326
target/
2427

2528
spring-openid/src/main/resources/application.properties
29+
.recommenders/

‎README.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
The "REST with Spring" Classes
33
==============================
4-
After 5 months of work, here's the Master Class: <br/>
4+
After 5 months of work, here's the Master Class of REST With Spring: <br/>
55
**[>> THE REST WITH SPRING MASTER CLASS](http://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=rws#master-class)**
66

77

@@ -19,3 +19,8 @@ Any IDE can be used to work with the projects, but if you're using Eclipse, cons
1919

2020
- import the included **formatter** in Eclipse:
2121
`https://github.com/eugenp/tutorials/tree/master/eclipse`
22+
23+
24+
CI - Jenkins
25+
================================
26+
This tutorials project is being built **[>> HERE](https://rest-security.ci.cloudbees.com/job/tutorials/)**

‎assertj/pom.xml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.baeldung</groupId>
8+
<artifactId>assertj</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>junit</groupId>
14+
<artifactId>junit</artifactId>
15+
<version>4.12</version>
16+
</dependency>
17+
<dependency>
18+
<groupId>org.assertj</groupId>
19+
<artifactId>assertj-core</artifactId>
20+
<version>3.4.1</version>
21+
<scope>test</scope>
22+
</dependency>
23+
</dependencies>
24+
25+
<build>
26+
<plugins>
27+
<plugin>
28+
<groupId>org.apache.maven.plugins</groupId>
29+
<artifactId>maven-compiler-plugin</artifactId>
30+
<version>3.3</version>
31+
<configuration>
32+
<source>1.8</source>
33+
<target>1.8</target>
34+
</configuration>
35+
</plugin>
36+
</plugins>
37+
</build>
38+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.baeldung.assertj.introduction.domain;
2+
3+
public class Dog {
4+
private String name;
5+
private Float weight;
6+
7+
public Dog(String name, Float weight) {
8+
this.name = name;
9+
this.weight = weight;
10+
}
11+
12+
public String getName() {
13+
return name;
14+
}
15+
16+
public Float getWeight() {
17+
return weight;
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.baeldung.assertj.introduction.domain;
2+
3+
public class Person {
4+
private String name;
5+
private Integer age;
6+
7+
public Person(String name, Integer age) {
8+
this.name = name;
9+
this.age = age;
10+
}
11+
12+
public String getName() {
13+
return name;
14+
}
15+
16+
public Integer getAge() {
17+
return age;
18+
}
19+
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
package com.baeldung.assertj.introduction;
2+
3+
import com.baeldung.assertj.introduction.domain.Dog;
4+
import com.baeldung.assertj.introduction.domain.Person;
5+
import org.assertj.core.util.Maps;
6+
import org.junit.Ignore;
7+
import org.junit.Test;
8+
9+
import java.io.ByteArrayInputStream;
10+
import java.io.File;
11+
import java.io.InputStream;
12+
import java.util.Arrays;
13+
import java.util.List;
14+
import java.util.Map;
15+
import java.util.NoSuchElementException;
16+
17+
import static org.assertj.core.api.Assertions.assertThat;
18+
import static org.assertj.core.api.Assertions.entry;
19+
import static org.assertj.core.api.Assertions.withPrecision;
20+
21+
public class AssertJCoreTest {
22+
23+
@Test
24+
public void whenComparingReferences_thenNotEqual() throws Exception {
25+
Dog fido = new Dog("Fido", 5.15f);
26+
Dog fidosClone = new Dog("Fido", 5.15f);
27+
28+
assertThat(fido).isNotEqualTo(fidosClone);
29+
}
30+
31+
@Test
32+
public void whenComparingFields_thenEqual() throws Exception {
33+
Dog fido = new Dog("Fido", 5.15f);
34+
Dog fidosClone = new Dog("Fido", 5.15f);
35+
36+
assertThat(fido).isEqualToComparingFieldByFieldRecursively(fidosClone);
37+
}
38+
39+
@Test
40+
public void whenCheckingForElement_thenContains() throws Exception {
41+
List<String> list = Arrays.asList("1", "2", "3");
42+
43+
assertThat(list)
44+
.contains("1");
45+
}
46+
47+
@Test
48+
public void whenCheckingForElement_thenMultipleAssertions() throws Exception {
49+
List<String> list = Arrays.asList("1", "2", "3");
50+
51+
assertThat(list).isNotEmpty();
52+
assertThat(list).startsWith("1");
53+
assertThat(list).doesNotContainNull();
54+
55+
assertThat(list)
56+
.isNotEmpty()
57+
.contains("1")
58+
.startsWith("1")
59+
.doesNotContainNull()
60+
.containsSequence("2", "3");
61+
}
62+
63+
@Test
64+
public void whenCheckingRunnable_thenIsInterface() throws Exception {
65+
assertThat(Runnable.class).isInterface();
66+
}
67+
68+
@Test
69+
public void whenCheckingCharacter_thenIsUnicode() throws Exception {
70+
char someCharacter = 'c';
71+
72+
assertThat(someCharacter)
73+
.isNotEqualTo('a')
74+
.inUnicode()
75+
.isGreaterThanOrEqualTo('b')
76+
.isLowerCase();
77+
}
78+
79+
@Test
80+
public void whenAssigningNSEExToException_thenIsAssignable() throws Exception {
81+
assertThat(Exception.class).isAssignableFrom(NoSuchElementException.class);
82+
}
83+
84+
@Test
85+
public void whenComparingWithOffset_thenEquals() throws Exception {
86+
assertThat(5.1).isEqualTo(5, withPrecision(1d));
87+
}
88+
89+
@Test
90+
public void whenCheckingString_then() throws Exception {
91+
assertThat("".isEmpty()).isTrue();
92+
}
93+
94+
@Test
95+
public void whenCheckingFile_then() throws Exception {
96+
final File someFile = File.createTempFile("aaa", "bbb");
97+
someFile.deleteOnExit();
98+
99+
assertThat(someFile)
100+
.exists()
101+
.isFile()
102+
.canRead()
103+
.canWrite();
104+
}
105+
106+
@Test
107+
public void whenCheckingIS_then() throws Exception {
108+
InputStream given = new ByteArrayInputStream("foo".getBytes());
109+
InputStream expected = new ByteArrayInputStream("foo".getBytes());
110+
111+
assertThat(given).hasSameContentAs(expected);
112+
}
113+
114+
@Test
115+
public void whenGivenMap_then() throws Exception {
116+
Map<Integer, String> map = Maps.newHashMap(2, "a");
117+
118+
assertThat(map)
119+
.isNotEmpty()
120+
.containsKey(2)
121+
.doesNotContainKeys(10)
122+
.contains(entry(2, "a"));
123+
}
124+
125+
@Test
126+
public void whenGivenException_then() throws Exception {
127+
Exception ex = new Exception("abc");
128+
129+
assertThat(ex)
130+
.hasNoCause()
131+
.hasMessageEndingWith("c");
132+
}
133+
134+
@Ignore // IN ORDER TO TEST, REMOVE THIS LINE
135+
@Test
136+
public void whenRunningAssertion_thenDescribed() throws Exception {
137+
Person person = new Person("Alex", 34);
138+
139+
assertThat(person.getAge())
140+
.as("%s's age should be equal to 100")
141+
.isEqualTo(100);
142+
}
143+
}

‎core-java-8/pom.xml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
<version>3.3.2</version>
4242
</dependency>
4343

44+
<dependency>
45+
<groupId>org.slf4j</groupId>
46+
<artifactId>slf4j-api</artifactId>
47+
<version>${org.slf4j.version}</version>
48+
</dependency>
49+
4450
<!-- test scoped -->
4551

4652
<dependency>
@@ -57,6 +63,12 @@
5763
<scope>test</scope>
5864
</dependency>
5965

66+
<dependency>
67+
<groupId>org.assertj</groupId>
68+
<artifactId>assertj-core</artifactId>
69+
<version>3.4.1</version>
70+
</dependency>
71+
6072
<dependency>
6173
<groupId>org.mockito</groupId>
6274
<artifactId>mockito-core</artifactId>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.baeldung.datetime;
2+
3+
import java.time.Duration;
4+
import java.time.LocalTime;
5+
import java.time.Period;
6+
7+
public class UseDuration {
8+
9+
public LocalTime modifyDates(LocalTime localTime,Duration duration){
10+
return localTime.plus(duration);
11+
}
12+
13+
public Duration getDifferenceBetweenDates(LocalTime localTime1,LocalTime localTime2){
14+
return Duration.between(localTime1, localTime2);
15+
}
16+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.baeldung.datetime;
2+
3+
import java.time.DayOfWeek;
4+
import java.time.LocalDate;
5+
import java.time.LocalDateTime;
6+
import java.time.temporal.ChronoUnit;
7+
import java.time.temporal.TemporalAdjusters;
8+
9+
public class UseLocalDate {
10+
11+
public LocalDate getLocalDateUsingFactoryOfMethod(int year, int month, int dayOfMonth){
12+
return LocalDate.of(year, month, dayOfMonth);
13+
}
14+
15+
public LocalDate getLocalDateUsingParseMethod(String representation){
16+
return LocalDate.parse(representation);
17+
}
18+
19+
public LocalDate getLocalDateFromClock(){
20+
LocalDate localDate = LocalDate.now();
21+
return localDate;
22+
}
23+
24+
public LocalDate getNextDay(LocalDate localDate){
25+
return localDate.plusDays(1);
26+
}
27+
28+
public LocalDate getPreviousDay(LocalDate localDate){
29+
return localDate.minus(1, ChronoUnit.DAYS);
30+
}
31+
32+
public DayOfWeek getDayOfWeek(LocalDate localDate){
33+
DayOfWeek day = localDate.getDayOfWeek();
34+
return day;
35+
}
36+
37+
public LocalDate getFirstDayOfMonth(){
38+
LocalDate firstDayOfMonth = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth());
39+
return firstDayOfMonth;
40+
}
41+
42+
public LocalDateTime getStartOfDay(LocalDate localDate){
43+
LocalDateTime startofDay = localDate.atStartOfDay();
44+
return startofDay;
45+
}
46+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.baeldung.datetime;
2+
3+
import java.time.LocalDateTime;
4+
5+
public class UseLocalDateTime {
6+
7+
public LocalDateTime getLocalDateTimeUsingParseMethod(String representation){
8+
return LocalDateTime.parse(representation);
9+
}
10+
11+
}

0 commit comments

Comments
 (0)