Polishing.
Add author tags. Update copyright years. Tweak method names. Reformat code. Closes #600 Original pull request: #600
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,12 +22,11 @@ import org.springframework.data.mongodb.repository.Aggregation;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
/**
|
||||
* A repository interface assembling CRUD functionality as well as the API to
|
||||
* invoke the methods implemented manually.
|
||||
* A repository interface assembling CRUD functionality as well as the API to invoke the methods implemented manually.
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
* @author Divya Srivastava
|
||||
*/
|
||||
public interface OrderRepository extends CrudRepository<Order, String>, OrderRepositoryCustom {
|
||||
|
||||
@@ -41,6 +40,6 @@ public interface OrderRepository extends CrudRepository<Order, String>, OrderRep
|
||||
"{ $project : { id : 1 , customerId : 1 , items : 1 , lineTotal : { $multiply: [ '$items.price' , '$items.quantity' ] } } }",
|
||||
"{ $group : { '_id' : '$_id' , 'netAmount' : { $sum : '$lineTotal' } , 'items' : { $addToSet : '$items' } } }",
|
||||
"{ $project : { 'orderId' : '$_id' , 'items' : 1 , 'netAmount' : 1 , 'taxAmount' : { $multiply: [ '$netAmount' , 0.19 ] } , 'totalAmount' : { $multiply: [ '$netAmount' , 1.19 ] } } }" })
|
||||
Invoice getInvoiceForOrderDeclarative(String orderId);
|
||||
Invoice aggregateInvoiceForOrder(String orderId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
* Copyright 2014-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
* @author Divya Srivastava
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@@ -51,7 +52,7 @@ public class OrderRepositoryIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsInvoiceViaAggregationProgrammatic() {
|
||||
public void createsInvoiceViaProgrammaticAggregation() {
|
||||
|
||||
Order order = new Order("c42", new Date()).//
|
||||
addItem(product1).addItem(product2).addItem(product3);
|
||||
@@ -65,15 +66,15 @@ 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() {
|
||||
public void createsInvoiceViaDeclarativeAggregation() {
|
||||
|
||||
Order order = new Order("c42", new Date()).//
|
||||
addItem(product1).addItem(product2).addItem(product3);
|
||||
order = repository.save(order);
|
||||
|
||||
Invoice invoice = repository.getInvoiceForOrderDeclarative(order.getId());
|
||||
Invoice invoice = repository.aggregateInvoiceForOrder(order.getId());
|
||||
|
||||
assertThat(invoice).isNotNull();
|
||||
assertThat(invoice.getOrderId()).isEqualTo(order.getId());
|
||||
@@ -110,5 +111,5 @@ public class OrderRepositoryIntegrationTests {
|
||||
|
||||
assertThat(repository.totalOrdersForCustomer("c42")).isEqualTo(3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user