JDBI 中 assertThat 的目的是什么?

what is the purpose of assertThat in JDBI?

我正在查看我在 github 中找到的代码库。 我在包含以下函数的代码中找到一组行:assertThat。感谢任何帮助。

 myObject = someDao.foo(obj);
 assertThat(myObject.getUpdated,isAfter(updated));

这是来自名为 Hamcrest used to ensure certain states in a program. If they fail they throw an Exception with some output to help understanding what goes wrong. Its like assert or the assertEquals methods from JUnit 的库的断言。因此它们通常用于测试 class 但您也可以在正常程序中使用它们以确保您期望的状态(先决条件、后置条件、Class 不变量或按合同设计)。

所以这确保了 Date getUpdated> Date updated 当这是错误的时候抛出异常。