All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bdi.testcases.misc.TriggerPlan Maven / Gradle / Ivy

Go to download

The Jadex BDI applications package contain several example applications, benchmarks and testcases using BDI agents.

There is a newer version: 2.4
Show newest version
package jadex.bdi.testcases.misc;

import jadex.base.test.TestReport;
import jadex.bdi.runtime.Plan;

/**
 *  A plan to be triggered by conditions
 *  of the repeatability test agent.
 */
public class TriggerPlan extends Plan
{
	/** The number, when the plan should be triggered. */
	private int	no;

	/** A description of the test case. */
	private String	description;

	/**
	 *  Create a new trigger plan.
	 *  @param no	The number, when the plan should be triggered.
	 *  @param	description	A description of the test case.
	 */
	public TriggerPlan()
	{
		this.no	= ((Number)getParameter("number").getValue()).intValue();
		this.description	= (String)getParameter("description").getValue();
	}
	
	/**
	 *  The plan code.
	 */
	public void body()
	{
		startAtomic();	// Hack!!! Todo: fix microplanstep semantics in V2
		TestReport	report	= new TestReport("trigger"+no, description);
		int	cnt	= ((Number)getBeliefbase().getBelief("cnt").getFact()).intValue();
		cnt++;
		if(cnt==no)
		{
			report.setSucceeded(true);
		}
		else
		{
			report.setFailed("Wrong execution order: Was "+no+" but should be "+cnt+".");
		}
		getBeliefbase().getBeliefSet("testcap.reports").addFact(report);
		getBeliefbase().getBelief("cnt").setFact(new Integer(cnt));
		endAtomic();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy