blinton wrote:
Hello,
Using the following imported enum:
public enum Status {
INCOMPLETE,
COMPLETE
}
And the following rule:
when
status : Status(this == Status.COMPLETE)
then
// ...
We're attempting to write a guvnor test scenario for this rule. But we can't
seem to figure out the syntax for instantiating the "given" status object.
Could someone point us in the correct direction? Many thanks.
Hi,
you don't need to instantiate Java enum values. In fact, the java syntax
simply does not support it, because the enum values specified in the
enum declaration are the only allowed instances of the enum "class"
generated by the compiler behind the scenes.
How to use them with drools? Just insert one of the enum values into
your working memory, like so:
workingMemory.insert(Status.INCOMPLETE);
This of course also works with variable "status" values, e. g.:
private void insertStatus(Status actualStatus) {
workingMemory.insert(actualStatus);
}
Best regards
Ansgar