// Path: src/main/java/com/github/rwitzel/couchrepository/internal/QueryMethodHandler.java
// @SuppressWarnings("rawtypes")
// public class QueryMethodHandler implements InvocationHandler {
// 
//     protected CouchDbCrudRepository crudRepository;
// 
//     protected Object customRepository;
// 
//     protected ViewParamsMerger viewParamsMerger;
// 
//     public QueryMethodHandler(CouchDbCrudRepository crudRepository, Object customRepository,
//             ViewParamsMerger viewParamsMerger) {
//         super();
//         this.crudRepository = crudRepository;
//         this.customRepository = customRepository;
//         this.viewParamsMerger = viewParamsMerger;
//     }
// 
//     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// 
//         // delegate to the custom repository?
//         if (customRepository != null) {
//             Method underlyingMethod = ReflectionUtils.findMethod(customRepository.getClass(), method.getName(),
//                     method.getParameterTypes());
// 
//             if (underlyingMethod != null) {
//                 try {
//                     return underlyingMethod.invoke(customRepository, args);
//                 } catch (InvocationTargetException e) {
//                     throw e.getCause(); // we want to throw the original exception
//                 }
//             }
//         }
// 
//         // delegate to the underlying CRUD repository?
//         Method underlyingMethod = ReflectionUtils.findMethod(crudRepository.getClass(), method.getName(),
//                 method.getParameterTypes());
//         if (underlyingMethod != null) {
//             try {
//                 return underlyingMethod.invoke(crudRepository, args);
//             } catch (InvocationTargetException e) {
//                 throw e.getCause(); // we want to throw the original exception
//             }
//         }
// 
//         // find by view
//         ViewParams viewParams = new ViewParams();
//         viewParamsMerger.mergeViewParams(viewParams, method, args);
//         return crudRepository.find(viewParams);
//     }
// 
// }
// 
// Path: src/test/java/com/github/rwitzel/couchrepository/model/Comment.java
// public class Comment {
//     
//     private String author;
//     
//     private String text;
// 
//     public String getAuthor() {
//         return author;
//     }
// 
//     public void setAuthor(String author) {
//         this.author = author;
//     }
// 
//     public String getText() {
//         return text;
//     }
// 
//     public void setText(String text) {
//         this.text = text;
//     }
// 
//     @Override
//     public int hashCode() {
//         final int prime = 31;
//         int result = 1;
//         result = prime * result + ((author == null) ? 0 : author.hashCode());
//         result = prime * result + ((text == null) ? 0 : text.hashCode());
//         return result;
//     }
// 
//     /**
//      * Generated by Eclipse.
//      */
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)
//             return true;
//         if (obj == null)
//             return false;
//         if (getClass() != obj.getClass())
//             return false;
//         Comment other = (Comment) obj;
//         if (author == null) {
//             if (other.author != null)
//                 return false;
//         } else if (!author.equals(other.author))
//             return false;
//         if (text == null) {
//             if (other.text != null)
//                 return false;
//         } else if (!text.equals(other.text))
//             return false;
//         return true;
//     }
// 
// }


import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.rwitzel.couchrepository.internal.QueryMethodHandler;
import com.github.rwitzel.couchrepository.model.Comment;
package com.github.rwitzel.couchrepository.api;





/**
 * Tests interfaces that must be automatically implemented by {@link QueryMethodHandler}.
 * 
 * @author rwitzel
 */
public abstract class AbstractAutomaticImplementationTest extends AbstractCouchdbCrudRepositoryTest {

    @Autowired
    private ProductRepository productRepo;

    @Test
    public void testDelegateToFindByViewParams() throws Exception {
        
        deleteProductRepoAndCreateSomeProducts();

        ViewParams viewParams = new ViewParams();
// Path: src/main/java/com/github/rwitzel/couchrepository/internal/QueryMethodHandler.java
// @SuppressWarnings("rawtypes")
// public class QueryMethodHandler implements InvocationHandler {
// 
//     protected CouchDbCrudRepository crudRepository;
// 
//     protected Object customRepository;
// 
//     protected ViewParamsMerger viewParamsMerger;
// 
//     public QueryMethodHandler(CouchDbCrudRepository crudRepository, Object customRepository,
//             ViewParamsMerger viewParamsMerger) {
//         super();
//         this.crudRepository = crudRepository;
//         this.customRepository = customRepository;
//         this.viewParamsMerger = viewParamsMerger;
//     }
// 
//     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// 
//         // delegate to the custom repository?
//         if (customRepository != null) {
//             Method underlyingMethod = ReflectionUtils.findMethod(customRepository.getClass(), method.getName(),
//                     method.getParameterTypes());
// 
//             if (underlyingMethod != null) {
//                 try {
//                     return underlyingMethod.invoke(customRepository, args);
//                 } catch (InvocationTargetException e) {
//                     throw e.getCause(); // we want to throw the original exception
//                 }
//             }
//         }
// 
//         // delegate to the underlying CRUD repository?
//         Method underlyingMethod = ReflectionUtils.findMethod(crudRepository.getClass(), method.getName(),
//                 method.getParameterTypes());
//         if (underlyingMethod != null) {
//             try {
//                 return underlyingMethod.invoke(crudRepository, args);
//             } catch (InvocationTargetException e) {
//                 throw e.getCause(); // we want to throw the original exception
//             }
//         }
// 
//         // find by view
//         ViewParams viewParams = new ViewParams();
//         viewParamsMerger.mergeViewParams(viewParams, method, args);
//         return crudRepository.find(viewParams);
//     }
// 
// }
// 
// Path: src/test/java/com/github/rwitzel/couchrepository/model/Comment.java
// public class Comment {
//     
//     private String author;
//     
//     private String text;
// 
//     public String getAuthor() {
//         return author;
//     }
// 
//     public void setAuthor(String author) {
//         this.author = author;
//     }
// 
//     public String getText() {
//         return text;
//     }
// 
//     public void setText(String text) {
//         this.text = text;
//     }
// 
//     @Override
//     public int hashCode() {
//         final int prime = 31;
//         int result = 1;
//         result = prime * result + ((author == null) ? 0 : author.hashCode());
//         result = prime * result + ((text == null) ? 0 : text.hashCode());
//         return result;
//     }
// 
//     /**
//      * Generated by Eclipse.
//      */
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)
//             return true;
//         if (obj == null)
//             return false;
//         if (getClass() != obj.getClass())
//             return false;
//         Comment other = (Comment) obj;
//         if (author == null) {
//             if (other.author != null)
//                 return false;
//         } else if (!author.equals(other.author))
//             return false;
//         if (text == null) {
//             if (other.text != null)
//                 return false;
//         } else if (!text.equals(other.text))
//             return false;
//         return true;
//     }
// 
// }


// Path: src/test/java/com/github/rwitzel/couchrepository/api/AbstractAutomaticImplementationTest.java
import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.rwitzel.couchrepository.internal.QueryMethodHandler;
import com.github.rwitzel.couchrepository.model.Comment;

package com.github.rwitzel.couchrepository.api;





/**
 * Tests interfaces that must be automatically implemented by {@link QueryMethodHandler}.
 * 
 * @author rwitzel
 */
public abstract class AbstractAutomaticImplementationTest extends AbstractCouchdbCrudRepositoryTest {

    @Autowired
    private ProductRepository productRepo;

    @Test
    public void testDelegateToFindByViewParams() throws Exception {
        
        deleteProductRepoAndCreateSomeProducts();

        ViewParams viewParams = new ViewParams();
        viewParams.setKeyType(String[].class);