d9646ab9d1
Release package / release (push) Failing after 3m24s
Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #9
53 lines
1.1 KiB
Java
53 lines
1.1 KiB
Java
package com.drinkool.entities;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
import io.quarkus.test.junit.QuarkusTest;
|
|
import jakarta.transaction.Transactional;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
@QuarkusTest
|
|
public class EateryInventoryItemEntityTest {
|
|
|
|
@Test
|
|
@Transactional
|
|
void testAdd_WhenItemExists_ShouldUseExistingItem() {
|
|
String itemName = "Coca Cola";
|
|
int quantity = 10;
|
|
|
|
InventoryItemEntity.create(itemName);
|
|
|
|
EateryInventoryItemEntity eateryItem = EateryInventoryItemEntity.create(
|
|
itemName,
|
|
quantity,
|
|
""
|
|
);
|
|
|
|
EateryInventoryItemEntity savedEntity = EateryInventoryItemEntity.find(
|
|
"id",
|
|
eateryItem.id
|
|
).firstResult();
|
|
assertNotNull(savedEntity);
|
|
}
|
|
|
|
@Test
|
|
@Transactional
|
|
void testAdd_WhenItemDoesNotExist_ShouldCreateNewItem() {
|
|
String itemName = "Pepsi";
|
|
int quantity = 5;
|
|
String unit = "Bottle";
|
|
|
|
EateryInventoryItemEntity eateryItem = EateryInventoryItemEntity.create(
|
|
itemName,
|
|
quantity,
|
|
unit
|
|
);
|
|
|
|
EateryInventoryItemEntity savedEntity = EateryInventoryItemEntity.find(
|
|
"id",
|
|
eateryItem.id
|
|
).firstResult();
|
|
assertNotNull(savedEntity);
|
|
}
|
|
}
|