<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-2022-jp">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>
<div>Thank you all very much for your advice! I feel I have what I need to move forward.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>
<div>-- James</div>
<div><br>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Stephen Masters &lt;<a href="mailto:stephen.masters@me.com">stephen.masters@me.com</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>Rules Users List &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Wednesday, March 27, 2013 2:24 AM<br>
<span style="font-weight:bold">To: </span>Rules Users List &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [rules-users] How to determine which rules fired under what conditions, for testing<br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>Good point Wolfgang - I linked to the wrong listener for tracking rule activations!</div>
<div><br>
</div>
<div>As Wolfgang alludes, I use object filters all the time for unit testing. It lets me create assertions about the objects that are in working memory. I find it very valuable when my rules are inserting new facts, rather than just modifying the fact I inserted.</div>
<div><br>
</div>
<div>btw - If your toString() method doesn't give you quite enough details about a fact, then the objectDetails(Object) method in the following will use reflection (via commons BeanUtils) to iterate through all the properties of an object and build a big string
 from them. Which is a good reason to ensure that all your classes have decent toString() methods.</div>
<div><a href="https://github.com/gratiartis/sctrcd-fx-web/blob/master/src/main/java/uk/co/scattercode/drools/util/DroolsUtil.java">https://github.com/gratiartis/sctrcd-fx-web/blob/master/src/main/java/uk/co/scattercode/drools/util/DroolsUtil.java</a></div>
<div><br>
</div>
<div>Steve</div>
<div><br>
</div>
<br>
<div>
<div>On 27 Mar 2013, at 04:49, Wolfgang Laun &lt;<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">Stephen has pointed you to a WorkingMemoryEventListener, and next to<br>
it there is also a TrackingAgendaEventListener. Callback methods<br>
beforeActivationFired and afterActivationFired bracket the execution<br>
of a rule's consequence, which, in combination with the WM events,<br>
will show you what a rule changes in WM.<br>
<br>
As to the facts participating in the firing of a rule: the Activation<br>
object of before/afterActivationFired lets you retrieve these Objects.<br>
(The list of FactHandle's may contain FactHandle objects that do not<br>
necessarily relate to Facts inserted into Working Memory.)<br>
<br>
If your Fact objects provide good toString() methods, putting this all<br>
together is a fairly simple task. Make sure to pick up Stephen's ideas<br>
about filtering - this may even be useful for unit testing.<br>
<br>
-W<br>
<br>
<br>
On 26/03/2013, Magnarelli, James &lt;<a href="mailto:James_Magnarelli@intuit.com">James_Magnarelli@intuit.com</a>&gt; wrote:<br>
<blockquote type="cite">Just to clarify, for anyone else who might offer advice, my original<br>
desire was to have some kind of information about what rule fired, and<br>
what object it fired for.<br>
<br>
<br>
-- James<br>
<br>
<br>
<br>
<br>
<br>
<br>
On 3/26/13 1:15 PM, &quot;Grant Rettke&quot; &lt;<a href="mailto:grettke@acm.org">grettke@acm.org</a>&gt; wrote:<br>
<br>
<blockquote type="cite">You might think differently about unit testing, set up your tests so<br>
you *know* the data is there, and add or retract facts, and verify<br>
their presence as a matter of success of failure.<br>
<br>
There are also more advanced approaches that others will surely share<br>
soon.<br>
<br>
On Tue, Mar 26, 2013 at 3:11 PM, Magnarelli, James<br>
&lt;<a href="mailto:James_Magnarelli@intuit.com">James_Magnarelli@intuit.com</a>&gt; wrote:<br>
<blockquote type="cite">Though all of those are worthy pursuits, I want to do it in the sense of<br>
unit testing to make sure that I have defined the rule correctly.<br>
<br>
Thanks for your rapid response, by the way. I really appreciate it.<br>
<br>
-- James<br>
<br>
<br>
<br>
<br>
<br>
<br>
On 3/26/13 1:08 PM, &quot;Grant Rettke&quot; &lt;<a href="mailto:grettke@acm.org">grettke@acm.org</a>&gt; wrote:<br>
<br>
<blockquote type="cite">Do you want to do that in the sense of unit testing to make sure you<br>
have defined the rule correctly?<br>
<br>
Or, do you want to understand more about the dynamic behavior as your<br>
system executes for profiling? Or learning more about your model?<br>
<br>
On Tue, Mar 26, 2013 at 3:05 PM, jmagnare &lt;<a href="mailto:james_magnarelli@intuit.com">james_magnarelli@intuit.com</a>&gt;<br>
wrote:<br>
<blockquote type="cite">I'm fairly new to Drools, but a fair amount of digging and searching<br>
hasn't<br>
brought me closer to an answer on this:<br>
<br>
Is there a way for me to determine, at runtime, which rules were fired<br>
and<br>
with what inputs?<br>
<br>
I am looking to use this my JUnit tests, to make sure that the rules I<br>
want<br>
to be fired are firing when I expect them to.<br>
<br>
<br>
<br>
--<br>
View this message in context:<br>
<a href="http://drools.46999.n3.nabble.com/How-to-determine-which-rules-fired-un">http://drools.46999.n3.nabble.com/How-to-determine-which-rules-fired-un</a><br>
de<br>
r-what-conditions-for-testing-tp4023063.html<br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
<br>
<br>
<br>
--<br>
Grant Rettke | ACM, AMA, COG, IEEE<br>
<a href="mailto:grettke@acm.org">grettke@acm.org</a> | <a href="http://www.wisdomandwonder.com/">
http://www.wisdomandwonder.com/</a><br>
Wisdom begins in wonder.<br>
(($B&K(B (x) (x x)) ($B&K(B (x) (x x)))<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
<br>
<br>
<br>
--<br>
Grant Rettke | ACM, AMA, COG, IEEE<br>
<a href="mailto:grettke@acm.org">grettke@acm.org</a> | <a href="http://www.wisdomandwonder.com/">
http://www.wisdomandwonder.com/</a><br>
Wisdom begins in wonder.<br>
(($B&K(B (x) (x x)) ($B&K(B (x) (x x)))<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
</blockquote>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></blockquote>
</div>
<br>
</div>
</div>
</span>
</body>
</html>