Added and rewrote tests
This commit is contained in:
25
src/test/java/de/rwu/easydrop/model/ProductPairTest.java
Normal file
25
src/test/java/de/rwu/easydrop/model/ProductPairTest.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package de.rwu.easydrop.model;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ProductPairTest {
|
||||
|
||||
@Test
|
||||
void constructor_TwoProducts_ProductsInitializedCorrectly() {
|
||||
// Arrange
|
||||
Product product1 = new Product();
|
||||
product1.setProductId("123");
|
||||
|
||||
Product product2 = new Product();
|
||||
product2.setProductId("234");
|
||||
|
||||
// Act
|
||||
ProductPair pair = new ProductPair(product1, product2);
|
||||
|
||||
// Assert
|
||||
assertSame(product1, pair.getProduct1());
|
||||
assertSame(product2, pair.getProduct2());
|
||||
}
|
||||
}
|
||||
23
src/test/java/de/rwu/easydrop/model/WebshopTest.java
Normal file
23
src/test/java/de/rwu/easydrop/model/WebshopTest.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package de.rwu.easydrop.model;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class WebshopTest {
|
||||
|
||||
@Test
|
||||
void testFromString_returnsIntendedConstant() {
|
||||
Webshop testShop = Webshop.fromString("Amazon");
|
||||
|
||||
assertEquals(Webshop.AMAZON, testShop);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFromString_invalidShop() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
Webshop.fromString("thisdoesnotexist");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user