I have trawled through the net but struggling to find a way to get AssertJ to verify data type, For example, I want to verify that the value from a JSON response is a long data type or not a double:
Something like this:
JsonPath jp = response.jsonPath();
long money= jp.get("amount.money");
Assertions.assertThat(money).isNotDouble; //isNotDouble is not a valid method, but I want to achieve something similar to this. isLong also does not exist.
Is there a way to create like a regex or pattern for money
and use that as the verification point?
Such methods exist yes.
Assertions.assertThat(table).isInstanceOf(Long.class);
Assertions.assertThat(table).isInstanceOfAny(Long.class, Number.class);
Assertions.assertThat(table).isExactlyInstanceOf(Long.class);
Assertions.assertThat(table).isInstanceOfSatisfying(Long.class, num -> {
});
And there are isNot variant.