44import io .github .mfvanek .pg .common .maintenance .Diagnostic ;
55import io .github .mfvanek .pg .model .DbObject ;
66import io .github .mfvanek .pg .model .PgContext ;
7- import io .github .mfvanek .pg .model .column . Column ;
7+ import io .github .mfvanek .pg .model .table . TableNameAware ;
88import io .github .mfvanek .spring .boot2 .test .support .TestBase ;
9- import org .assertj .core .api .ListAssert ;
109import org .junit .jupiter .api .DisplayName ;
1110import org .junit .jupiter .api .Test ;
1211import org .springframework .beans .factory .annotation .Autowired ;
1312
1413import java .util .List ;
14+ import java .util .function .Predicate ;
1515
1616import static org .assertj .core .api .Assertions .assertThat ;
17- import static org .assertj .core .api .InstanceOfAssertFactories .list ;
1817
1918class IndexesMaintenanceTest extends TestBase {
2019
@@ -37,18 +36,16 @@ void databaseStructureCheckForPublicSchema() {
3736 checks .stream ()
3837 .filter (DatabaseCheckOnHost ::isStatic )
3938 .forEach (check -> {
40- final List <? extends DbObject > objects = check .check (PgContext .ofPublic (), o -> !o .getName ().equalsIgnoreCase ("databasechangelog" ));
41- final ListAssert <? extends DbObject > checkAssert = assertThat (objects )
42- .as (check .getDiagnostic ().name ());
43-
44- if (check .getDiagnostic () == Diagnostic .COLUMNS_WITHOUT_DESCRIPTION ) {
45- assertThat (objects )
46- .asInstanceOf (list (Column .class ))
47- .hasSize (14 )
48- .allSatisfy (column -> assertThat (column .getTableName ()).isEqualTo ("databasechangelog" ));
49- } else {
50- checkAssert .isEmpty ();
51- }
39+ final Predicate <DbObject > skipLiquibaseTables = dbObject -> {
40+ if (dbObject instanceof TableNameAware t ) {
41+ return !t .getTableName ().equalsIgnoreCase ("databasechangelog" );
42+ }
43+ return true ;
44+ };
45+ final List <? extends DbObject > objects = check .check (PgContext .ofPublic (), skipLiquibaseTables );
46+ assertThat (objects )
47+ .as (check .getDiagnostic ().name ())
48+ .isEmpty ();
5249 });
5350 }
5451}
0 commit comments