All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.lestard.assertj.javafx.internal.BindingAssertions Maven / Gradle / Ivy

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");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy