Skip to content

Commit b7b80ae

Browse files
More examples and improvements
1 parent b4d0826 commit b7b80ae

16 files changed

+238
-45
lines changed

assertions-examples/.classpath

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
<classpath>
33
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
44
<attributes>
5+
<attribute name="test" value="true"/>
56
<attribute name="optional" value="true"/>
67
<attribute name="maven.pomderived" value="true"/>
78
</attributes>
89
</classpathentry>
910
<classpathentry kind="src" path="src/test/generated-assertions"/>
1011
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
1112
<attributes>
13+
<attribute name="test" value="true"/>
1214
<attribute name="maven.pomderived" value="true"/>
1315
</attributes>
1416
</classpathentry>
@@ -23,6 +25,7 @@
2325
<attribute name="maven.pomderived" value="true"/>
2426
</attributes>
2527
</classpathentry>
28+
<classpathentry combineaccessrules="false" kind="src" path="/assertj--core-3.x"/>
2629
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
2730
<attributes>
2831
<attribute name="maven.pomderived" value="true"/>

assertions-examples/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<properties>
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
<neo4j.version>3.0.0</neo4j.version>
24-
<assertj-core.version>3.10.1-SNAPSHOT</assertj-core.version>
24+
<assertj-core.version>3.11.0-SNAPSHOT</assertj-core.version>
2525
</properties>
2626

2727
<dependencies>
@@ -34,7 +34,7 @@
3434
<dependency>
3535
<groupId>org.assertj</groupId>
3636
<artifactId>assertj-joda-time</artifactId>
37-
<version>2.0.0</version>
37+
<version>2.2.0</version>
3838
<scope>test</scope>
3939
</dependency>
4040
<dependency>
@@ -98,7 +98,7 @@
9898
<dependency>
9999
<groupId>org.mockito</groupId>
100100
<artifactId>mockito-core</artifactId>
101-
<version>2.17.0</version>
101+
<version>2.18.3</version>
102102
<scope>test</scope>
103103
</dependency>
104104
<dependency>

assertions-examples/src/test/generated-assertions/org/assertj/Assertions.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,28 @@ public static org.assertj.examples.data.service.TeamManagerAssert assertThat(org
348348
return new org.assertj.examples.data.service.TeamManagerAssert(actual);
349349
}
350350

351+
/**
352+
* Creates a new instance of <code>{@link org.assertj.examples.rpg.ItemAssert}</code>.
353+
*
354+
* @param actual the actual value.
355+
* @return the created assertion object.
356+
*/
357+
@org.assertj.core.util.CheckReturnValue
358+
public static org.assertj.examples.rpg.ItemAssert assertThat(org.assertj.examples.rpg.Item actual) {
359+
return new org.assertj.examples.rpg.ItemAssert(actual);
360+
}
361+
362+
/**
363+
* Creates a new instance of <code>{@link org.assertj.examples.rpg.WandAssert}</code>.
364+
*
365+
* @param actual the actual value.
366+
* @return the created assertion object.
367+
*/
368+
@org.assertj.core.util.CheckReturnValue
369+
public static org.assertj.examples.rpg.WandAssert assertThat(org.assertj.examples.rpg.Wand actual) {
370+
return new org.assertj.examples.rpg.WandAssert(actual);
371+
}
372+
351373
/**
352374
* Creates a new <code>{@link Assertions}</code>.
353375
*/

assertions-examples/src/test/generated-assertions/org/assertj/BddAssertions.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,28 @@ public static org.assertj.examples.data.service.TeamManagerAssert then(org.asser
347347
return new org.assertj.examples.data.service.TeamManagerAssert(actual);
348348
}
349349

