mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Remove CustomCatalogEntryDataInitializer
This commit is contained in:
parent
441c12ee17
commit
580489d216
|
@ -1,46 +0,0 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
// SPDX-FileCopyrightText: 2023-2024 swt23w23
|
|
||||||
package catering.orderCatalog;
|
|
||||||
|
|
||||||
import catering.order.OrderType;
|
|
||||||
import org.salespointframework.catalog.Product;
|
|
||||||
import org.salespointframework.core.DataInitializer;
|
|
||||||
import org.salespointframework.quantity.Quantity;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.salespointframework.inventory.UniqueInventory;
|
|
||||||
import org.salespointframework.inventory.UniqueInventoryItem;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.javamoney.moneta.Money;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class CustomCatalogEntryDataInitializer implements DataInitializer {
|
|
||||||
private CustomCatalogEntryRepository catalogEntryRepository;
|
|
||||||
private final UniqueInventory<UniqueInventoryItem> inventory;
|
|
||||||
|
|
||||||
public CustomCatalogEntryDataInitializer(CustomCatalogEntryRepository catalogEntryRepository, UniqueInventory<UniqueInventoryItem> inventory) {
|
|
||||||
this.catalogEntryRepository = catalogEntryRepository;
|
|
||||||
this.inventory = inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize() {
|
|
||||||
|
|
||||||
Map<Product, Quantity> products = new HashMap<>();
|
|
||||||
Product product1 = inventory.findAll().stream().toList().get(0).getProduct();
|
|
||||||
Product product2 = inventory.findAll().stream().toList().get(1).getProduct();
|
|
||||||
Product product3 = inventory.findAll().stream().toList().get(2).getProduct();
|
|
||||||
|
|
||||||
products.put(product1, product1.createQuantity(30));
|
|
||||||
products.put(product2, product2.createQuantity(15));
|
|
||||||
products.put(product3, product3.createQuantity(1));
|
|
||||||
|
|
||||||
catalogEntryRepository.save(
|
|
||||||
new CustomCatalogEntry(
|
|
||||||
OrderType.EVENT_CATERING,
|
|
||||||
products,
|
|
||||||
Money.of(500, "EUR")));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,7 +44,6 @@ public class CatalogControllerUnitTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void countOfEntries() {
|
void countOfEntries() {
|
||||||
// Includes entry of data initializer
|
assertThat(catalogEntryRepository.findAll().stream().count()).isEqualTo(1);
|
||||||
assertThat(catalogEntryRepository.findAll().stream().count()).isEqualTo(2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue