MigrationClientTest.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:henicea 作者:
@Test
public void getAppliedMigrations_shouldIgnoreFailedAndIncompleteMigrations() throws Exception {
    ResultSet appliedMigrationResultSet = mock(ResultSet.class);
    Row row1 = mock(Row.class);
    Row row2 = mock(Row.class);

    when(session.execute(argThat(new CustomMatcher<Insert>("Get applied migrations") {
        @Override
        public boolean matches(Object item) {
            return "SELECT name,status FROM test.migrations;".equals(item.toString());
        }
    }))).thenReturn(appliedMigrationResultSet);
    when(appliedMigrationResultSet.all()).thenReturn(Arrays.asList(row1, row2));

    when(row1.getString(0)).thenReturn("001_initial_migration.cql");
    when(row1.getString(1)).thenReturn("APPLIED");
    when(row2.getString(0)).thenReturn("002_add_stuff.cql");
    when(row2.getString(1)).thenReturn("FAILED");

    assertThat(client.getAppliedMigrations()).containsOnly("001_initial_migration.cql");
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号