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
0 answers

Where is `MapAssert.containsExactlyInAnyOrder`?

I want to write something like assertThat(myMap).containsExactlyInAnyOrder( entry("a", "b"), entry("c", "d"), ... ) but I can't find the right method. containsExactly requires that the order of the map iteration be the same as the entries,…
Todd O'Bryan
  • 2,234
  • 17
  • 30
0
votes
0 answers

Swing testing with AssertJ not working in IntelliJ IDEA

I want to test a Swing app written with Intellij IDEA. I have been able to setup the initial example, but when trying to execute the example text, I get this message: Unable to find component using matcher…
Jose
  • 11
  • 1
0
votes
0 answers

Looking for a custom swing JComponent object inside a standard Swing app using AssertJ FrameFixture

AssertJ has options for finding JPanel, JFrame, and suite of other standard Swing components, but I am wanting to test a custom Prefuse Display window derived directly from the JComponent class. What method on the main FrameFixture object should I…
0
votes
1 answer

Using Assertj how to verify two hashmap list List> with multiple keys

I have two hashmap list and want to check the value present against the given key is same. List> listMap1 = new ArrayList<>(); Map map1 = new HashMap<>(); map1.put("Car", "Toyota"); map1.put("Bike",…
DeepakVerma
  • 179
  • 1
  • 3
  • 14
0
votes
1 answer

Can AssertJ isEqualToComparingFieldByFieldRecursively ignore a field?

I need to compare a JPA Entity with expected value ignoring IDs. AssertJ has this method assertThat(actualEntity).isEqualToIgnoringGivenFields(expectedEntity, "id"); which compares two objects ignoring ID, but my actualEntity has a list of inner…
Michal Krasny
  • 5,434
  • 7
  • 36
  • 64
0
votes
0 answers

determineDifferences method of RecursiveComparisonDifferenceCalculator not able to compare the list of 100 objects

I hope you would suggest me something as I am quite new to Java world and trying to work with assertj-core recursive comparison APIs for deep comparison between the objects as follows. But it appears that it doesn't work when we pass collections of…
Amit
  • 13
  • 4
0
votes
0 answers

Can AssertJ's contains method work with spring's PagedModel - getContent()?

The getContent() method in Spring's PagedModel is able to get all the content from an API response absolutely fine and it is possible to write an assertion that compares the content fetched by getContent() isEqualTo expected response. This assertion…
matt
  • 25
  • 5
0
votes
1 answer

Bytebuddy get value of proteced field

Im struggling to figure out how to access a protected field using ByteBuddy and what approach to take. Background: Id like to intercept a class from a dependency I have on my class path. Im creating a junit test report and need to intercept…
rogger2016
  • 821
  • 3
  • 11
  • 28
0
votes
1 answer

List diffs in the context of usingRecursiveComparison()

This is an AssertJ specific question. Consider the tests below where two lists are compared first directly and then nested in some other object through usingRecursiveComparison(). public class RecursiveComparisonWithNestedListsTest { @Test …
Bogdan Calmac
  • 7,993
  • 6
  • 51
  • 64
0
votes
0 answers

roots are empty in BasicRobot.robot.hierarchy Swing-assertj

I’m trying to test swing dialog in desktop application, bit robot couldn’t get any dialog and also the roots is empty I need to get access to this dialog , it appears in access bridge explore
0
votes
0 answers

AssertJ assertThat Consumer

Im currently building a custom maven test report plugin that captures unit and integration tests results. While trying to capture as much test information as possible, I am able to capture AssertJ descriptions using something like this > //…
rogger2016
  • 821
  • 3
  • 11
  • 28
0
votes
1 answer

Testing object method return values

I have an object under test and want to verify it was configured correctly by testing the return values of methods. Is there a way to do this without creating one test per method? I'm imagining something like: assertThat(obj).fieldIs(Obj::methodA,…
gph
  • 1,045
  • 8
  • 25
0
votes
3 answers

How can i access an element from a list in AssertJ?

assertThat(service.load(1, setup.getEntity(), "OBJECT1").getImages().get(0).isSwitchedOn()).isEqualTo(false); I'm accesing the unique element of the list in this way,but i'm wondering if there's a more appropriate way to do it.
0
votes
0 answers

Converting JUnit throw exceptions to AssertJ?

I am trying to manually convert my JUnit tests into AssertJ, but I'm running into some blockers. None of the scripts or plugins I've found online are working for me. I have a number of JUnit assertThrows tests runTest { assertThrows
bensalerno
  • 467
  • 1
  • 6
  • 22
0
votes
1 answer

Alternatives to deprecated java method from org.assertj.core.api

I'm looking for an alternative of the deprecated method containsOnlyElementsOf. It has to check whether the given iterable (a list of Integers in my case) contains only Integers in-between given bounds. I've tried looking at the docs but didn't find…
IDK
  • 359
  • 1
  • 16