Summary
Please forgive me If this issue is already fulfilled or not appropriate.
I just faced a situation that I need to assert an actual of String against an expected of int.
String actual = calculate();
int expected = 1;
assertThat(actual).isNotNull().satisfies(v -> {
assertThat(Integer.parseInt(v)).isEqualsTo(expected);
});
assertThat(actual).isNotNull()
.asInstanceOf(new InstanceOfAssertFactory<>(String.class, v -> assertThat(Integer.parseInt(v))))
.isEqualTo(expected);
Example
Do I have an already existing handy idiom or do I have any chance to get following one?
String actual = calculate();
int expected = 1;
assertThat(actual).parsesAsInt().isEqualsTo(expected);
// <N extends Number, A extends NumberAssert<?, N>> A asInstanceOf(Class<N>, Class<A>)
assertThat(actual)
.asInstanceOf(Integer.class, AbstractIntegerAssert.class)
.isEqualTo(expected);
// AbstractIntegerAssert<?> asInstanceOfIntegerAssert()
assertThat(actual)
.asInstanceOfIntegerAssert()
.isEqualTo(expected);
Thanks.
Summary
Please forgive me If this issue is already fulfilled or not appropriate.
I just faced a situation that I need to assert an actual of
Stringagainst an expected ofint.Example
Do I have an already existing handy idiom or do I have any chance to get following one?
Thanks.