Questions tagged [assertj]

AssertJ provides a set of strongly-typed assertions to use for unit testing (either with JUnit or TestNG).

386 questions
0
votes
2 answers

How to assert 'Exception B' when "Exception A: Exception B" is thrown?

I want to assert that a certain exception (SSLHandshakeException) is thrown when running some code. assertThatThrownBy(() -> { // some code }).isInstanceOf(SSLHandshakeException.class); However, this fails because the failure trace…
Patze
  • 859
  • 10
  • 19
0
votes
0 answers

why isEqualToComparingFieldByFieldRecursively() method of AssertJ is failing on same value objects?

I am comparing the data after uploading the excel sheet via an API response. while comparing it is giving this error: assertThat(holdings.get(2)).isEqualToComparingFieldByFieldRecursively(listOfDataFromExcel.get(2)); -actual :…
Vaibhav_Sharma
  • 546
  • 1
  • 9
  • 22
0
votes
1 answer

AssertJ - Is there a more fluent way to extract/map values?

I have following test code ObjectNode jsonObject = .. assertThat(jsonObject.get("level")).isNotNull(); assertThat(jsonObject.get("level").get("object")).isNotNull(); assertThat(jsonObject.get("level").get("object").textValue()).isEqualTo("my…
isADon
  • 3,433
  • 11
  • 35
  • 49
0
votes
0 answers

Gson adds "root", "entrySet", "values" fields after deserialization

I have the following JSON String: [ { "id": 23425, "mailboxGroupId": 6659, "statusCode": "ACTIVE" }, { "id": 23425, "groupId": 6659, "statusCode": "INACTIVE" } ] I want to deserialize it into a list of two objects of…
Vitali Plagov
  • 722
  • 1
  • 12
  • 31
0
votes
1 answer

AssertJ List of String Must Exist In Expected, Ignoring Duplicates

I have a expected List of Strings: List expected = Arrays.asList("a", "b"); I want these assertions be evaluated with these results: {"a", "a", "b", "b"} -> true {"a", "b", "c"} -> false Essentially, I want assertJ to ignore/remove any…
George
  • 2,820
  • 4
  • 29
  • 56
0
votes
1 answer

AssertJ and Groovy not playing nicely together

I'm encountering a weird issue / bug with assert j and groovy with step verifier testing mongo db. I've included some code to help you reproduce this locally and also I have made the test work by replacing the closure with just a string. I have the…
johnwick0831
  • 918
  • 1
  • 12
  • 24
0
votes
1 answer

Can't integrate AssertJ into TestNG (Java 1.8, Maven)

Added dependency into pom.xml After adding static import (tried also many with all list) and assertion (AssertThat) - it doesn't work. import static org.assertj.core.api.Assertions.*; It's not finding any JAR for AssertJ. After pressing 2…
0
votes
1 answer

Assert list items without order

Seems very stupid, but I can't find good solution to this (I guess very basic) problem: I have an list with elements that can not be checked by equals. Instead, I want to assert items state by their properties, and I want to do it ignoring item…
Askar Kalykov
  • 2,553
  • 1
  • 22
  • 43
0
votes
1 answer

A required class was missing while executing org.assertj:assertj-assertions-generator-maven-plugin:2.1.0:generate-assertions: org.junit.rules.TestRule

I am facing this issue when migrating my application from JDK8 to JDK11. [ERROR] Failed to execute goal org.assertj:assertj-assertions-generator-maven-plugin:2.1.0:generate-assertions (default) on project mws-inbound: Execution default of goal…
akuma8
  • 4,160
  • 5
  • 46
  • 82
0
votes
1 answer

Assertj+ How to create custom assertion for iterables

I need to create custom assertion for list items. For example, I have ArrayList in which there is an Address Object, now I need to create a custom assertion to check anySatisfy Assertions.assertThat(results.result).anySatisfy(p->{ …
Rejish R
  • 43
  • 1
  • 4
0
votes
1 answer

assertj + how to identify which property is failing when using tuple

I am using assertj's tuple to combine two or three property together and check the combination. Now I am having the issue of identifying out of which property it is failing. Currently am using the as…
Rejish R
  • 43
  • 1
  • 4
0
votes
1 answer

Assertj + While using tuple, for one field how to check it check it matches from more than one value

I have a list of object responses and want to test that each block of object matches.Hence using tuple. softAssertions.assertThat(resultArrayList) .extracting("title", "countryCode") …
Rejish R
  • 43
  • 1
  • 4
0
votes
1 answer

FlatExtracting Map with AssertJ 3

I'm using AssertJ 3.11.1 and trying to get rid of Hamcrest completely. I managed so far but I'm having trouble with the following code: class Foo { private final Map innerMap; Foo(Map innerMap) { …
Poly
  • 195
  • 2
  • 8
0
votes
1 answer

AssertJ + Verify items in subset of list from the extracted list

So, have an use case where in I extract title from the object, as list say 10 items, now need to verify the title is present in anyof the first 5 items. Using below method to extract the items.But not sure how to reduce the list and verify…
Rejish R
  • 43
  • 1
  • 4
0
votes
1 answer

Force AssertJ to treat classes as objects rather than Iterables

I'm trying to use isEqualToComparingFieldByFieldRecursively from AssertJ to compare HSSFWorkbooks from Apache POI However when I try to use it with a HSSFWorkbook it does not work: HSSFWorkbook wb1 = new HSSFWorkbook(); HSSFWorkbook wb2 =…
ciferkey
  • 2,064
  • 3
  • 20
  • 28