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

jadex.bdi.testcases.goals.GoalRegressionTestPlan Maven / Gradle / Ivy

Go to download

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

The newest version!
package jadex.bdi.testcases.goals;

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

/**
 *  This plan checks goal info events, if goal processing
 *  was as expected.
 *  The expected results of goal processing are read from
 *  special goal parameters (test_state, test_process_states).
 */
public class GoalRegressionTestPlan extends Plan
{
	//-------- methods --------

	/**
	 *  The plan body.
	 */
	public void body()
	{
		IGoal	goal	= (IGoal)getReason();
		Boolean	state	= (Boolean)goal.getParameter("test_state").getValue();
//		boolean[]	pstates	= (boolean[])goal.getParameter("test_process_states").getValue();
		String 	errors	= "";
		TestReport	report	= new TestReport(""+goal, "Test execution of goal "+goal);

		// Check state.
		if(state!=null && !goal.isSucceeded()==state.booleanValue())
		{
			errors	+=	"State was "+goal.isSucceeded()+" should be "+state+".\n";
		}

		// Check process states.
		/*if(pstates!=null)
		{
			RGoal	rgoal	= (RGoal)((ElementWrapper)goal).unwrap();
			ApplicableCandidateList	apl	= rgoal.getApplicableCandidateList();
			Object[]	hes	= apl.getExecutedCandidates().toArray(new ICandidateInfo[0]);
			// Todo: How to access execution results of single plans?
//			IHistoryEntry[]	hes	= goal.getHistoryEntries();
			if(hes.length==pstates.length)
			{
//				for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy