created test write offer with validproduct
This commit is contained in:
@@ -36,9 +36,6 @@ public class OfferWriterTest {
|
||||
offerWriter = new OfferWriter(persistence);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
void writeOfferToPersistence_InvalidProduct_ThrowsException() {
|
||||
//Arrange
|
||||
@@ -50,6 +47,30 @@ public class OfferWriterTest {
|
||||
assertThrows(Exception.class, () -> offerWriter.writeOfferToPersistence(offer));
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeOfferToPresistence_ValidProduct_CallsSaveProduct(){
|
||||
|
||||
// Arrange
|
||||
Product product = new Product();
|
||||
product.setProductId("12345");
|
||||
product.setDataOrigin(Webshop.AMAZON);
|
||||
product.setCurrentPrice(9.99);
|
||||
|
||||
// Arrange
|
||||
Offer offer = new Offer();
|
||||
offer.setOfferId("26876");
|
||||
offer.setLastUpdate("2022-12-25");
|
||||
offer.setSourceProduct(product);
|
||||
offer.setTargetProduct(product);
|
||||
|
||||
// Act
|
||||
offerWriter.writeOfferToPersistence(offer);
|
||||
|
||||
// Assert
|
||||
Mockito.verify(persistence).writeOffer(any(OfferDTO.class));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user