Add declarative MongoDB aggregation example.
Original pull request: #600.
This commit is contained in:
@@ -51,7 +51,7 @@ public class OrderRepositoryIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsInvoiceViaAggregation() {
|
||||
public void createsInvoiceViaAggregationProgrammatic() {
|
||||
|
||||
Order order = new Order("c42", new Date()).//
|
||||
addItem(product1).addItem(product2).addItem(product3);
|
||||
@@ -65,6 +65,22 @@ public class OrderRepositoryIntegrationTests {
|
||||
assertThat(invoice.getTaxAmount()).isCloseTo(1.577D, offset(0.00001));
|
||||
assertThat(invoice.getTotalAmount()).isCloseTo(9.877, offset(0.00001));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsInvoiceViaAggregationDeclarative() {
|
||||
|
||||
Order order = new Order("c42", new Date()).//
|
||||
addItem(product1).addItem(product2).addItem(product3);
|
||||
order = repository.save(order);
|
||||
|
||||
Invoice invoice = repository.getInvoiceForOrderDeclarative(order.getId());
|
||||
|
||||
assertThat(invoice).isNotNull();
|
||||
assertThat(invoice.getOrderId()).isEqualTo(order.getId());
|
||||
assertThat(invoice.getNetAmount()).isCloseTo(8.3D, offset(0.00001));
|
||||
assertThat(invoice.getTaxAmount()).isCloseTo(1.577D, offset(0.00001));
|
||||
assertThat(invoice.getTotalAmount()).isCloseTo(9.877, offset(0.00001));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void declarativeAggregationWithSort() {
|
||||
@@ -94,4 +110,5 @@ public class OrderRepositoryIntegrationTests {
|
||||
|
||||
assertThat(repository.totalOrdersForCustomer("c42")).isEqualTo(3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user