<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Add commons beanutils to your project:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 145, 146); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                </span></span><span style="color: #009193">&lt;</span>dependency<span style="color: #009193">&gt;</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre">                        </span><span style="color: #009193">&lt;</span><span style="color: #4e9192">groupId</span><span style="color: #009193">&gt;</span>commons-beanutils<span style="color: #009193">&lt;/</span><span style="color: #4e9192">groupId</span><span style="color: #009193">&gt;</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre">                        </span><span style="color: #009193">&lt;</span><span style="color: #4e9192">artifactId</span><span style="color: #009193">&gt;</span>commons-beanutils<span style="color: #009193">&lt;/</span><span style="color: #4e9192">artifactId</span><span style="color: #009193">&gt;</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 145, 146); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                        </span></span><span style="color: #009193">&lt;</span>version<span style="color: #009193">&gt;</span><span style="color: #000000">1.8.3</span><span style="color: #009193">&lt;/</span>version<span style="color: #009193">&gt;</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(78, 145, 146); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                </span></span><span style="color: #009193">&lt;/</span>dependency<span style="color: #009193">&gt;</span></div></div><div><br></div><div>Then all you need is a class with a static method something like this:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp;&nbsp;<span style="color: #931a68">public</span> <span style="color: #931a68">static</span> String objectDetails(Object o) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; StringBuilder sb = <span style="color: #931a68">new</span> StringBuilder(o.getClass().getSimpleName());</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #931a68">try</span> {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(119, 119, 119); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>@SuppressWarnings<span style="color: #000000">(</span><span style="color: #3933ff">"unchecked"</span><span style="color: #000000">)</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map&lt;String, Object&gt; objectProperties = BeanUtils.describe(o);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #931a68">for</span> (String k : objectProperties.keySet()) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.append(<span style="color: #3933ff">", "</span> + k + <span style="color: #3933ff">"=\""</span> + objectProperties.get(k) + <span style="color: #3933ff">"\""</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; } <span style="color: #931a68">catch</span> (IllegalAccessException e) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #931a68">return</span><span style="color: #000000"> </span>"IllegalAccessException attempting to parse object."<span style="color: #000000">;</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; } <span style="color: #931a68">catch</span> (InvocationTargetException e) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #931a68">return</span><span style="color: #000000"> </span>"InvocationTargetException attempting to parse object."<span style="color: #000000">;</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; } <span style="color: #931a68">catch</span> (NoSuchMethodException e) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #931a68">return</span><span style="color: #000000"> </span>"NoSuchMethodException attempting to parse object."<span style="color: #000000">;</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #931a68">return</span> sb.toString();</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; }</div></div><div><br></div><div><br></div><br><div><div>On 7 Aug 2013, at 10:19, droolster &lt;<a href="mailto:quant.coder@gmail.com">quant.coder@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi,<br><br>I haven't put Foo in my Java code as it is a transient type which I need to<br>the rule processing and not really part of my ontology model. Anything which<br>isn't part of ontology model but which I need to do the rule processing, I<br>put those types in my DRL file.<br><br>I'll explain what I am trying to achieve:<br><br>I am writing some JUnit test classes and I would like to test for specific<br>values for some attributes in the declared types in my DRL file. So in the<br>example I gave, I would like to assert that during rule processing the value<br>of Foo.score == 4.<br><br>So basically I would like to query the working memory for this type and get<br>the value of the score attribute.<br><br>Is there a good way of doing this?<br><br><br><br>--<br>View this message in context: <a href="http://drools.46999.n3.nabble.com/WorkingMemoryListener-Declared-Types-tp4025391p4025396.html">http://drools.46999.n3.nabble.com/WorkingMemoryListener-Declared-Types-tp4025391p4025396.html</a><br>Sent from the Drools: User forum mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users<br></blockquote></div><br></body></html>