Created
July 11, 2016 00:07
-
-
Save brunokrebs/89ab787c71d30cfed45f69f8072bc8ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.someaddress.test; | |
import com.someaddress.model.Product; | |
import com.someaddress.intent.DetailsUpdateIntent; | |
import java.math.BigDecimal; | |
import org.testng.Assert; | |
import org.testng.annotations.Test; | |
public class ProductTest { | |
@Test | |
public void testUpdateDetails() { | |
DetailsUpdateIntent intent = new DetailsUpdateIntent(); | |
intent.setId("xy12"); | |
intent.setName("White Cow Milk"); | |
intent.setDescription("Very fresh milk ready to consume"); | |
intent.setPrice(BigDecimal.valueOf(-1)); | |
Product product = new Product(); | |
try { | |
product.handleDetailsUpdate(intent); | |
Assert.fail("Should not accept negative prices."); | |
} catch (IllegalArgumentException e) {} | |
BigDecimal newPrice = BigDecimal.valueOf(2.42); | |
intent.setPrice(); | |
product.handleDetailsUpdate(intent); | |
Assert.assertEquals(product.getPrice(), newPrice, "Should have 2.42 as price."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment