[rules-users] WorkingMemoryListener & Declared Types

Wolfgang Laun wolfgang.laun at gmail.com
Wed Aug 7 05:34:16 EDT 2013


On 07/08/2013, droolster <quant.coder at 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.

Well, just stick to your principles.

>
> 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.
>

What's this got to do with toString() for a declared type?

> Is there a good way of doing this?

See the API for org.drools.definition.type.FactType.
StatefulKnowledgeSession has a method getObjects() with an
ObjectFilter argument.

It would be even easier with a class declared in Java, but your principles...

-W

>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/WorkingMemoryListener-Declared-Types-tp4025391p4025396.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list