use of org.immutables.criteria.typemodel.LocalDateHolderCriteria in project immutables by immutables.
the class ComponentTypeTest method localDate.
@Test
void localDate() {
final LocalDateHolderCriteria criteria = LocalDateHolderCriteria.localDateHolder;
check(argumentOf(criteria.array)).is(LocalDate.class);
check(argumentOf(criteria.list)).is(LocalDate.class);
}
use of org.immutables.criteria.typemodel.LocalDateHolderCriteria in project immutables by immutables.
the class ReturnTypeTest method localDate.
@Test
void localDate() {
final LocalDateHolderCriteria criteria = LocalDateHolderCriteria.localDateHolder;
check(Matchers.toExpression(criteria.value.min()).returnType()).is(LocalDate.class);
check(Matchers.toExpression(criteria.value.max()).returnType()).is(LocalDate.class);
check(Matchers.toExpression(criteria.value.count()).returnType()).is(Long.class);
check(Matchers.toExpression(criteria.value).returnType()).is(LocalDate.class);
check(Matchers.toExpression(criteria.optional).returnType()).is(new TypeToken<Optional<LocalDate>>() {
}.getType());
check(Matchers.toExpression(criteria.nullable).returnType()).is(LocalDate.class);
}
use of org.immutables.criteria.typemodel.LocalDateHolderCriteria in project immutables by immutables.
the class TupleCodecProviderTest method localDate.
@Test
void localDate() {
LocalDateHolderCriteria criteria = LocalDateHolderCriteria.localDateHolder;
Query query = Query.of(TypeHolder.LocalDateHolder.class).addProjections(Matchers.toExpression(criteria.value), Matchers.toExpression(criteria.nullable), Matchers.toExpression(criteria.optional));
Path idPath = Visitors.toPath(KeyExtractor.defaultFactory().create(TypeHolder.LocalDateHolder.class).metadata().keys().get(0));
TupleCodecProvider provider = new TupleCodecProvider(query, new MongoPathNaming(idPath, PathNaming.defaultNaming()).toExpression());
Codec<ProjectedTuple> codec = provider.get(ProjectedTuple.class, registry);
LocalDate now = LocalDate.now();
final long millisEpoch = now.atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli();
BsonDocument doc = new BsonDocument().append("id", new BsonString("id1")).append("value", new BsonDateTime(millisEpoch)).append("nullable", BsonNull.VALUE).append("optional", BsonNull.VALUE).append("array", new BsonArray()).append("list", new BsonArray());
ProjectedTuple tuple = codec.decode(new BsonDocumentReader(doc), DecoderContext.builder().build());
check(tuple.get(Matchers.toExpression(criteria.value))).is(now);
check(tuple.get(Matchers.toExpression(criteria.nullable))).isNull();
check(tuple.get(Matchers.toExpression(criteria.optional))).is(Optional.empty());
}
Aggregations