[891] | 1 | import static org.junit.Assert.assertThat |
---|
| 2 | import static org.hamcrest.CoreMatchers.equalTo |
---|
| 3 | import grails.test.GrailsUnitTestCase |
---|
| 4 | |
---|
| 5 | /** |
---|
| 6 | * Created by IntelliJ IDEA. |
---|
| 7 | * User: John |
---|
| 8 | * Date: 19/04/2011 |
---|
| 9 | * Time: 8:32:59 AM |
---|
| 10 | * To change this template use File | Settings | File Templates. |
---|
| 11 | */ |
---|
| 12 | class PurchaseOrderNumberTests extends GrailsUnitTestCase { |
---|
| 13 | protected void setUp() { |
---|
| 14 | super.setUp() |
---|
| 15 | mockDomain(PurchaseOrder) |
---|
| 16 | mockDomain(PurchaseOrderNumber) |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | protected void tearDown() { |
---|
| 20 | super.tearDown() |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | void testGetDescriptionForNewPurchaseOrder() { |
---|
| 24 | createTenPurchaseOrderNumbers() |
---|
| 25 | def pon = PurchaseOrderNumber.get(1) |
---|
| 26 | |
---|
| 27 | assertThat pon.description, equalTo("P1000 - new") |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | void testGetDescriptionForExistingPurchaseOrder() { |
---|
| 31 | def pon = new PurchaseOrderNumber(value:"P1234").save(failOnError:true) |
---|
| 32 | def supplier = new Supplier(name:"Supplier Name",supplierType:new SupplierType()) |
---|
| 33 | def po = new PurchaseOrder(purchaseOrderNumber:pon, supplier:supplier) |
---|
| 34 | pon.purchaseOrder = po |
---|
| 35 | pon.save(failOnError:true) |
---|
| 36 | po.save(failOnError:true) |
---|
| 37 | |
---|
| 38 | assertThat pon.description, equalTo("P1234 for Supplier Name") |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | private createTenPurchaseOrderNumbers() { |
---|
| 42 | for (int i = 1000; i < 1010; i++) { |
---|
| 43 | new PurchaseOrderNumber(value: "P${i}").save(failOnError: true) |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | } |
---|