Example usage for java.util.function Predicate toString

List of usage examples for java.util.function Predicate toString

Introduction

In this page you can find the example usage for java.util.function Predicate toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:ddf.common.test.ServiceManager.java

public void waitForFeature(String featureName, Predicate<FeatureState> predicate) throws Exception {
    boolean ready = false;

    long timeoutLimit = System.currentTimeMillis() + REQUIRED_BUNDLES_TIMEOUT;
    FeaturesService featuresService = getFeaturesService();
    while (!ready) {
        if (featuresService != null) {
            Feature feature = featuresService.getFeature(featureName);
            FeatureState state = featuresService.getState(feature.getName() + "/" + feature.getVersion());
            if (state == null) {
                LOGGER.warn("No Feature found for featureName: {}", featureName);
                return;
            } else if (predicate.test(state)) {
                ready = true;/*from w ww .  j a  v a  2 s  . co m*/
            }
        }

        if (!ready) {
            if (System.currentTimeMillis() > timeoutLimit) {
                printInactiveBundles();
                fail(String.format(
                        "Feature did not change to State [" + predicate.toString() + "] within %d minutes.",
                        TimeUnit.MILLISECONDS.toMinutes(REQUIRED_BUNDLES_TIMEOUT)));
            }
            LOGGER.info("Feature [{}] not [{}], sleeping...", featureName, predicate.toString());
            Thread.sleep(1000);
        }
    }
}