Edit II
Basically, the question is if there's an AssertJ (preferred) or JUnit assertion for:
objA == objB
Edit I
My class under test (CUT) extends JAXB's XmlAdapter
. When unmarshalling a XML file, it should guarantee that equal objects exist exactly once. In order to verify this, my test currently looks like this (in the example the standard ctor creates equal objects):
MyType obj = cut.unmarshal(new MyType());
assertThat(cut.unmarshal(new MyType()) == obj).isTrue();
Is there a way to explicitly assert identity with AssertJ or JUnit?
Original Post
My class under test (CUT) has a method (e.g. foo
) which should guarantee that returned objects—that are equal—exist exactly once. Currently, I'm using the following assert statement:
assertThat(cut.foo() == obj).isTrue();
Is there a way to explicitly assert identity with AssertJ or JUnit?