@Test public void testValidateProduct() { // For Test 1 = None of the values can be empty for (Product p : products) { System.out.println("\n" + p.getProductId()); } assertEquals(ProductService.validateProduct(products.get(0)), Constants.ALL_FIELDS_REQUIRED); // For Test 2 = Price should be greater than zero assertEquals( ProductService.validateProduct(products.get(1)), Utility.getPropertyValue(Constants.pricemorethanzero)); // For Test 3 = Non negative values assertEquals( ProductService.validateProduct(products.get(2)), Utility.getPropertyValue(Constants.msgnotNegative)); }
@Test public void test() { // Add Discount. We have done some validation in UI View itself like // date validation. // 1. normal seasonal discount validate and save assertEquals(DiscountService.validateDiscount(discounts.get(0)), Constants.SUCCESS); assertEquals(DiscountService.validateDiscount(discounts.get(1)), Constants.SUCCESS); // 2. Discount code not greater than 100 assertEquals( DiscountService.validateDiscount(discounts.get(2)), Utility.getPropertyValue(Constants.msgnotGrtThan100)); // 3. Discount code / duration non -ve assertEquals( DiscountService.validateDiscount(discounts.get(3)), Utility.getPropertyValue(Constants.msgnotNegative)); assertEquals( DiscountService.validateDiscount(discounts.get(4)), Utility.getPropertyValue(Constants.msgnotNegative)); assertEquals( DiscountService.validateDiscount(discounts.get(5)), Utility.getPropertyValue(Constants.msgnotNegative)); // test 4 : discount object Null or string empty validation assertEquals( DiscountService.validateDiscount(null), Utility.getPropertyValue(Constants.validateEmptyMessage)); assertEquals( DiscountService.validateDiscount(discounts.get(6)), Utility.getPropertyValue(Constants.validateEmptyMessage)); assertEquals( DiscountService.validateDiscount(discounts.get(7)), Utility.getPropertyValue(Constants.validateEmptyMessage)); }