eu.lestard.assertj.javafx.internal.BindingAssertions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-javafx Show documentation
Show all versions of assertj-javafx Show documentation
AssertJ-JavaFX is a package of assertj assertions for JavaFX
The newest version!
package eu.lestard.assertj.javafx.internal;
import javafx.beans.Observable;
import javafx.beans.binding.Binding;
import org.assertj.core.api.AbstractAssert;
import static eu.lestard.assertj.javafx.internal.ErrorMessages.*;
public class BindingAssertions extends AbstractAssert, Binding> {
public BindingAssertions(Binding actual) {
super(actual, BindingAssertions.class);
}
public void dependsOn(Observable value) {
isNotNull();
if (value == null) {
throw new NullPointerException("The given dependency value should not be null");
}
if (!actual.getDependencies().contains(value)) {
failWithMessage("Expected actual binding <%s> to depend on <%s> but it doesn't", actual, value);
}
}
public void hasValue(T expectedValue) {
isNotNull();
if(expectedValue == null){
failWithMessage(EXPECTED_NOT_NULL);
}
if(!expectedValue.equals(actual.getValue())){
failWithMessage("Actual binding should have the value <%s> but was <%s>", expectedValue,actual.getValue());
}
}
public void hasNullValue(){
isNotNull();
if(actual.getValue() != null){
failWithMessage("Expected binding to have a value of null but was <%s>", actual.getValue());
}
}
public void hasNotNullValue(){
isNotNull();
if(actual.getValue() == null){
failWithMessage("Expected binding to not have a value of null");
}
}
}