// Path: src/main/java/org/springframework/social/evernote/api/EvernoteException.java
// public class EvernoteException extends RuntimeException {
// 
// 	public EvernoteException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public boolean isEDAMUserException() {
// 		return getCause() instanceof EDAMUserException;
// 	}
// 
// 	public boolean isEDAMSystemException() {
// 		return getCause() instanceof EDAMSystemException;
// 	}
// 
// 	public boolean isEDAMNotFoundException() {
// 		return getCause() instanceof EDAMNotFoundException;
// 	}
// 
// 	public boolean isTException() {
// 		return getCause() instanceof TException;
// 	}
// 
// 	/**
// 	 * True if exception is one of {@link EDAMUserException}, {@link EDAMSystemException}, or {@link EDAMNotFoundException}
// 	 *
// 	 * @return true when thrown exception is one of EDAM*Exception.
// 	 */
// 	public boolean isEDAMException() {
// 		return isEDAMUserException() || isEDAMSystemException() || isEDAMNotFoundException();
// 	}
// 
// 	public EDAMErrorCode getEDAMErrorCode() {
// 		if (isEDAMUserException()) {
// 			return ((EDAMUserException) getCause()).getErrorCode();
// 		} else if (isEDAMSystemException()) {
// 			return ((EDAMSystemException) getCause()).getErrorCode();
// 		}
// 		return null;
// 	}
// }


import com.evernote.edam.error.EDAMNotFoundException;
import com.evernote.edam.error.EDAMSystemException;
import com.evernote.edam.error.EDAMUserException;
import com.evernote.thrift.TException;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.springframework.social.evernote.api.EvernoteException;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.runners.Parameterized.Parameters;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package org.springframework.social.evernote.api.impl;




/**
 * @author Tadaya Tsuyukubo
 */
@RunWith(Parameterized.class)
public class ClientStoreMethodInterceptorWithExceptionTest {

	private Exception original;
	private Exception expected;

	@Parameters
	public static Collection<Object[]> data() {
		EDAMUserException edamUserException = new EDAMUserException();
		EDAMSystemException edamSystemException = new EDAMSystemException();
		EDAMNotFoundException edamNotFoundException = new EDAMNotFoundException();
		RuntimeException runtimeException = new RuntimeException();

		return Arrays.asList(new Object[][]{
				// original, expected
				{edamUserException, edamUserException},
				{edamSystemException, edamSystemException},
				{edamNotFoundException, edamNotFoundException},
				{runtimeException, runtimeException}
		});
	}

	public ClientStoreMethodInterceptorWithExceptionTest(Exception original, Exception expected) {
		this.original = original;
		this.expected = expected;
	}

	@Test
	public void testInvokeWithException() throws Throwable {

		// underlying class
		FooImpl fooImpl = mock(FooImpl.class);
		when(fooImpl.echo()).thenThrow(original);

		// invoked interface method
		Method getUserMethod = ReflectionUtils.findMethod(Foo.class, "echo");
		MethodInvocation invocation = mock(MethodInvocation.class);
		when(invocation.getThis()).thenReturn(fooImpl);
// Path: src/main/java/org/springframework/social/evernote/api/EvernoteException.java
// public class EvernoteException extends RuntimeException {
// 
// 	public EvernoteException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public boolean isEDAMUserException() {
// 		return getCause() instanceof EDAMUserException;
// 	}
// 
// 	public boolean isEDAMSystemException() {
// 		return getCause() instanceof EDAMSystemException;
// 	}
// 
// 	public boolean isEDAMNotFoundException() {
// 		return getCause() instanceof EDAMNotFoundException;
// 	}
// 
// 	public boolean isTException() {
// 		return getCause() instanceof TException;
// 	}
// 
// 	/**
// 	 * True if exception is one of {@link EDAMUserException}, {@link EDAMSystemException}, or {@link EDAMNotFoundException}
// 	 *
// 	 * @return true when thrown exception is one of EDAM*Exception.
// 	 */
// 	public boolean isEDAMException() {
// 		return isEDAMUserException() || isEDAMSystemException() || isEDAMNotFoundException();
// 	}
// 
// 	public EDAMErrorCode getEDAMErrorCode() {
// 		if (isEDAMUserException()) {
// 			return ((EDAMUserException) getCause()).getErrorCode();
// 		} else if (isEDAMSystemException()) {
// 			return ((EDAMSystemException) getCause()).getErrorCode();
// 		}
// 		return null;
// 	}
// }


// Path: src/test/java/org/springframework/social/evernote/api/impl/ClientStoreMethodInterceptorWithExceptionTest.java
import com.evernote.edam.error.EDAMNotFoundException;
import com.evernote.edam.error.EDAMSystemException;
import com.evernote.edam.error.EDAMUserException;
import com.evernote.thrift.TException;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.springframework.social.evernote.api.EvernoteException;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.runners.Parameterized.Parameters;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

package org.springframework.social.evernote.api.impl;




/**
 * @author Tadaya Tsuyukubo
 */
@RunWith(Parameterized.class)
public class ClientStoreMethodInterceptorWithExceptionTest {

	private Exception original;
	private Exception expected;

	@Parameters
	public static Collection<Object[]> data() {
		EDAMUserException edamUserException = new EDAMUserException();
		EDAMSystemException edamSystemException = new EDAMSystemException();
		EDAMNotFoundException edamNotFoundException = new EDAMNotFoundException();
		RuntimeException runtimeException = new RuntimeException();

		return Arrays.asList(new Object[][]{
				// original, expected
				{edamUserException, edamUserException},
				{edamSystemException, edamSystemException},
				{edamNotFoundException, edamNotFoundException},
				{runtimeException, runtimeException}
		});
	}

	public ClientStoreMethodInterceptorWithExceptionTest(Exception original, Exception expected) {
		this.original = original;
		this.expected = expected;
	}

	@Test
	public void testInvokeWithException() throws Throwable {

		// underlying class
		FooImpl fooImpl = mock(FooImpl.class);
		when(fooImpl.echo()).thenThrow(original);

		// invoked interface method
		Method getUserMethod = ReflectionUtils.findMethod(Foo.class, "echo");
		MethodInvocation invocation = mock(MethodInvocation.class);
		when(invocation.getThis()).thenReturn(fooImpl);
		when(invocation.getMethod()).thenReturn(getUserMethod);