// Path: src/main/java/com/google/code/tempusfugit/temporal/Condition.java
// public interface Condition {
//     boolean isSatisfied();
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/concurrency/CallableAdapter.java
// public static Condition condition(final Callable<Boolean> callable ) {
// 	return () -> {
// 		try {
// 			return callable.call();
// 		} catch (Exception e ) {
// 			return false;
// 		}
// 	};
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/concurrency/CallableAdapter.java
//   public static Runnable runnable(final Callable callable) {
//       return () -> {
// 	try {
// 		callable.call();
// 	} catch (Exception e) {
// 		throw new RuntimeException(e);
// 	}
// };
//   }


import static org.jmock.Expectations.returnValue;
import static org.jmock.Expectations.throwException;
import com.google.code.tempusfugit.temporal.Condition;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.api.Action;
import org.jmock.integration.junit4.JMock;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.Callable;
import static com.google.code.tempusfugit.concurrency.CallableAdapter.condition;
import static com.google.code.tempusfugit.concurrency.CallableAdapter.runnable;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
/*
 * Copyright (c) 2009-2018, toby weston & tempus-fugit committers
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 *
 *      http://www.apache.org/licenses/LICENSE-2.0 
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */

package com.google.code.tempusfugit.concurrency;




@RunWith(JMock.class)
public class CallableAdapterTest {

    private final Mockery context = new Mockery();
    private final Callable callable = context.mock(Callable.class);

    private static final Object RESULT = new Object();

    @Test
    public void callableToRunnableDelegates() throws Exception {
        callableWill(returnValue(RESULT));
        runnable(callable).run();
    }

    @Test(expected = RuntimeException.class)
    public void callableToRunnableExceptionPropagates() throws Exception {
        callableWill(throwException(new Exception()));
// Path: src/main/java/com/google/code/tempusfugit/temporal/Condition.java
// public interface Condition {
//     boolean isSatisfied();
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/concurrency/CallableAdapter.java
// public static Condition condition(final Callable<Boolean> callable ) {
// 	return () -> {
// 		try {
// 			return callable.call();
// 		} catch (Exception e ) {
// 			return false;
// 		}
// 	};
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/concurrency/CallableAdapter.java
//   public static Runnable runnable(final Callable callable) {
//       return () -> {
// 	try {
// 		callable.call();
// 	} catch (Exception e) {
// 		throw new RuntimeException(e);
// 	}
// };
//   }


// Path: src/test/java/com/google/code/tempusfugit/concurrency/CallableAdapterTest.java
import static org.jmock.Expectations.returnValue;
import static org.jmock.Expectations.throwException;
import com.google.code.tempusfugit.temporal.Condition;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.api.Action;
import org.jmock.integration.junit4.JMock;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.Callable;
import static com.google.code.tempusfugit.concurrency.CallableAdapter.condition;
import static com.google.code.tempusfugit.concurrency.CallableAdapter.runnable;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

/*
 * Copyright (c) 2009-2018, toby weston & tempus-fugit committers
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 *
 *      http://www.apache.org/licenses/LICENSE-2.0 
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */

package com.google.code.tempusfugit.concurrency;




@RunWith(JMock.class)
public class CallableAdapterTest {

    private final Mockery context = new Mockery();
    private final Callable callable = context.mock(Callable.class);

    private static final Object RESULT = new Object();

    @Test
    public void callableToRunnableDelegates() throws Exception {
        callableWill(returnValue(RESULT));
        runnable(callable).run();
    }

    @Test(expected = RuntimeException.class)
    public void callableToRunnableExceptionPropagates() throws Exception {
        callableWill(throwException(new Exception()));
        runnable(callable).run();