Rev | Line | |
---|
[891] | 1 | import static org.junit.Assert.assertThat |
---|
| 2 | import static org.hamcrest.CoreMatchers.equalTo |
---|
| 3 | import grails.test.GrailsUnitTestCase |
---|
| 4 | |
---|
| 5 | /** |
---|
[894] | 6 | * Unit tests for PurchaseOrderNumber domain class. |
---|
[891] | 7 | */ |
---|
| 8 | class PurchaseOrderNumberTests extends GrailsUnitTestCase { |
---|
| 9 | protected void setUp() { |
---|
| 10 | super.setUp() |
---|
| 11 | mockDomain(PurchaseOrder) |
---|
| 12 | mockDomain(PurchaseOrderNumber) |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | protected void tearDown() { |
---|
| 16 | super.tearDown() |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | void testGetDescriptionForNewPurchaseOrder() { |
---|
| 20 | createTenPurchaseOrderNumbers() |
---|
| 21 | def pon = PurchaseOrderNumber.get(1) |
---|
| 22 | |
---|
| 23 | assertThat pon.description, equalTo("P1000 - new") |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | void testGetDescriptionForExistingPurchaseOrder() { |
---|
| 27 | def pon = new PurchaseOrderNumber(value:"P1234").save(failOnError:true) |
---|
| 28 | def supplier = new Supplier(name:"Supplier Name",supplierType:new SupplierType()) |
---|
| 29 | def po = new PurchaseOrder(purchaseOrderNumber:pon, supplier:supplier) |
---|
| 30 | pon.purchaseOrder = po |
---|
| 31 | pon.save(failOnError:true) |
---|
| 32 | po.save(failOnError:true) |
---|
| 33 | |
---|
| 34 | assertThat pon.description, equalTo("P1234 for Supplier Name") |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | private createTenPurchaseOrderNumbers() { |
---|
| 38 | for (int i = 1000; i < 1010; i++) { |
---|
| 39 | new PurchaseOrderNumber(value: "P${i}").save(failOnError: true) |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.