Add commons beanutils to your project:
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
Then all you need is a class with a static method something like this:
public static String objectDetails(Object o) {
StringBuilder sb = new StringBuilder(o.getClass().getSimpleName());
try {
@SuppressWarnings("unchecked")
Map<String, Object> objectProperties = BeanUtils.describe(o);
for (String k : objectProperties.keySet()) {
sb.append(", " + k + "=\"" +
objectProperties.get(k) + "\"");
}
} catch (IllegalAccessException e) {
return "IllegalAccessException attempting to parse object.";
} catch (InvocationTargetException e) {
return "InvocationTargetException attempting to parse object.";
} catch (NoSuchMethodException e) {
return "NoSuchMethodException attempting to parse object.";
}
return sb.toString();
}
On 7 Aug 2013, at 10:19, droolster <quant.coder(a)gmail.com> wrote:
Hi,
I haven't put Foo in my Java code as it is a transient type which I need to
the rule processing and not really part of my ontology model. Anything which
isn't part of ontology model but which I need to do the rule processing, I
put those types in my DRL file.
I'll explain what I am trying to achieve:
I am writing some JUnit test classes and I would like to test for specific
values for some attributes in the declared types in my DRL file. So in the
example I gave, I would like to assert that during rule processing the value
of Foo.score == 4.
So basically I would like to query the working memory for this type and get
the value of the score attribute.
Is there a good way of doing this?
--
View this message in context:
http://drools.46999.n3.nabble.com/WorkingMemoryListener-Declared-Types-tp...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users