Package com.dhemery.polling

Source Code of com.dhemery.polling.ConditionAssert

package com.dhemery.polling;

import org.hamcrest.Description;
import org.hamcrest.StringDescription;

/**
* Asserts that a condition is satisfied.
*/
public class ConditionAssert {
    private ConditionAssert(){}

    /**
     * Assert that the condition is satisfied.
     * @throws AssertionError if the condition is not satisfied
     */
    public static void assertThat(Condition condition) {
        if(condition.isSatisfied()) return;
        Description description = new StringDescription();
        description.appendText("\nExpected: ")
                    .appendDescriptionOf(condition)
                    .appendText("\n     but: ");
        condition.describeDissatisfactionTo(description);
        throw new AssertionError(description.toString());
    }
}
TOP

Related Classes of com.dhemery.polling.ConditionAssert

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.