mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-06 21:05:50 +08:00
Add test case for #1262
This commit is contained in:
parent
12d785f528
commit
b454f78c3a
@ -0,0 +1,49 @@
|
||||
package com.querydsl.collections;
|
||||
|
||||
import static com.querydsl.collections.CollQueryFactory.from;
|
||||
import static com.querydsl.core.alias.Alias.$;
|
||||
import static com.querydsl.core.alias.Alias.alias;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class GuavaOptionalTest {
|
||||
|
||||
public static class Cat {
|
||||
|
||||
private Optional<String> pedigree = Optional.absent();
|
||||
|
||||
public Cat() {
|
||||
}
|
||||
|
||||
public Cat(Optional<String> pedigree) {
|
||||
this.pedigree = pedigree;
|
||||
}
|
||||
|
||||
public Optional<String> getPedigree() {
|
||||
return pedigree;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Test() {
|
||||
Collection<Cat> cats = Lists.newArrayList();
|
||||
cats.add(new Cat(Optional.<String>absent()));
|
||||
cats.add(new Cat(Optional.of("persian")));
|
||||
Cat c = alias(Cat.class);
|
||||
|
||||
for (Cat cat : from(c, cats)
|
||||
.where($(c.getPedigree()).eq(Optional.of("persian")))
|
||||
.list($(c))) {
|
||||
|
||||
assertTrue(cat.getPedigree().isPresent());
|
||||
assertEquals("persian", cat.getPedigree().get());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user