|
|
|
|
@@ -57,12 +57,12 @@ public class StorageServer {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createOrders(ProductRepository productRepository, OrderRepository orderRepository) {
|
|
|
|
|
Random random = new Random(System.nanoTime());
|
|
|
|
|
Address address = new Address("it", "doesn't", "matter");
|
|
|
|
|
var random = new Random(System.nanoTime());
|
|
|
|
|
var address = new Address("it", "doesn't", "matter");
|
|
|
|
|
LongStream.rangeClosed(1, 10).forEach((orderId) -> LongStream.rangeClosed(1, 300).forEach((customerId) -> {
|
|
|
|
|
Order order = new Order(orderId, customerId, address);
|
|
|
|
|
var order = new Order(orderId, customerId, address);
|
|
|
|
|
IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> {
|
|
|
|
|
int quantity = random.nextInt(3) + 1;
|
|
|
|
|
var quantity = random.nextInt(3) + 1;
|
|
|
|
|
long productId = random.nextInt(3) + 1;
|
|
|
|
|
order.add(new LineItem(productRepository.findById(productId).get(), quantity));
|
|
|
|
|
});
|
|
|
|
|
@@ -73,7 +73,7 @@ public class StorageServer {
|
|
|
|
|
private void createProducts(ProductRepository productRepository) {
|
|
|
|
|
productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"), "An Apple portable music player"));
|
|
|
|
|
productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"), "An Apple tablet device"));
|
|
|
|
|
Product macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"), "An Apple notebook computer");
|
|
|
|
|
var macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"), "An Apple notebook computer");
|
|
|
|
|
macbook.addAttribute("warranty", "included");
|
|
|
|
|
productRepository.save(macbook);
|
|
|
|
|
}
|
|
|
|
|
|