
jadex.bdi.testcases.plans.PlanConditionTesterPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
The newest version!
package jadex.bdi.testcases.plans;
import jadex.base.test.TestReport;
import jadex.bdi.runtime.Plan;
/**
* Test if trigger conditions of plans work.
*/
public class PlanConditionTesterPlan extends Plan
{
/**
* The body method is called on the
* instatiated plan instance from the scheduler.
*/
public void body()
{
TestReport tr = new TestReport("#1", "Test if a condition triggers a plan.");
int a1 = ((Integer)getBeliefbase().getBelief("a").getFact()).intValue();
getBeliefbase().getBelief("count").setFact(Integer.valueOf(1));
waitFor(100);
int a2 = ((Integer)getBeliefbase().getBelief("a").getFact()).intValue();
if(a1+1==a2)
{
tr.setSucceeded(true);
}
else
{
tr.setReason("No plan was triggered.");
}
getBeliefbase().getBeliefSet("testcap.reports").addFact(tr);
tr = new TestReport("#2", "Test if a condition triggers a plan with binding.");
a1 = ((Integer)getBeliefbase().getBelief("a").getFact()).intValue();
getBeliefbase().getBelief("count").setFact(Integer.valueOf(2));
waitFor(1000);
a2 = ((Integer)getBeliefbase().getBelief("a").getFact()).intValue();
if(a1+2==a2)
{
tr.setSucceeded(true);
}
else
{
tr.setReason("No plan was triggered.");
}
getBeliefbase().getBeliefSet("testcap.reports").addFact(tr);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy