// Create OrderStatus Pass Case. Case when description is unique and Flag is Invoice(Allowed) @Test public void createOrderStatus() { String statusName = "Test: " + System.currentTimeMillis(); refOrderStatus = buildOrderStatus(OrderStatusFlag.INVOICE, statusName); refOrderStatus.setId(api.createUpdateOrderStatus(refOrderStatus)); assertNotNull("Order status created", refOrderStatus.getId()); }
// Update Order Status fail case. Case when status flag is set to finished(Already exist) @Test(expectedExceptions = SessionInternalError.class) public void createUpdateOrderStatus2() { // create vanilla Invoice order status String statusName = "Update Test: " + System.currentTimeMillis(); refOrderStatus = buildOrderStatus(OrderStatusFlag.INVOICE, statusName); refOrderStatus.setId(api.createUpdateOrderStatus(refOrderStatus)); // attempt to change flag from INVOICE to FINISHED // refOrderStatus = api.findOrderStatusById(refOrderStatus.getId()); refOrderStatus.setOrderStatusFlag(OrderStatusFlag.FINISHED); api.createUpdateOrderStatus(refOrderStatus); }
// Update Order Status Description Pass case. Case when description is unique. @Test public void createUpdateOrderStatus() { // create vanilla Invoice order status String statusName = "Update Test: " + System.currentTimeMillis(); refOrderStatus = buildOrderStatus(OrderStatusFlag.INVOICE, statusName); refOrderStatus.setId(api.createUpdateOrderStatus(refOrderStatus)); // refresh and verify description refOrderStatus = api.findOrderStatusById(refOrderStatus.getId()); assertEquals("Description should match", statusName, refOrderStatus.getDescription()); // modify the description of the order status String newDescription = "New Update Test: " + System.currentTimeMillis(); refOrderStatus.setDescription(newDescription); refOrderStatus.setDescriptions(buildDescriptions(newDescription)); api.createUpdateOrderStatus(refOrderStatus); refOrderStatus = api.findOrderStatusById(refOrderStatus.getId()); assertEquals( "Updated Description should match", newDescription, refOrderStatus.getDescription()); }
private OrderStatusWS buildOrderStatus(OrderStatusFlag flag, String statusName) { OrderStatusWS orderStatus = new OrderStatusWS(null, company, flag, statusName); orderStatus.setDescription(statusName); orderStatus.setDescriptions(buildDescriptions(statusName)); return orderStatus; }