isSameAs

Verifies that the actual value is the same as the given one, ie using == comparison.

Example:

// Name is a class with first and last fields, two Names are equals if both first and last are equals.
Name tyrion = new Name("Tyrion", "Lannister");
Name alias = tyrion;
Name clone = new Name("Tyrion", "Lannister");
// assertions succeed:
assertThat(tyrion).isSameAs(alias)
.isEqualTo(clone);
// assertion fails:
assertThat(tyrion).isSameAs(clone);

Parameters:

expected - the given value to compare the actual value to.

Returns:

this assertion object.

Throws:

AssertionError - if the actual value is not the same as the given one.

isNotSameAs

Verifies that the actual value is not the same as the given one, ie using == comparison.

Example:

// Name is a class with first and last fields, two Names are equals if both first and last are equals.
Name tyrion = new Name("Tyrion", "Lannister");
Name alias = tyrion;
Name clone = new Name("Tyrion", "Lannister");
// assertions succeed:
assertThat(clone).isNotSameAs(tyrion)
.isEqualTo(tyrion);
// assertion fails:
assertThat(alias).isNotSameAs(tyrion);

You can also control other types format by overriding StandardRepresentation.toStringOf(Object))
calling your formatting method first and then fall back to the default representation by calling super.toStringOf(Object).