diff --git a/QorderWS/src/main/java/com/qorder/qorderws/model/product/Product.java b/QorderWS/src/main/java/com/qorder/qorderws/model/product/Product.java index f6edd4f..a98db1f 100644 --- a/QorderWS/src/main/java/com/qorder/qorderws/model/product/Product.java +++ b/QorderWS/src/main/java/com/qorder/qorderws/model/product/Product.java @@ -30,7 +30,7 @@ public class Product { private BigDecimal price = new BigDecimal(0); @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable(name = "DESCRIPTION", joinColumns = @JoinColumn(name = "PRODUCT_ID")) + @CollectionTable(name = "DESCRIPTIONS", joinColumns = @JoinColumn(name = "PRODUCT_ID")) @Column(name = "DESCRIPTION") private List descriptions = new ArrayList(); @@ -116,4 +116,4 @@ public boolean equals(Object obj) { return false; return true; } -} +} \ No newline at end of file diff --git a/QorderWS/src/test/java/com/qorder/qorderws/dao/OrderDaoTest.java b/QorderWS/src/test/java/com/qorder/qorderws/dao/OrderDaoTest.java index dda0610..0cbf564 100644 --- a/QorderWS/src/test/java/com/qorder/qorderws/dao/OrderDaoTest.java +++ b/QorderWS/src/test/java/com/qorder/qorderws/dao/OrderDaoTest.java @@ -22,6 +22,7 @@ import com.qorder.qorderws.exception.BusinessDoesNotExistException; import com.qorder.qorderws.exception.OrderDoesNotExistException; +import com.qorder.qorderws.model.order.EOrderStatus; import com.qorder.qorderws.model.order.Order; @RunWith(SpringJUnit4ClassRunner.class) @@ -58,11 +59,6 @@ public void setUp() throws Exception { this.order = new Order(); } - @After - public void tearDown() throws Exception { - IDatabaseConnection connection = new DatabaseDataSourceConnection(testDataSource); - DatabaseOperation.DELETE.execute(connection, getDataSet()); - } @Test public void testFetchOrderForBusiness() throws BusinessDoesNotExistException{ @@ -70,15 +66,15 @@ public void testFetchOrderForBusiness() throws BusinessDoesNotExistException{ orderList = this.testOrderDAO.fetchOrderForBusiness(1); assertEquals("25", orderList.get(0).getTableNumber()); assertEquals(2, orderList.size()); - } @Test public void testSave() throws BusinessDoesNotExistException, OrderDoesNotExistException { - this.order.setTableNumber("50"); - this.testOrderDAO.save(this.order); - assertEquals("50", this.testOrderDAO.findById(3).getTableNumber()); - } + this.order.setTableNumber("50"); + this.testOrderDAO.save(this.order); + //Warning : change the ID each time you add an order in the DbunitOrders.xml file. + assertEquals("50", this.testOrderDAO.findById(6).getTableNumber()); + } @Test public void testFindById() throws OrderDoesNotExistException { @@ -86,8 +82,32 @@ public void testFindById() throws OrderDoesNotExistException { } @Test(expected=OrderDoesNotExistException.class) - public void testFindByIdDoesntExist() throws OrderDoesNotExistException { + public void testFindByIdDoesntExist() throws OrderDoesNotExistException { this.testOrderDAO.findById(3000); } + @Test + public void testFetchPendingOrdersForBusiness() throws BusinessDoesNotExistException { + List orderList= new ArrayList(); + orderList = this.testOrderDAO.fetchOrdersByStatus(2, EOrderStatus.PENDING); + assertEquals(2, orderList.size()); + assertEquals("15", orderList.get(0).getTableNumber()); + } + + @Test + public void testFetchAcceptedOrdersForBusiness() throws BusinessDoesNotExistException { + List orderList= new ArrayList(); + orderList = this.testOrderDAO.fetchOrdersByStatus(1, EOrderStatus.ACCEPTED); + assertEquals(2, orderList.size()); + assertEquals("25", orderList.get(0).getTableNumber()); + } + + @Test + public void testFetchServicedOrdersForBusiness() throws BusinessDoesNotExistException { + List orderList= new ArrayList(); + orderList = this.testOrderDAO.fetchOrdersByStatus(2, EOrderStatus.SERVICED); + assertEquals(1, orderList.size()); + assertEquals("17", orderList.get(0).getTableNumber()); + } + } \ No newline at end of file diff --git a/QorderWS/src/test/java/com/qorder/qorderws/dao/RunAllTests.java b/QorderWS/src/test/java/com/qorder/qorderws/dao/RunAllTests.java index d6fee12..7272ded 100644 --- a/QorderWS/src/test/java/com/qorder/qorderws/dao/RunAllTests.java +++ b/QorderWS/src/test/java/com/qorder/qorderws/dao/RunAllTests.java @@ -6,7 +6,7 @@ @RunWith(Suite.class) @SuiteClasses({ BusinessDaoTest.class, CategoryDaoTest.class, - ProductDaoTest.class }) + ProductDaoTest.class, OrderDaoTest.class }) public class RunAllTests { } diff --git a/QorderWS/src/test/resources/Dbunit/DbunitBusinesses.xml b/QorderWS/src/test/resources/Dbunit/DbunitBusinesses.xml index 9ec03af..05e9ef7 100644 --- a/QorderWS/src/test/resources/Dbunit/DbunitBusinesses.xml +++ b/QorderWS/src/test/resources/Dbunit/DbunitBusinesses.xml @@ -1,13 +1,13 @@ - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/QorderWS/src/test/resources/Dbunit/DbunitCategories.xml b/QorderWS/src/test/resources/Dbunit/DbunitCategories.xml index a792ade..8e1ce8f 100644 --- a/QorderWS/src/test/resources/Dbunit/DbunitCategories.xml +++ b/QorderWS/src/test/resources/Dbunit/DbunitCategories.xml @@ -1,22 +1,21 @@ - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/QorderWS/src/test/resources/Dbunit/DbunitOrders.xml b/QorderWS/src/test/resources/Dbunit/DbunitOrders.xml index 818f811..b358c67 100644 --- a/QorderWS/src/test/resources/Dbunit/DbunitOrders.xml +++ b/QorderWS/src/test/resources/Dbunit/DbunitOrders.xml @@ -1,20 +1,43 @@ - + + + + + + + - + + - - + + + + + + + + + + + + - - + + + - - + + + + - + + + + \ No newline at end of file diff --git a/QorderWS/src/test/resources/Dbunit/DbunitProducts.xml b/QorderWS/src/test/resources/Dbunit/DbunitProducts.xml index cafb5a6..8613b4c 100644 --- a/QorderWS/src/test/resources/Dbunit/DbunitProducts.xml +++ b/QorderWS/src/test/resources/Dbunit/DbunitProducts.xml @@ -1,19 +1,19 @@ - + - + - - - - - - - + + + + + + + - - + + \ No newline at end of file