350+
/**
351+
* Creates a new instance of <code>{@link org.assertj.examples.rpg.ItemAssert}</code>.
352+
*
353+
* @param actual the actual value.
354+
* @return the created assertion object.
355+
*/
356+
@org.assertj.core.util.CheckReturnValue
357+
public static org.assertj.examples.rpg.ItemAssert then(org.assertj.examples.rpg.Item actual) {
358+
return new org.assertj.examples.rpg.ItemAssert(actual);
359+
}
360+
361+
/**
362+
* Creates a new instance of <code>{@link org.assertj.examples.rpg.WandAssert}</code>.
363+
*
364+
* @param actual the actual value.
365+
* @return the created assertion object.
366+
*/
367+
@org.assertj.core.util.CheckReturnValue
368+
public static org.assertj.examples.rpg.WandAssert then(org.assertj.examples.rpg.Wand actual) {
369+
return new org.assertj.examples.rpg.WandAssert(actual);
370+
}
371+
350372
/**
351373
* Creates a new <code>{@link BddAssertions}</code>.
352374
*/

assertions-examples/src/test/generated-assertions/org/assertj/JUnitSoftAssertions.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,26 @@ public org.assertj.examples.data.service.TeamManagerAssert assertThat(org.assert
362362
return proxy(org.assertj.examples.data.service.TeamManagerAssert.class, org.assertj.examples.data.service.TeamManager.class, actual);
363363
}
364364

365+
/**
366+
* Creates a new "soft" instance of <code>{@link org.assertj.examples.rpg.ItemAssert}</code>.
367+
*
368+
* @param actual the actual value.
369+
* @return the created "soft" assertion object.
370+
*/
371+
@org.assertj.core.util.CheckReturnValue
372+
public org.assertj.examples.rpg.ItemAssert assertThat(org.assertj.examples.rpg.Item actual) {
373+
return proxy(org.assertj.examples.rpg.ItemAssert.class, org.assertj.examples.rpg.Item.class, actual);
374+
}
375+
376+
/**
377+
* Creates a new "soft" instance of <code>{@link org.assertj.examples.rpg.WandAssert}</code>.
378+
*
379+
* @param actual the actual value.
380+
* @return the created "soft" assertion object.
381+
*/
382+
@org.assertj.core.util.CheckReturnValue
383+
public org.assertj.examples.rpg.WandAssert assertThat(org.assertj.examples.rpg.Wand actual) {
384+
return proxy(org.assertj.examples.rpg.WandAssert.class, org.assertj.examples.rpg.Wand.class, actual);
385+
}
386+
365387
}

assertions-examples/src/test/generated-assertions/org/assertj/SoftAssertions.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,26 @@ public org.assertj.examples.data.service.TeamManagerAssert assertThat(org.assert
347347
return proxy(org.assertj.examples.data.service.TeamManagerAssert.class, org.assertj.examples.data.service.TeamManager.class, actual);
348348
}
349349

350+
/**
351+
* Creates a new "soft" instance of <code>{@link org.assertj.examples.rpg.ItemAssert}</code>.
352+
*
353+
* @param actual the actual value.
354+
* @return the created "soft" assertion object.
355+
*/
356+
@org.assertj.core.util.CheckReturnValue
357+
public org.assertj.examples.rpg.ItemAssert assertThat(org.assertj.examples.rpg.Item actual) {
358+
return proxy(org.assertj.examples.rpg.ItemAssert.class, org.assertj.examples.rpg.Item.class, actual);
359+
}
360+
361+
/**
362+
* Creates a new "soft" instance of <code>{@link org.assertj.examples.rpg.WandAssert}</code>.
363+
*
364+
* @param actual the actual value.
365+
* @return the created "soft" assertion object.
366+
*/
367+
@org.assertj.core.util.CheckReturnValue
368+
public org.assertj.examples.rpg.WandAssert assertThat(org.assertj.examples.rpg.Wand actual) {
369+
return proxy(org.assertj.examples.rpg.WandAssert.class, org.assertj.examples.rpg.Wand.class, actual);
370+
}
371+
350372
}

