io.github.bekoenig.assertj.schemacrawler.api.AbstractTableAssert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-schemacrawler Show documentation
Show all versions of assertj-schemacrawler Show documentation
An assertj extension for schema-crawler.
package io.github.bekoenig.assertj.schemacrawler.api;
import schemacrawler.schema.*;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;
public abstract class AbstractTableAssert<
SELF extends AbstractTableAssert,
ACTUAL extends Table>
extends AbstractDatabaseObjectAssert {
protected AbstractTableAssert(ACTUAL actual, Class> selfType) {
super(actual, selfType);
}
public ListableNamedObjectAssert, List, PrimaryKey, PrimaryKeyAssert> alternateKeys() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getAlternateKeys(),
SchemaCrawlerAssertions::assertThat);
}
public ListableNamedObjectAssert, List, Column, ColumnAssert> columns() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getColumns(),
SchemaCrawlerAssertions::assertThat);
}
public SELF matchesDefinition(Predicate predicate) {
extracting(DefinedObject::getDefinition).matches(predicate);
return myself;
}
public ListableNamedObjectAssert, List, ForeignKey, ForeignKeyAssert> exportedForeignKeys() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getExportedForeignKeys(),
SchemaCrawlerAssertions::assertThat);
}
public ListableNamedObjectAssert, List, ForeignKey, ForeignKeyAssert> foreignKeys() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getForeignKeys(),
SchemaCrawlerAssertions::assertThat);
}
public ListableNamedObjectAssert, List, Column, ColumnAssert> hiddenColumns() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getHiddenColumns(),
SchemaCrawlerAssertions::assertThat);
}
public ListableNamedObjectAssert, List, ForeignKey, ForeignKeyAssert> importedForeignKeys() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getImportedForeignKeys(),
SchemaCrawlerAssertions::assertThat);
}
public ListableNamedObjectAssert, List, Index, IndexAssert> indexes() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getIndexes(),
SchemaCrawlerAssertions::assertThat);
}
public SELF satisfiesPrimaryKey(Consumer requirement) {
extracting(Table::getPrimaryKey)
.satisfies(requirement);
return myself;
}
public ListableNamedObjectAssert, List>, Privilege, PrivilegeAssert> privileges() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getPrivileges(),
SchemaCrawlerAssertions::assertThat);
}
public ListableNamedObjectAssert, List, Table, TableAssert> relatedTables(
TableRelationshipType tableRelationshipType) {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getRelatedTables(tableRelationshipType),
SchemaCrawlerAssertions::assertThat);
}
public ListableNamedObjectAssert, List, TableConstraint, TableConstraintAssert> tableConstraints() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getTableConstraints(),
SchemaCrawlerAssertions::assertThat);
}
public SELF satisfiesTableType(Consumer requirement) {
extracting(Table::getTableType).satisfies(requirement);
return myself;
}
public ListableNamedObjectAssert, List, Trigger, TriggerAssert> triggers() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getTriggers(),
SchemaCrawlerAssertions::assertThat);
}
public SELF satisfiesType(Consumer requirement) {
extracting(Table::getType).satisfies(requirement);
return myself;
}
public ListableNamedObjectAssert, List, TableReference, TableReferenceAssert> weakAssociation() {
isNotNull();
return new ListableNamedObjectAssert<>(
actual.getWeakAssociations(),
SchemaCrawlerAssertions::assertThat);
}
public SELF hasDefinition(boolean expected) {
return returns(expected, DefinedObject::hasDefinition);
}
public SELF hasForeignKeys(boolean expected) {
return returns(expected, Table::hasForeignKeys);
}
public SELF hasPrimaryKey(boolean expected) {
return returns(expected, Table::hasPrimaryKey);
}
public PrimaryKeyAssert alternateKey(String name) {
return extracting(x -> x.lookupAlternateKey(name).orElse(null))
.asInstanceOf(SchemaCrawlerInstanceOfAssertFactories.primaryKey());
}
public ColumnAssert column(String name) {
return extracting(x -> x.lookupColumn(name).orElse(null))
.asInstanceOf(SchemaCrawlerInstanceOfAssertFactories.column());
}
public ForeignKeyAssert foreignKey(String name) {
return extracting(x -> x.lookupForeignKey(name).orElse(null))
.asInstanceOf(SchemaCrawlerInstanceOfAssertFactories.foreignKey());
}
public IndexAssert index(String name) {
return extracting(x -> x.lookupIndex(name).orElse(null))
.asInstanceOf(SchemaCrawlerInstanceOfAssertFactories.index());
}
@SuppressWarnings("unchecked")
public PrivilegeAssert privilege(String name) {
return (PrivilegeAssert) extracting(x -> x.lookupPrivilege(name).orElse(null))
.asInstanceOf(SchemaCrawlerInstanceOfAssertFactories.privilege());
}
public TableConstraintAssert tableConstraint(String name) {
return extracting(x -> x.lookupTableConstraint(name).orElse(null))
.asInstanceOf(SchemaCrawlerInstanceOfAssertFactories.tableConstraint());
}
public TriggerAssert trigger(String name) {
return extracting(x -> x.lookupTrigger(name).orElse(null))
.asInstanceOf(SchemaCrawlerInstanceOfAssertFactories.trigger());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy