// 29.08.2014 Homework #12

package com.example.tests;

	import static com.example.tests.GroupDataGenerator.*;
	import java.util.*;
	import java.io.*;
	import org.testng.annotations.DataProvider;

	public class GroupDataProvider
	{
		@DataProvider
		public static Iterator<Object[]> randomValidGroupsGenerator()
		{
			return wrapGroupsForDataProvider(generateRandomGroups(5)).iterator();
		}

		public static List<Object[]> wrapGroupsForDataProvider(List<GroupData> pGroups)
		{
			List <Object[]> vList = new ArrayList <Object[]>();
			for(GroupData vGroup: pGroups)
			{
				vList.add(new Object[] {vGroup});
			}
			return vList;
		}

		@DataProvider
		public static Iterator<Object[]> groupsFromCSVFile() throws IOException
		{
			return wrapGroupsForDataProvider(loadGroupsFromCSVFile(new File("Groups.txt"))).iterator();
		}
		
		@DataProvider
		public static Iterator<Object[]> groupsFromXMLFile() throws IOException
		{
			return wrapGroupsForDataProvider(loadGroupsFromXMLFile(new File("Groups.xml"))).iterator();
		}
	}