|
| 1 | +package seedu.clinic.model.product; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 5 | +import static seedu.clinic.testutil.TypicalProductSupplier.SANITIZER_SUPPLIER; |
| 6 | +import static seedu.clinic.testutil.TypicalProductSupplier.SURGICAL_MASK_SUPPLIER; |
| 7 | +import static seedu.clinic.testutil.TypicalProductWarehouse.SANITIZER_WAREHOUSE; |
| 8 | +import static seedu.clinic.testutil.TypicalProductWarehouse.SURGICAL_MASK_WAREHOUSE; |
| 9 | + |
| 10 | +import org.junit.jupiter.api.Test; |
| 11 | + |
| 12 | +import seedu.clinic.testutil.ProductBuilderSupplier; |
| 13 | +import seedu.clinic.testutil.ProductBuilderWarehouse; |
| 14 | + |
| 15 | +public class ProductTest { |
| 16 | + @Test |
| 17 | + public void isSameProductSupplier() { |
| 18 | + //same object -> returns true |
| 19 | + assertTrue(SANITIZER_SUPPLIER.equals(SANITIZER_SUPPLIER)); |
| 20 | + |
| 21 | + //null -> returns false |
| 22 | + assertFalse(SANITIZER_SUPPLIER.equals(null)); |
| 23 | + |
| 24 | + // different name -> returns false |
| 25 | + Product editedSanitizerSupplier = new ProductBuilderSupplier(SANITIZER_SUPPLIER) |
| 26 | + .withName("Lifebuoy").build(); |
| 27 | + assertFalse(SANITIZER_SUPPLIER.equals(editedSanitizerSupplier)); |
| 28 | + |
| 29 | + //different name and tag -> returns false |
| 30 | + Product editedMaskSupplier = new ProductBuilderSupplier(SURGICAL_MASK_SUPPLIER).withName("housebrand") |
| 31 | + .withTags("protects").build(); |
| 32 | + assertFalse(SURGICAL_MASK_SUPPLIER.equals(editedMaskSupplier)); |
| 33 | + |
| 34 | + //different tag, same name -> returns true |
| 35 | + Product editedMaskTagsSupplier = new ProductBuilderSupplier(SURGICAL_MASK_SUPPLIER) |
| 36 | + .withTags("protects").build(); |
| 37 | + assertTrue(SURGICAL_MASK_SUPPLIER.equals(editedMaskTagsSupplier)); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + public void isSameProductWarehouse() { |
| 42 | + //same object -> returns true |
| 43 | + assertTrue(SANITIZER_WAREHOUSE.equals(SANITIZER_WAREHOUSE)); |
| 44 | + |
| 45 | + //null -> returns false |
| 46 | + assertFalse(SANITIZER_WAREHOUSE.equals(null)); |
| 47 | + |
| 48 | + // different name -> returns false |
| 49 | + Product editedSanitizerWarehouse = new ProductBuilderWarehouse(SANITIZER_WAREHOUSE) |
| 50 | + .withName("Lifebuoy").build(); |
| 51 | + assertFalse(SANITIZER_WAREHOUSE.equals(editedSanitizerWarehouse)); |
| 52 | + |
| 53 | + //different name and quantity -> returns false |
| 54 | + Product editedMaskWarehouse = new ProductBuilderWarehouse(SURGICAL_MASK_WAREHOUSE) |
| 55 | + .withName("housebrand").withQuantity(100).build(); |
| 56 | + assertFalse(SURGICAL_MASK_WAREHOUSE.equals(editedMaskWarehouse)); |
| 57 | + |
| 58 | + //different quantity, same name -> returns true |
| 59 | + Product editedMaskTagsWarehouse = new ProductBuilderWarehouse(SURGICAL_MASK_WAREHOUSE) |
| 60 | + .withQuantity(100).build(); |
| 61 | + assertTrue(SURGICAL_MASK_WAREHOUSE.equals(editedMaskTagsWarehouse)); |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments