eu.lestard.assertj.javafx.api.NumberBindingAssert 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.api;
import eu.lestard.assertj.javafx.internal.ObservableNumberValueAssertions;
import eu.lestard.assertj.javafx.internal.ObservableValueAssertions;
import javafx.beans.Observable;
import javafx.beans.binding.NumberBinding;
import javafx.beans.value.ObservableNumberValue;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.data.Offset;
/**
* Assertion methods for {@link NumberBinding}s
*
* To create an instance of this class, invoke
* {@link eu.lestard.assertj.javafx.api.Assertions#assertThat(NumberBinding)}
.
*
*/
public class NumberBindingAssert extends AbstractAssert {
protected NumberBindingAssert(NumberBinding actual) {
super(actual, NumberBindingAssert.class);
}
/**
* Verifies that the actual observable has the expected value set.
*
* @param expectedValue the value to compare to the actual observables current value.
* @return {@code this} assertion instance.
*/
public NumberBindingAssert hasValue(Number expectedValue){
new BindingAssert<>(actual).hasValue(expectedValue);
return this;
}
/**
* Verifies that the actual observable number has a value that is close to the given one by less then the given offset.
*
* @param expectedValue the given value to compare the actual observables value to.
* @param offset the given positive offset.
* @return {@code this} assertion object.
*
* @throws java.lang.NullPointerException if the given offset is null
.
* @throws java.lang.AssertionError if the actual observables value is not equal to the expected one.
*/
public NumberBindingAssert hasValue(Number expectedValue, Offset offset){
new ObservableNumberValueAssertions(actual).hasValue(expectedValue, offset);
return this;
}
/**
* Verifies that the actual Binding is bound and depends on the given Observable value.
*
* @param observable the observable that is expected to be a binding dependency of the actual binding.
* @return {@code this} assertion instance
*/
public NumberBindingAssert dependsOn(Observable observable){
new BindingAssert<>(actual).dependsOn(observable);
return this;
}
/**
* Verifies that the actual observable has the same value as the given observable.
*
* @param expectedValue the observable value to compare with the actual observables current value.
*
* @return {@code this} assertion instance.
*/
public NumberBindingAssert hasSameValue(ObservableNumberValue expectedValue) {
new ObservableValueAssertions<>(actual).hasSameValue(expectedValue);
return this;
}
}