/**@generated
 * WARNING ? Changes you make to this file may be lost.
 *           File is generated and may be re-generated without warning.
 */
package test;

import com.ibm.rational.test.lt.datacorrelation.execution.action.VariableAction;
import com.ibm.rational.test.lt.datacorrelation.execution.harvest.DataCorrelationVar;
import com.ibm.rational.test.lt.datacorrelation.execution.harvest.DataVar;
import com.ibm.rational.test.lt.datacorrelation.execution.harvest.IDCCoreVar;
import com.ibm.rational.test.lt.datacorrelation.execution.harvest.IDataCorrelationVar;
import com.ibm.rational.test.lt.datacorrelation.execution.proto.ProtoAdapterHandler;
import com.ibm.rational.test.lt.kernel.IDataArea;
import com.ibm.rational.test.lt.kernel.action.IContainer;
import com.ibm.rational.test.lt.kernel.action.impl.KAction;
import com.ibm.rational.test.lt.kernel.custom.ICustomCode2;
import com.ibm.rational.test.lt.kernel.services.RPTCustomCodeVPFailureEvent;

public class Snoop_Test_A1DE78512E96EA60F168B43762373037 extends com.ibm.rational.test.lt.execution.core.impl.LTTestScript  {

    static ProtoAdapterHandler pa = new ProtoAdapterHandler();
    static {           
        pa.addPA("com.ibm.rational.test.lt.datacorrelation.execution.protocol.core.CoreProtoAdapter", "coreAdapter");
    }
	private IDataCorrelationVar[] dcVars = DataCorrelationVar.getArrayDCVars(1);
	private DataVar[] vars = new DataVar[4];
	
	
    
	
	
	public Snoop_Test_A1DE78512E96EA60F168B43762373037(IContainer container, String invocationId) {
		super(container, "Snoop", invocationId, "A1DE78512E96EA60F168B43762373037");
		setArmEnabled(false);
			if (!isScheduleRun()) setThinkMax(2000);
	
		
		      this.add(varAction_1(this)); /* GENERIC CREATE TEMPLATE */

	this.add(new CustomCode_1(this, dcVars[0]));
	}

	private VariableAction varAction_1(final IContainer parent) {

	VariableAction vc = new VariableAction(parent, "A1DE78512EA06051F168B43762373037");	
			vars[0] = new DataVar("hostname", "thejudge", IDataArea.TEST, "IGNORE");
	vc.add(vars[0]);
	
		vars[1] = new DataVar("url", "/snoop", IDataArea.TEST, "IGNORE");
	vc.add(vars[1]);
	
		vars[2] = new DataVar("port", "9080", IDataArea.TEST, "IGNORE");
	vc.add(vars[2]);
	
		vars[3] = new DataVar("connections", "1", IDataArea.TEST, "IGNORE");
	vc.add(vars[3]);
		
	return vc;
	
}

	public class CustomCode_1 extends KAction {

		private IDataCorrelationVar outVar;
		
		
			/**
		 * @param parent
		 * @param name
		 */
		public CustomCode_1(IContainer parent, IDataCorrelationVar outVar) {
			super(parent, "test.CCBlast", "A1DE78515A3684A0F168B43762373037");
			this.outVar = outVar;
		}
	
		/**
		 * @see com.ibm.rational.test.lt.kernel.action.IKAction#execute()
		 */
		public void execute() {
		
				
	
	
			IDCCoreVar[] inputVars = {
				vars[0],
vars[1],
vars[2],
vars[3]
			};
			String[] inputs = new String[inputVars.length];
			for ( int idx=0; idx<inputVars.length; idx++ ) {
				if ( inputVars[idx] != null ){
					Object obj = inputVars[idx].getValue();
					if (obj == null) inputs[idx] = null;
					else inputs[idx] = obj.toString();
				}else
					inputs[idx] = "";
	
			}
			
				ICustomCode2 userCustom_1 = new test.CCBlast();
			String usrCustomRtn = 	userCustom_1.exec(this, inputs);

			
			if (getNonPassingVPReported()) {
				registerEvent(new RPTCustomCodeVPFailureEvent(), null);
			}
			
			outVar.setValue(usrCustomRtn);
			outVar.setType(IDCCoreVar.CUSTOMCODE);
	
			finish();
		}
	}



}
