DATACOUCH-75 - Trim off find on custom repository finder.
This commit is contained in:
@@ -20,6 +20,7 @@ import com.couchbase.client.protocol.views.Query;
|
||||
import org.springframework.data.couchbase.core.CouchbaseOperations;
|
||||
import org.springframework.data.repository.query.QueryMethod;
|
||||
import org.springframework.data.repository.query.RepositoryQuery;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Execute a repository query through the View mechanism.
|
||||
@@ -69,7 +70,7 @@ public class ViewBasedCouchbaseQuery implements RepositoryQuery {
|
||||
if (method.hasViewAnnotation()) {
|
||||
return method.getViewAnnotation().designDocument();
|
||||
} else {
|
||||
return method.getEntityInformation().getJavaType().getSimpleName().toLowerCase();
|
||||
return StringUtils.uncapitalize(method.getEntityInformation().getJavaType().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ public class ViewBasedCouchbaseQuery implements RepositoryQuery {
|
||||
if (method.hasViewAnnotation()) {
|
||||
return method.getViewAnnotation().viewName();
|
||||
} else {
|
||||
return method.getName();
|
||||
return StringUtils.uncapitalize(method.getName().replaceFirst("find", ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
import org.springframework.data.couchbase.TestApplicationConfig;
|
||||
import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
||||
import org.springframework.data.couchbase.repository.support.CouchbaseRepositoryFactory;
|
||||
@@ -72,4 +73,9 @@ public class CouchbaseRepositoryViewTests {
|
||||
assertThat(value, is(100L));
|
||||
}
|
||||
|
||||
@Test(expected = InvalidDataAccessResourceUsageException.class)
|
||||
public void shouldTrimOffFindOnCustomFinder() {
|
||||
repository.findAllSomething();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,4 +31,6 @@ public interface CustomUserRepository extends CouchbaseRepository<User, String>
|
||||
@View(designDocument = "userCustom", viewName = "customCountView")
|
||||
long count();
|
||||
|
||||
Iterable<User> findAllSomething();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user