assertions-examples/src/test/java/org/assertj/examples/BDDAssertionsExamples.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22-
import org.junit.Test;
23-
import org.junit.runner.RunWith;
24-
import org.mockito.InjectMocks;
25-
import org.mockito.Mock;
26-
import org.mockito.runners.MockitoJUnitRunner;
27-
2822
import org.assertj.examples.data.BasketBallPlayer;
2923
import org.assertj.examples.data.Mansion;
3024
import org.assertj.examples.data.service.GameService;
3125
import org.assertj.examples.data.service.TeamManager;
26+
import org.junit.Test;
27+
import org.junit.runner.RunWith;
28+
import org.mockito.InjectMocks;
29+
import org.mockito.Mock;
30+
import org.mockito.junit.MockitoJUnitRunner;
3231

3332
/**
3433
* BDD Style Assertions examples
@@ -51,7 +50,7 @@ public void given_when_then_with_mockito() {
5150

5251
given(teamManager.getPlayers()).willReturn(asList(rose, james, durant));
5352

54-
//when
53+
// when
5554
boolean result = sut.play();
5655

5756
then(result).isTrue();
@@ -60,10 +59,10 @@ public void given_when_then_with_mockito() {
6059
@Test
6160
public void bdd_host_dinner_party_where_nobody_dies() {
6261

63-
//given
62+
// given
6463
Mansion mansion = new Mansion();
6564

66-
//when
65+
// when
6766
mansion.hostPotentiallyMurderousDinnerParty();
6867

6968
then(mansion.guests()).isEqualTo(6);
@@ -75,13 +74,12 @@ public void bdd_host_dinner_party_where_nobody_dies() {
7574
then(mansion.professor()).isEqualTo("bloodied and disheveled");
7675
}
7776

78-
7977
@Test
8078
public void bdd_assertions_examples() {
81-
//given
82-
List<BasketBallPlayer> bulls = new ArrayList<BasketBallPlayer>();
79+
// given
80+
List<BasketBallPlayer> bulls = new ArrayList<>();
8381

84-
//when
82+
// when
8583
bulls.add(rose);
8684
bulls.add(noah);
8785

@@ -90,14 +88,14 @@ public void bdd_assertions_examples() {
9088

9189
@Test
9290
public void bdd_soft_assertions_examples() {
93-
//given
94-
List<BasketBallPlayer> bulls = new ArrayList<BasketBallPlayer>();
95-
96-
//when
97-
bulls.add(rose);
98-
bulls.add(noah);
99-
100-
then(bulls).contains(rose, noah).doesNotContain(james);
91+
// given
92+
List<BasketBallPlayer> bulls = new ArrayList<>();
93+
94+
// when
95+
bulls.add(rose);
96+
bulls.add(noah);
97+
98+
then(bulls).contains(rose, noah).doesNotContain(james);
10199
}
102-
100+
103101
}

assertions-examples/src/test/java/org/assertj/examples/GeneratedSoftAssertionsExamples.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
*/
1313
package org.assertj.examples;
1414

15-
import org.junit.Test;
16-
15+
import org.assertj.SoftAssertions;
1716
import org.assertj.core.api.SoftAssertionError;
1817
import org.assertj.examples.data.Name;
19-
import org.assertj.SoftAssertions;
2018
import org.assertj.examples.exception.NameException;
19+
import org.junit.Test;
2120

2221
public class GeneratedSoftAssertionsExamples extends AbstractAssertionsExamples {
2322

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
3+
* the License. You may obtain a copy of the License at
4+
*
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
* specific language governing permissions and limitations under the License.
10+
*
11+
* Copyright 2012-2016 the original author or authors.
12+
*/
13+
package org.assertj.examples;
14+
15+
import static org.assertj.core.api.Assertions.assertThat;
16+
17+
import java.io.ByteArrayInputStream;
18+
import java.io.InputStream;
19+
20+
import org.junit.Test;
21+
22+
public class InputStreamAssertionsExamples extends AbstractAssertionsExamples {
23+
24+
@Test
25+
public void input_stream_content_can_be_compared_to_string() {
26+
// GIVEN
27+
String text = "Real stupidity beats artificial intelligence every time";
28+
InputStream inputStream = new ByteArrayInputStream(text.getBytes());
29+
// THEN
30+
assertThat(inputStream).hasContent(text);
31+
}
32+
33+
}

0 commit comments

Comments
 (0)