|
1 | 1 | package org.baeldung.hamcrest; |
2 | 2 |
|
| 3 | +import org.junit.Test; |
| 4 | + |
| 5 | +import java.util.*; |
| 6 | + |
3 | 7 | import static org.baeldung.hamcrest.IsPositiveInteger.isAPositiveInteger; |
4 | 8 | import static org.hamcrest.MatcherAssert.assertThat; |
5 | | -import static org.hamcrest.Matchers.equalTo; |
6 | | -import static org.hamcrest.Matchers.greaterThan; |
7 | | -import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
8 | | -import static org.hamcrest.Matchers.lessThan; |
9 | | -import static org.hamcrest.Matchers.lessThanOrEqualTo; |
10 | | -import static org.hamcrest.Matchers.closeTo; |
| 9 | +import static org.hamcrest.Matchers.*; |
11 | 10 | import static org.hamcrest.beans.HasProperty.hasProperty; |
12 | 11 | import static org.hamcrest.beans.HasPropertyWithValue.hasProperty; |
13 | 12 | import static org.hamcrest.beans.SamePropertyValuesAs.samePropertyValuesAs; |
|
19 | 18 | import static org.hamcrest.collection.IsEmptyCollection.empty; |
20 | 19 | import static org.hamcrest.collection.IsIn.isIn; |
21 | 20 | import static org.hamcrest.collection.IsIn.isOneOf; |
22 | | -import static org.hamcrest.collection.IsMapContaining.hasKey; |
23 | | -import static org.hamcrest.collection.IsMapContaining.hasEntry; |
24 | | -import static org.hamcrest.collection.IsMapContaining.hasValue; |
25 | 21 | import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; |
26 | 22 | import static org.hamcrest.collection.IsIterableContainingInOrder.contains; |
27 | | -import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase; |
28 | | -import static org.hamcrest.text.IsEmptyString.isEmptyOrNullString; |
29 | | -import static org.hamcrest.text.IsEmptyString.isEmptyString; |
30 | | -import static org.hamcrest.text.IsEqualIgnoringWhiteSpace.equalToIgnoringWhiteSpace; |
31 | | -import static org.hamcrest.text.StringContainsInOrder.stringContainsInOrder; |
32 | | -import static org.hamcrest.object.HasToString.hasToString; |
33 | | -import static org.hamcrest.object.IsCompatibleType.typeCompatibleWith; |
| 23 | +import static org.hamcrest.collection.IsMapContaining.hasEntry; |
| 24 | +import static org.hamcrest.collection.IsMapContaining.hasKey; |
| 25 | +import static org.hamcrest.collection.IsMapContaining.hasValue; |
34 | 26 | import static org.hamcrest.core.AllOf.allOf; |
35 | 27 | import static org.hamcrest.core.AnyOf.anyOf; |
36 | 28 | import static org.hamcrest.core.Every.everyItem; |
37 | | -import static org.hamcrest.core.Is.is;//class |
| 29 | +import static org.hamcrest.core.Is.is; |
38 | 30 | import static org.hamcrest.core.IsInstanceOf.instanceOf; |
39 | | -import static org.hamcrest.core.IsNot.not;//matcher |
40 | | -import static org.hamcrest.core.IsNull.notNullValue;//without arg |
| 31 | +import static org.hamcrest.core.IsNot.not; |
| 32 | +import static org.hamcrest.core.IsNull.notNullValue; |
41 | 33 | import static org.hamcrest.core.IsSame.sameInstance; |
42 | 34 | import static org.hamcrest.core.StringContains.containsString; |
43 | 35 | import static org.hamcrest.core.StringEndsWith.endsWith; |
44 | 36 | import static org.hamcrest.core.StringStartsWith.startsWith; |
45 | | - |
46 | | -import java.util.ArrayList; |
47 | | -import java.util.Arrays; |
48 | | -import java.util.HashMap; |
49 | | -import java.util.List; |
50 | | -import java.util.Map; |
51 | | - |
52 | | -import org.junit.Test; |
| 37 | +import static org.hamcrest.object.HasToString.hasToString; |
| 38 | +import static org.hamcrest.object.IsCompatibleType.typeCompatibleWith; |
| 39 | +import static org.hamcrest.text.IsEmptyString.isEmptyOrNullString; |
| 40 | +import static org.hamcrest.text.IsEmptyString.isEmptyString; |
| 41 | +import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase; |
| 42 | +import static org.hamcrest.text.IsEqualIgnoringWhiteSpace.equalToIgnoringWhiteSpace; |
| 43 | +import static org.hamcrest.text.StringContainsInOrder.stringContainsInOrder; |
53 | 44 |
|
54 | 45 | public class HamcrestMatcherTest { |
55 | 46 | @Test |
@@ -150,7 +141,7 @@ public void givenCollection_whenEmpty_thenCorrect() { |
150 | 141 | public void givenValueAndArray_whenValueFoundInArray_thenCorrect() { |
151 | 142 | String[] array = new String[] { "collections", "beans", "text", |
152 | 143 | "number" }; |
153 | | - assertThat("bean", isIn(array)); |
| 144 | + assertThat("beans", isIn(array)); |
154 | 145 |
|
155 | 146 | } |
156 | 147 |
|
@@ -299,7 +290,7 @@ public void givenString_whenMeetsAnyOfGivenConditions_thenCorrect() { |
299 | 290 | public void givenString_whenMeetsAllOfGivenConditions_thenCorrect() { |
300 | 291 | String str = "calligraphy"; |
301 | 292 | String start = "call"; |
302 | | - String end = "foo"; |
| 293 | + String end = "phy"; |
303 | 294 | assertThat(str, allOf(startsWith(start), endsWith(end))); |
304 | 295 | } |
305 | 296 |
|
|
0 commit comments