complete.countDown();
}
};
gradlePluginLord.addRequestObserver(observer, false); //add the observer before we add the request due to timing issues. It's possible for it to completely execute before we return from addRefreshRequestToQueue.
Request request = gradlePluginLord.addRefreshRequestToQueue();
//make sure we've got a request
Assert.assertNotNull(request);
//now wait until we're complete, but bail if we wait too long
boolean completed;
try {
completed = complete.await(maximumWaitValue, maximumWaitUnits);
} catch (InterruptedException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
gradlePluginLord.removeRequestObserver(observer);
if (!completed) {
//its still running. Something is wrong.
request.cancel(); //just to clean up after ourselves a little, cancel the request.
throw new AssertionError("Failed to complete refresh in alotted time: " + maximumWaitValue + " " + maximumWaitUnits + ". Considering this failed.");
}
if (errorOutput.get() != null) {
throw new AssertionError(String.format("Command failed with output:%n%s", errorOutput.get()));
}