Advertisement
aironman

exception

Dec 13th, 2019
206
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Running hello rule:
  2.  
  3. rule "My First Drools Rule"
  4. when
  5. $o: Object()
  6. then
  7. System.out.println(" >>> Rule Fired for Object: "+$o.toString());
  8. end
  9.  
  10. @Test
  11. public void hello() {
  12. Assert.assertNotNull(kSession);
  13. kSession.insert("Hi There From Test!");
  14. Assert.assertEquals(1, kSession.fireAllRules());
  15. }
  16.  
  17. java.lang.RuntimeException: Error while creating KieBase[Message [id=1, level=ERROR, path=rules.drl, line=22, column=0
  18. text=Unable to Analyse Expression isImported == true:
  19. [Error: no such identifier: isImported]
  20. [Near : {... isImported == true ....}]
  21. ^
  22. [Line: 22, Column: 2]]]
  23.  
  24. Running tax rule:
  25.  
  26. rule "Applying taxes to imported products."
  27. when
  28.  
  29. // Take the order from working memory and get the product list from it
  30. $order: Order( $products: products != null )
  31.  
  32. // Get only the imported products
  33. $product: Product( isImported == true ) from $products
  34. then
  35. $product.setSale_tax($product.getPrize() * (5d/100));
  36. $order.setTotalPrize($product.getSale_tax() + $product.getPrize());
  37. $order.setTotalTaxes($product.getSale_tax());
  38. System.out.println($order.toString());
  39. System.out.println($order.getTotalPrize());
  40. System.out.println($order.getTotalTaxes());
  41. end
  42.  
  43. @Test
  44. public void should_apply_rules_to_order2_exempetd_imported_not_imported() {
  45. //GIVEN
  46. Assert.assertNotNull(kSession);
  47. final Order order2 = Utilities.createOrder2();
  48. //WHEN
  49. kSession.insert(order2);
  50.  
  51. //THEN
  52. Assert.assertEquals(1, kSession.fireAllRules()); //failing
  53. Assert.assertEquals("Shoud be equals...",65.15d, order2.getTotalPrize(),0d);
  54. Assert.assertEquals("Shoud be equals...",7.65d, order2.getTotalTaxes(),0d);
  55. }
  56.  
  57. java.lang.AssertionError: expected:<1> but was:<0>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement