mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Add integration test for InventoryInitializer
This commit is contained in:
parent
d0ac59de87
commit
9ec41df27f
|
@ -0,0 +1,48 @@
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
// SPDX-FileCopyrightText: 2024 swt23w23
|
||||||
|
package catering.inventory;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.salespointframework.inventory.UniqueInventory;
|
||||||
|
import org.salespointframework.inventory.UniqueInventoryItem;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import catering.catalog.CateringCatalog;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class InventoryInitializerIntegrationTests {
|
||||||
|
@Autowired
|
||||||
|
UniqueInventory<UniqueInventoryItem> inventory;
|
||||||
|
@Autowired
|
||||||
|
CateringCatalog cateringCatalog;
|
||||||
|
|
||||||
|
InventoryInitializer inventoryInitializer;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void init() {
|
||||||
|
inventoryInitializer = new InventoryInitializer(inventory, cateringCatalog);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the inventory items are only created once.
|
||||||
|
*
|
||||||
|
* After the first startup,
|
||||||
|
* the catalog entries will only be changed through the inventory interfaces,
|
||||||
|
* which automatically keep the catalog in sync.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void onlyRunOnce() {
|
||||||
|
// the first run is already done
|
||||||
|
Set<UniqueInventoryItem> before = inventory.findAll().stream().collect(Collectors.toSet());
|
||||||
|
inventoryInitializer.initialize();
|
||||||
|
Set<UniqueInventoryItem> after = inventory.findAll().stream().collect(Collectors.toSet());
|
||||||
|
|
||||||
|
assertThat(before).hasSameElementsAs(after);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue