package com.example.tests;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;

import com.example.fw.ApplicationManager;

public class TestBase {
	protected static ApplicationManager app;

	@BeforeTest
	public void setUp() throws Exception {
		app = new ApplicationManager();
	}

	@AfterTest
	public void tearDown() throws Exception {
		app.stop();
	}

	@DataProvider
	public Iterator<Object[]> randomValidGroupGenerator() {
		List<Object[]> list = new ArrayList<Object[]>();
		for (int i = 0; i < 5; i++) {
			GroupData group = new GroupData();
			group.name = generateRandomString();
			group.header = generateRandomString();
			group.footer = generateRandomString();
			list.add(new Object[] { group });
		}
		return list.iterator();
	}

	public String generateRandomString() {
		Random rnd = new Random();
		if (rnd.nextInt(3) == 0) {
			return "";
		} else {
			return "test " + rnd.nextInt();
		}
	}
}

@@ -1079,11 +1079,622 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A%09public String generateValidPhoneNumber() %7B%0A%09%09Random rnd = new Random();%0A%09%09String phone = %22%22;%0A%09%09if (rnd.nextBoolean() == true)%0A%09%09%09phone += %22+%22;%0A%09%09phone += rnd.nextInt(10);%0A%09%09if (rnd.nextInt(5) == 0) %7B%0A%09%09%09phone += rnd.nextInt(Integer.MAX_VALUE);%0A%09%09%7D else %7B%0A%09%09%09if (rnd.nextBoolean() == true) %7B%0A%09%09%09%09phone += %22(%22;%0A%09%09%09%09phone += (100 + rnd.nextInt(900)); %0A%09%09%09%09phone += %22)%22;%0A%09%09%09%7D else %7B%0A%09%09%09%09phone += (100 + rnd.nextInt(900));%0A%09%09%09%09phone += %22-%22;%0A%09%09%09%7D%0A%09%09%09phone += (100 + rnd.nextInt(900));%0A%09%09%09phone += %22-%22;%0A%09%09%09phone += (10 + rnd.nextInt(90));%0A%09%09%09phone += %22-%22;%0A%09%09%09phone += (10 + rnd.nextInt(90));%0A%09%09%7D%0A%0A%09%09return phone;%0A%09%7D
 %0A%7D%0A

add String generateValidPhoneNumber()