io.github.bekoenig.assertj.schemacrawler.api.AbstractNamedObjectWithAttributesAssert 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 org.assertj.core.api.InstanceOfAssertFactories;
import org.assertj.core.api.OptionalAssert;
import schemacrawler.schema.AttributedObject;
import schemacrawler.schema.DescribedObject;
import schemacrawler.schema.NamedObject;
import java.util.function.Predicate;
public abstract class AbstractNamedObjectWithAttributesAssert<
SELF extends AbstractNamedObjectWithAttributesAssert,
ACTUAL extends NamedObject & AttributedObject & DescribedObject>
extends AbstractNamedObjectAssert {
protected AbstractNamedObjectWithAttributesAssert(ACTUAL actual, Class> selfType) {
super(actual, selfType);
}
public SELF matchesAttribute(String name, Class type, Predicate predicate) {
extracting(x -> x.getAttribute(name))
.asInstanceOf(InstanceOfAssertFactories.type(type))
.matches(predicate);
return myself;
}
public SELF matchesRemarks(Predicate predicate) {
extracting(DescribedObject::getRemarks).matches(predicate);
return myself;
}
public SELF hasAttribute(String name) {
return returns(true, x -> x.getAttribute(name));
}
public SELF hasNoAttribute(String name) {
return returns(false, x -> x.getAttribute(name));
}
public OptionalAssert attribute(String name, Class resultType) {
return extracting(x -> x.lookupAttribute(name))
.asInstanceOf(InstanceOfAssertFactories.optional(resultType));
}
}