Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ class Book {
this.outOfStock = outOfStock;
}

public Book(
int id,
String title,
Integer publishYear,
Boolean outOfStock,
Long isbn13,
Double discount,
BigDecimal price) {
this(id, title, publishYear, outOfStock);
this.isbn13 = isbn13;
this.discount = discount;
this.price = price;
}

@Override
public String toString() {
return "Book{" + "id=" + id + '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,41 @@ void testBooleanFieldPathExpression(boolean negated) {
assertSelectionQuery(
"from Book where" + (negated ? " not " : " ") + "outOfStock",
Book.class,
"{'aggregate': 'books', 'pipeline': [{'$match': {'outOfStock': {'$eq': "
+ (negated ? "false" : "true")
+ "}}}, {'$project': {'_id': true, 'discount': true, 'isbn13': true, 'outOfStock': true, 'price': true, 'publishYear': true, 'title': true}}]}",
"""
{
"aggregate": "books",
"pipeline": [
{
"$match": {
"$and": [
{
"outOfStock": {
"$eq": %s
}
},
{
"outOfStock": {
"$ne": null
}
}
]
}
},
{
"$project": {
"_id": true,
"discount": true,
"isbn13": true,
"outOfStock": true,
"price": true,
"publishYear": true,
"title": true
}
}
]
}
"""
.formatted(negated ? "false" : "true"),
negated ? singletonList(bookInStock) : singletonList(bookOutOfStock));
}

Expand Down
Loading