This commit is contained in:
Timo Westkämper 2009-06-04 11:57:57 +00:00
parent f08dfe3598
commit d7398fca35
4 changed files with 52 additions and 1 deletions

View File

@ -1,5 +1,7 @@
package com.mysema.query;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
@ -50,6 +52,14 @@ public class ColQueryStandardTest {
}
}
@Test
public void matchingStringFilters(){
for (EBoolean f : TestFilters.getMatchingFilters(cat.name, otherCat.name, "Bob")){
System.out.println(f);
assertTrue(!MiniApi.from(cat, data).from(otherCat, data).where(f).list(cat.name).isEmpty());
}
}
@Test
public void booleanFilters(){
for (EBoolean f : TestFilters.getFiltersForBoolean(cat.name.isNull(), otherCat.kittens.isEmpty())){

View File

@ -108,6 +108,36 @@ public abstract class TestFilters {
return rv;
}
public static Collection<EBoolean> getMatchingFilters(EString expr, EString other, String knownValue){
return Arrays.<EBoolean>asList(
expr.eq(other),
expr.eq(knownValue),
expr.ne(other),
expr.ne(knownValue),
expr.equalsIgnoreCase(other),
expr.equalsIgnoreCase(knownValue),
expr.lower().eq(other.lower()),
expr.upper().eq(other.upper()),
expr.lower().eq(knownValue.toLowerCase()),
expr.charAt(0).eq(other.charAt(0)),
expr.endsWith(other),
expr.endsWith(knownValue),
expr.startsWith(other),
expr.startsWith(knownValue),
expr.contains(other),
expr.contains(knownValue),
other.startsWith(expr),
other.endsWith(expr),
other.contains(expr),
expr.substring(0,1).eq(other.substring(0,1)),
expr.substring(1).eq(other.substring(1)),
expr.substring(0,1).eq(knownValue.substring(0,1)),
expr.substring(1).eq(knownValue.substring(1)),
expr.like(knownValue),
other.like(knownValue)
);
}
private TestFilters(){}
}

View File

@ -7,6 +7,7 @@ import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.jdo.annotations.EmbeddedOnly;
import javax.jdo.annotations.PersistenceCapable;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
@ -28,7 +29,7 @@ public class JDOAnnotationProcessor extends AbstractProcessor{
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Running " + getClass().getSimpleName());
Class<? extends Annotation> entity = PersistenceCapable.class;
Class<? extends Annotation> superType = null;
Class<? extends Annotation> embeddable = null;
Class<? extends Annotation> embeddable = EmbeddedOnly.class;
Class<? extends Annotation> dtoAnnotation = DTO.class;
Processor p = new Processor(processingEnv, entity, superType, embeddable, dtoAnnotation, "Q");
p.process(roundEnv);

View File

@ -1,5 +1,7 @@
package com.mysema.query;
import static org.junit.Assert.*;
import javax.jdo.PersistenceManager;
import javax.jdo.Transaction;
@ -44,6 +46,14 @@ public class JDOQLQueryStandardTest extends AbstractJDOTest{
}
}
@Test
public void matchingStringFilters(){
for (EBoolean f : TestFilters.getMatchingFilters(product.name, otherProduct.name, "C5")){
System.out.println(f);
assertTrue(!query().from(product, otherProduct).where(f).list(product.name, otherProduct.name).isEmpty());
}
}
@BeforeClass
public static void doPersist() {
// Persistence of a Product and a Book.