Given the following (quick and missing) code:
class Pair{
int x;
int y;
}
List l1 = Arrays.asList(new Match(1,2), new Match(1,3), new Match(2,3));
List l2 = Arrays.asList(new Match(1,2), new Match(1,3), new Match(2,3));
How can I compare the…
I'm using AssertJ for my tests and I noticed there's a method for checking if a List is sorted:
public static void sorted(final List actual) {
try {
assertThat(actual).isSorted();
} catch (AssertionError e) {
…
I'm trying to set multiply conditions on the assertJ and could not find in it examplesGit.
I currently write:
assertThat(A.getPhone())
.isEqualTo(B.getPhone());
assertThat(A.getServiceBundle().getId())
…
I am running assertions like so:
assertThat(obj.getTotal()).isEqualTo(BigDecimal.valueOf(4))
I am getting
Expecting:
<4.00>
to be equal to:
<4>
so then I tried
assertThat(obj.getTotal()).isEqualTo(BigDecimal.valueOf(4.00))
Expecting:
<4.00>
to…
When I try to test this method
static void validatePostcode(final String postcode, final String addressLine)
{
if(! hasValidPostcode(postcode, addressLine)) {
throw new InvalidFieldException("Postcode is null or empty…
I am looking to compare 2 list of objects (say Foo) in test.
List fooA;
List fooB;
Each Foo entry has one of the fields of type List (say Bar)
class Foo {
private List bars;
....
}
assertThat(fooA).isEqualTo(fooB);
Comparison…
I have a working hamcrest assertion:
assertThat(mylist, contains(
containsString("15"),
containsString("217")));
The intended behavior is:
mylist == asList("Abcd15", "217aB") => success
myList == asList("Abcd15", "218") => failure
How can I…
I'm trying to update my project to recently released Android Test Support library version 1.0.0. But if I add assertj-core dependency Gradle instrumented test tasks start to fail with "No tests found" message. I can successfully run individual tests…
I used FEST-Assert and moved to AssertJ after it stopped development.
Recently I was pointed to Google repository with another assertions library Truth (http://google.github.io/truth/).
Reading the examples I can not find any advantage of start…
I am using AssertJ. I have a class like MyObj. And I have a List of MyObj.
class MyObj {
...
Map myMap;
...
}
When I use:
assertThat(list).extracting("myMap"), I cannot use .containsKey() method.
I also tried using…
I'm working with AssertJ and I need to check that all objects in a list have intField > 0. Something like this:
assertThat(myObjectList).extracting(p -> p.getIntField()).isGreaterThan(0);
What's the correct way to achieve this? Should I use some…
How to achieve the below:
List streams = new ArrayList<>();
assertThat(streams).usingFieldByFieldElementComparatorIgnoringGivenFields("createdOn").containsOnly(data1, data2);
Is there a way when using AssertJ agains a method throwing an excetion to check that the message in the cause is equal to some string.
I'm currently doing something like:
assertThatThrownBy(() -> SUT.method())
…
I have a Message object with MessageHeaders field. The MessageHeaders class implements a Map. I want to assert that I have specific headers set. I'm having trouble getting the MapAssert methods to come up.
Here's what I want to…
So I have a Map of String/String list pairs, and what I want to do is after extraction, combine the returned lists into one list on which i can perform more assertions:
MyTest.java
Map> testMap = new HashMap<>();
List…