public class Expecter
extends java.lang.Object
Constructor and Description |
---|
Expecter(BETestEngine engine)
Create a new Expecter object to be used by the unit test engine
|
Modifier and Type | Method and Description |
---|---|
void |
expect(java.lang.String uri,
ExpectationType type)
Expect that the
ExpectationType operation occurred at least once for any entity specified by uri For example: expect("/Concepts/Person", ExpectationType.CONCEPT_MODIFICATION) tests whether at least one instance of '/Concepts/Person' has been modified Example 2: expect("/Events/Fraud", ExpectationType.EVENT_CREATED) tests whether at least one '/Events/Fraud' has been created |
void |
expectEventAsserted(java.lang.String eventUri)
Expect that an Event specified by
eventUri has been created/asserted |
void |
expectEventSent(java.lang.String eventUri)
Expect that an Event specified by
eventUri has been sent |
void |
expectInWorkingMemory(Entity entity)
Expect that the specified Entity currently exists in working memory.
|
void |
expectInWorkingMemory(java.lang.String uri)
Expect that at least one entity specified by
uri currently exists in working memory.For example: expectInWorkingMemory("/Concepts/Person") tests whether there is an instance of '/Concepts/Person' currently in working memory |
void |
expectInWorkingMemoryByExtId(java.lang.String extId)
Expect that at least one entity specified by
uri currently exists in working memory.For example: expectInWorkingMemory("/Concepts/Person") tests whether there is an instance of '/Concepts/Person' currently in working memory |
void |
expectModified(java.lang.String uri)
Expect that a particular entity specified by
uri has been modified
For example, expectModified("/Concepts/Person") will test whether a
Person concept has been modifiedNote that this will test whether any /Concepts/Person instance has been modified To test a specific entity instance, use the expectModified(String uri, String propertyName, Object newValue, String extId)
method instead |
void |
expectModified(java.lang.String uri,
java.lang.String propertyName)
Expect that a particular property with the name
propertyName
in the entity specified by uri has been modified
For example, expectModified("/Concepts/Person", "department") will test whether a
Person concept has a property named 'department' that has been modifiedNote that this will test whether any /Concepts/Person instance has been modified To test a specific entity instance, use the expectModified(String uri, String propertyName, Object newValue, String extId)
method instead |
void |
expectModified(java.lang.String uri,
java.lang.String propertyName,
java.lang.Object newValue)
Expect that a particular property with the name
propertyName
in the entity specified by uri has been modified, and the new value
of the property is equal to newValue For example, expectModified("/Concepts/Person", "department", 1234) will test whether a Person concept has a property named 'department' that has been modified to the value '1234' Note that this will test whether any /Concepts/Person has been modified to the expected value. |
void |
expectModifiedByExtId(java.lang.String extId)
Expect that a particular entity specified by
extId has been modified
For example, expectModifiedByExtId("MY_ID") will test whether a
Concept or Event with the extId equal to "MY_ID" has been modified |
void |
expectModifiedByExtId(java.lang.String extId,
java.lang.String propertyName)
Expect that a particular property with the name
propertyName
in the entity specified by extId has been modified
For example, expectModifiedByExtId("MY_ID", "department") will test whether the
Entity matching the extId has a property named 'department' that has been modified |
void |
expectModifiedByExtId(java.lang.String extId,
java.lang.String propertyName,
java.lang.Object newValue)
Expect that a particular property with the name
propertyName
in the entity with the matching extId has been modified, and the new value
of the property is equal to newValue For example, expectModifiedByExtId("MY_ID", "department", 1234) will test whether an Entity matching extId 'MY_ID' has a property named 'department' that has been modified to the value '1234' |
void |
expectNothing()
Expect that nothing has happened in the current Rule Session.
|
void |
expectNotInWorkingMemory(Entity entity)
Expect that the specified Entity does not currently exist in working memory.
|
void |
expectNotInWorkingMemory(java.lang.String uri)
Expect that no entity specified by
uri currently exists in working memory.For example: expectNotInWorkingMemory("/Concepts/Person") tests whether there is an instance of '/Concepts/Person' currently in working memory, and will fail if one is found |
void |
expectNotInWorkingMemoryByExtId(java.lang.String extId)
Expect that no entity with the matching
extId currently exists in working memory.For example: expectNotInWorkingMemory("MY_ID") tests whether there is an Event or Concept currently in working memory with the extId of 'MY_ID', and will fail if one is found |
void |
expectOnce(java.lang.String uri,
ExpectationType type)
Expect that the
ExpectationType operation occurred only once for any entity specified by uri For example: expectOnce("/Concepts/Person", ExpectationType.CONCEPT_MODIFICATION) tests whether exactly one instance of '/Concepts/Person' has been modified Example 2: expectOnce("/Events/Fraud", ExpectationType.EVENT_CREATED) tests whether exactly one '/Events/Fraud' has been created |
void |
expectOrdered(java.util.List ruleURIs,
ExpectationType type)
Expect that all rules specified in
ruleURIs have fired, in a specific order. |
void |
expectRuleFired(java.lang.String ruleURI)
Expect that the rule specified by
ruleURI has fired.For example: expectRuleFired("/Rules/FraudDetected") will check whether the rule 'FraudDetected' has fired, and will
fail if not |
void |
expectScheduled(java.lang.String timeEventUri)
Expect that the Time Event specified by
timeEventUri has been scheduled. |
void |
expectScheduled(java.lang.String timeEventUri,
boolean failIfAlreadyFired)
Expect that the Time Event specified by
timeEventUri has been scheduled. |
void |
expectScheduledByExtId(java.lang.String extId)
Expect that the Time Event specified by
timeEventUri has been scheduled. |
void |
expectScheduledByExtId(java.lang.String extId,
boolean failIfAlreadyFired)
Expect that the Time Event specified by
timeEventUri has been scheduled. |
void |
expectSomething()
Expect that something has happened in the current Rule Session.
|
void |
expectUnmodified(java.lang.String uri)
Expect that a particular entity specified by
uri has not been modified
For example, expectUnmodified("/Concepts/Person") will test whether a
Person concept has been modified, and will fail if soNote that this will test whether any /Concepts/Person instance has been modified To test a specific entity instance, use the expectModified(String uri, String propertyName, Object newValue, String extId)
method instead |
void |
expectUnmodified(java.lang.String uri,
java.lang.String propertyName)
Expect that a particular property with the name
propertyName
in the entity specified by uri has not been modified
For example, expectModified("/Concepts/Person", "department") will test whether a
Person concept has a property named 'department' that has been modified, and will fail if soTo test a specific entity instance, use the expectModified(String uri, String propertyName, Object newValue, String extId)
method instead |
void |
expectUnmodifiedByExtId(java.lang.String extId)
Expect that a particular entity specified by
uri has not been modified
For example, expectUnmodified("/Concepts/Person") will test whether a
Person concept has been modified, and will fail if soNote that this will test whether any /Concepts/Person instance has been modified To test a specific entity instance, use the expectModified(String uri, String propertyName, Object newValue, String extId)
method instead |
void |
expectUnmodifiedByExtId(java.lang.String extId,
java.lang.String propertyName)
Expect that a particular property with the name
propertyName
in the entity specified by uri has not been modified
For example, expectModified("/Concepts/Person", "department") will test whether a
Person concept has a property named 'department' that has been modified, and will fail if soTo test a specific entity instance, use the expectModified(String uri, String propertyName, Object newValue, String extId)
method instead |
void |
expectUnordered(java.util.List ruleURIs)
Expect that all rules specified in
ruleURIs have fired, in any order. |
public Expecter(BETestEngine engine)
engine
- public void expectEventAsserted(java.lang.String eventUri)
eventUri
has been created/assertedeventUri
- - the Event uri, for example "/Events/FraudDetected"public void expectEventSent(java.lang.String eventUri)
eventUri
has been senteventUri
- - the Event uri, for example "/Events/FraudDetected"public void expectInWorkingMemory(Entity entity)
entity
- - an instance of an Entity, typically created from the TestDataHelper
public void expectInWorkingMemory(java.lang.String uri)
uri
currently exists in working memory.expectInWorkingMemory("/Concepts/Person")
uri
- - the entity uri, for instance "/Concepts/Person"public void expectModified(java.lang.String uri)
uri
has been modified
For example, expectModified("/Concepts/Person") will test whether a
Person concept has been modifiedexpectModified(String uri, String propertyName, Object newValue, String extId)
method insteaduri
- - the entity uri (i.e. "/Concepts/Person")public void expectModified(java.lang.String uri, java.lang.String propertyName)
propertyName
in the entity specified by uri
has been modified
For example, expectModified("/Concepts/Person", "department") will test whether a
Person concept has a property named 'department' that has been modifiedexpectModified(String uri, String propertyName, Object newValue, String extId)
method insteaduri
- - the entity uri (i.e. "/Concepts/Person")propertyName
- - the name of the property to checkpublic void expectModified(java.lang.String uri, java.lang.String propertyName, java.lang.Object newValue)
propertyName
in the entity specified by uri
has been modified, and the new value
of the property is equal to newValue
expectModified(String uri, String propertyName, Object newValue, String extId)
method insteaduri
- - the entity uri (i.e. "/Concepts/Person")propertyName
- - the name of the property to checknewValue
- - the expected new value of the property. If null, then newValue will be ignored and no value check will occurpublic void expectInWorkingMemoryByExtId(java.lang.String extId)
uri
currently exists in working memory.expectInWorkingMemory("/Concepts/Person")
extId
- - the extId of the entitypublic void expectModifiedByExtId(java.lang.String extId)
extId
has been modified
For example, expectModifiedByExtId("MY_ID") will test whether a
Concept or Event with the extId equal to "MY_ID" has been modifiedextId
- - the extId of the entitypublic void expectModifiedByExtId(java.lang.String extId, java.lang.String propertyName)
propertyName
in the entity specified by extId
has been modified
For example, expectModifiedByExtId("MY_ID", "department") will test whether the
Entity matching the extId has a property named 'department' that has been modifiedextId
- - the extId of the entitypropertyName
- - the name of the property to checkpublic void expectModifiedByExtId(java.lang.String extId, java.lang.String propertyName, java.lang.Object newValue)
propertyName
in the entity with the matching extId
has been modified, and the new value
of the property is equal to newValue
extId
- - the extId of the entitypropertyName
- - the name of the property to checknewValue
- - the expected new value of the property. If null, then newValue will be ignored and no value check will occurpublic void expectNothing()
public void expectNotInWorkingMemory(Entity entity)
entity
- - an instance of an Entity (i.e a Concept or an Event), typically created from the TestDataHelper
public void expectNotInWorkingMemory(java.lang.String uri)
uri
currently exists in working memory.expectNotInWorkingMemory("/Concepts/Person")
uri
- - the entity uri, for instance "/Concepts/Person"public void expectNotInWorkingMemoryByExtId(java.lang.String extId)
extId
currently exists in working memory.expectNotInWorkingMemory("MY_ID")
extId
- - the extId of the entitypublic void expectOnce(java.lang.String uri, ExpectationType type)
ExpectationType
operation occurred only once for any entity specified by uri
expectOnce("/Concepts/Person", ExpectationType.CONCEPT_MODIFICATION)
expectOnce("/Events/Fraud", ExpectationType.EVENT_CREATED)
uri
- - the entity uri, for instance "/Concepts/Person"type
- - the ExpectationType
operationpublic void expect(java.lang.String uri, ExpectationType type)
ExpectationType
operation occurred at least once for any entity specified by uri
expect("/Concepts/Person", ExpectationType.CONCEPT_MODIFICATION)
expect("/Events/Fraud", ExpectationType.EVENT_CREATED)
uri
- - the entity uri, for instance "/Concepts/Person"type
- - the ExpectationType
operationpublic void expectOrdered(java.util.List ruleURIs, ExpectationType type)
ruleURIs
have fired, in a specific order.
For example:
engine.executeRules();
List rules = new ArrayList();
rules.add("/Rules/ProcessApplication");
rules.add("/Rules/FraudDetected");
expecter.expectOrdered(rules, ExpectationType.RULE_EXECUTION);
ruleURIs
- - a List of Strings corresponding to the expected order of rule executionpublic void expectRuleFired(java.lang.String ruleURI)
ruleURI
has fired.expectRuleFired("/Rules/FraudDetected")
will check whether the rule 'FraudDetected' has fired, and will
fail if notruleURI
- - the uri of the rule, for instance "/Rules/FraudDetected"public void expectScheduled(java.lang.String timeEventUri)
timeEventUri
has been scheduled.
Convenience method. This is fully equivalent to expectScheduled(timeEventUri, false)
timeEventUri
- - the Time Event uri, for instance "/Events/ScheduledPaymentEvent"public void expectScheduledByExtId(java.lang.String extId)
timeEventUri
has been scheduled.
Convenience method. This is fully equivalent to expectScheduled(timeEventUri, false)
extId
- - the extId of the Time Eventpublic void expectScheduled(java.lang.String timeEventUri, boolean failIfAlreadyFired)
timeEventUri
has been scheduled. If failIfAlreadyFired
is set to true, an AssertionError will be thrown if the Time Event was scheduled but has already firedtimeEventUri
- - the Time Event uri, for instance "/Events/ScheduledPaymentEvent"failIfAlreadyFired
- - if true, an AssertionError will be thrown if the Time Event was scheduled but has already firedpublic void expectScheduledByExtId(java.lang.String extId, boolean failIfAlreadyFired)
timeEventUri
has been scheduled. If failIfAlreadyFired
is set to true, an AssertionError will be thrown if the Time Event was scheduled but has already firedextId
- - the extId of the Time EventfailIfAlreadyFired
- - if true, an AssertionError will be thrown if the Time Event was scheduled but has already firedpublic void expectSomething()
public void expectUnmodified(java.lang.String uri)
uri
has not been modified
For example, expectUnmodified("/Concepts/Person") will test whether a
Person concept has been modified, and will fail if soexpectModified(String uri, String propertyName, Object newValue, String extId)
method insteaduri
- - the entity uri (i.e. "/Concepts/Person")public void expectUnmodified(java.lang.String uri, java.lang.String propertyName)
propertyName
in the entity specified by uri
has not been modified
For example, expectModified("/Concepts/Person", "department") will test whether a
Person concept has a property named 'department' that has been modified, and will fail if soexpectModified(String uri, String propertyName, Object newValue, String extId)
method insteaduri
- - the entity uri (i.e. "/Concepts/Person")propertyName
- - the name of the property to checkpublic void expectUnmodifiedByExtId(java.lang.String extId)
uri
has not been modified
For example, expectUnmodified("/Concepts/Person") will test whether a
Person concept has been modified, and will fail if soexpectModified(String uri, String propertyName, Object newValue, String extId)
method insteadextId
- - the extId of the entitypublic void expectUnmodifiedByExtId(java.lang.String extId, java.lang.String propertyName)
propertyName
in the entity specified by uri
has not been modified
For example, expectModified("/Concepts/Person", "department") will test whether a
Person concept has a property named 'department' that has been modified, and will fail if soexpectModified(String uri, String propertyName, Object newValue, String extId)
method insteadextId
- - the extId of the entitypropertyName
- - the name of the property to checkpublic void expectUnordered(java.util.List ruleURIs)
ruleURIs
have fired, in any order.
For example:
engine.executeRules();
List rules = new ArrayList();
rules.add("/Rules/ProcessApplication");
rules.add("/Rules/FraudDetected");
ruleURIs
- - a List of Strings corresponding to the expected rules