Double sony_led_price = 900d;
Double sony_lcd_price = 500d;
//TVs
StockItem samsungLEDTV1 = new StockItem(ItemType.LED_TV,"Samsung");
StockItem samsungLEDTV2 = new StockItem(ItemType.LED_TV,"Samsung");
StockItem samsungLCDTV1 = new StockItem(ItemType.LCD_TV,"Samsung");
StockItem samsungTUBETV1 = new StockItem(ItemType.TUBE_TV,"Samsung");
StockItem sonyLEDTV1 = new StockItem(ItemType.LED_TV,"Sony");
StockItem sonyLCDTV1 = new StockItem(ItemType.LCD_TV,"Sony");
StockItem sonyLCDTV2 = new StockItem(ItemType.LCD_TV,"Sony");
//PROMOTIONAL PRICES
SpecialOffer samsungLCDSpecialOffer = new SpecialOffer(ItemType.LCD_TV, "Samsung", 300d);
SpecialOffer sonyLEDSpecialOffer = new SpecialOffer(ItemType.LED_TV, "Sony", 850d);
//Insert promotional prices as globals
ksession.setGlobal("samsung_led_price", samsung_led_price);
ksession.setGlobal("samsung_lcd_price", samsung_lcd_price);
ksession.setGlobal("samsung_tube_price", samsung_tube_price);
ksession.setGlobal("sony_led_price", sony_led_price);
ksession.setGlobal("sony_lcd_price", sony_lcd_price);
//Insert Special prices as facts
ksession.insert(samsungLCDSpecialOffer);
ksession.insert(sonyLEDSpecialOffer);
//Insert items as facts
ksession.insert(samsungLEDTV1);
ksession.insert(samsungLEDTV2);
ksession.insert(samsungLCDTV1);
ksession.insert(samsungTUBETV1);
ksession.insert(sonyLEDTV1);
ksession.insert(sonyLCDTV1);
ksession.insert(sonyLCDTV2);
//fire all rules
ksession.fireAllRules();
//Control
//SAMSUNG
Assert.assertEquals("",samsung_led_price.doubleValue(), samsungLEDTV1.getPrice(),0.1);
Assert.assertEquals("",samsung_led_price.doubleValue(), samsungLEDTV2.getPrice(),0.1);
Assert.assertEquals("",samsungLCDSpecialOffer.getPrice(), samsungLCDTV1.getPrice(),0.1);
Assert.assertEquals("",samsung_tube_price.doubleValue(), samsungTUBETV1.getPrice(),0.1);
//SONY
Assert.assertEquals("",sonyLEDSpecialOffer.getPrice(), sonyLEDTV1.getPrice(),0.1);
Assert.assertEquals("",sony_lcd_price.doubleValue(), sonyLCDTV1.getPrice(),0.1);
Assert.assertEquals("",sony_lcd_price.doubleValue(), sonyLCDTV2.getPrice(),0.1);
ksession.dispose();
}