SGF-156 fix
This commit is contained in:
@@ -46,7 +46,7 @@ abstract class AbstractFunctionTemplate implements GemfireFunctionOperations {
|
||||
.setArgs(args)
|
||||
.setFunction(function);
|
||||
|
||||
return this.<T>executeAndExtract(functionExecution);
|
||||
return this.<T> executeAndExtract(functionExecution);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.gemstone.gemfire.cache.Region;
|
||||
*/
|
||||
class QueryString {
|
||||
|
||||
private static final String REGION_PATTERN = "(?<=\\/)%s";
|
||||
private static final String REGION_PATTERN = "(?<=\\/)\\w+";
|
||||
private static final String IN_PARAMETER_PATTERN = "(?<=IN (SET|LIST) \\$)\\d";
|
||||
private static final String IN_PATTERN = "(?<=IN (SET|LIST) )\\$\\d";
|
||||
|
||||
@@ -66,10 +66,8 @@ class QueryString {
|
||||
* @param region must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
public QueryString forRegion(Class<?> domainClass, Region<?, ?> region) {
|
||||
|
||||
String pattern = String.format(REGION_PATTERN, domainClass.getSimpleName());
|
||||
return new QueryString(query.replaceAll(pattern, region.getName()));
|
||||
public QueryString forRegion(Class<?> domainClass, Region<?, ?> region) {
|
||||
return new QueryString(query.replaceAll(REGION_PATTERN, region.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,6 +49,16 @@ public class QueryStringUnitTests {
|
||||
when(region.getName()).thenReturn("foo");
|
||||
assertThat(query.forRegion(Person.class, region).toString(), is("SELECT * FROM /foo p WHERE p.firstname = $1"));
|
||||
}
|
||||
|
||||
//SGF-156
|
||||
@Test
|
||||
public void replacesDomainObjectWithPluralRegionNameCorrectly() {
|
||||
|
||||
QueryString query = new QueryString("SELECT * FROM /Persons p WHERE p.firstname = $1");
|
||||
|
||||
when(region.getName()).thenReturn("Persons");
|
||||
assertThat(query.forRegion(Person.class, region).toString(), is("SELECT * FROM /Persons p WHERE p.firstname = $1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindsInValuesCorrectly() {
|
||||
|
||||
@@ -79,13 +79,9 @@ public abstract class AbstractGemfireRepositoryFactoryIntegrationTests {
|
||||
|
||||
protected abstract PersonRepository getRepository(Regions regions);
|
||||
|
||||
@Test
|
||||
public void foo() {
|
||||
assertResultsFound(repository.findByFirstnameAnnotated("Dave"), dave);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void executesAnnotatedInQueryMethodCorrectly() {
|
||||
assertResultsFound(repository.findByFirstnameAnnotated("Dave"), dave);
|
||||
assertResultsFound(repository.findByFirstnamesAnnotated(Arrays.asList("Carter", "Dave")), carter, dave);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user