package test;


import java.util.Date;
import java.util.Random;


import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;

/**
 * @author unknown
 */
public class GenerateUserRegistrationData implements
		com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {
	static Random random = new Random();
	static Random random2 = new Random();
	private Date date = null;
	
	/**
	 * Instances of this will be created using the no-arg constructor.
	 */
	public GenerateUserRegistrationData() {
	}

	/**
	 * For javadoc of ICustomCode2 and ITestExecutionServices interfaces, select 'Help Contents' in the
	 * Help menu and select 'Extending Rational Performance Tester functionality' -> 'Extending test execution with custom code'
	 */
	public String exec(ITestExecutionServices tes, String[] args) {
		String num_users = args[0];
		int num_u = Integer.parseInt(num_users);

	    date = new Date();
		String stNoSpaceDate="";


		stNoSpaceDate = Long.toString(date.getTime());
 
		// Generate data to register a new user 		
        String name = "first:" + String.valueOf(random.nextInt(999))+ "last:" + String.valueOf(random.nextInt(4999));
        String add = String.valueOf(random.nextInt(4999)) + "mystreet";        
        String uid = "ru:" + String.valueOf(random.nextInt(num_u)) + ":"  + stNoSpaceDate + String.valueOf(random.nextInt(99));
        
        String email = uid + "@" + String.valueOf(random.nextInt(99)) + ".com" ;

  		String RegisterData = "Full+Name=" +name+ "&snail+mail=" +add+ "&email=" +email+ "&user+id=" +uid+ "&passwd=yyy&confirm+passwd=yyy&money=1000000&Credit+Card+Number=123-fake-ccnum-456&action=register";  		
		return RegisterData;

	}

}