package com.ubique.dataobject;

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.testng.annotations.DataProvider;

import au.com.bytecode.opencsv.CSVReader;

public class ResistrationData {
	


	private String firstName;
	private String lastName;
	private String phoneNumber;
	private String userName;
	private String country;
	private String email;
	private String password;
	private String confirmPassword;


	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	
	/**
	 * Test data provider reading data from csv file
	 * 
	 * @return
	 * @throws IOException
	 */
	@DataProvider(name = "regCSVData")
	public static Object[][] getCSVData() throws IOException {
		CSVReader csvReader = new CSVReader(new FileReader(
				ResistrationData.class.getResource("/regdata.csv").getPath()));
		List<String[]>dataList = csvReader.readAll();
		Object[][] data = new Object[dataList.size()][1];
		List<ResistrationData> regList = new ArrayList<ResistrationData>();
		for (String[] strArray:dataList) {
			ResistrationData registrationData2 = new ResistrationData();
			registrationData2.setFirstName(strArray[0].trim());
			registrationData2.setLastName(strArray[1].trim());
			registrationData2.setPhoneNumber(strArray[2].trim());
			registrationData2.setUserName(strArray[3].trim());
			registrationData2.setCountry(strArray[4].trim());
			registrationData2.setEmail(strArray[5].trim());
			registrationData2.setPassword(strArray[6].trim());
			registrationData2.setConfirmPassword(strArray[7].trim());
			regList.add(registrationData2);
		}
		for(int i=0; i<data.length; i++) {
			for(int j=0; j<data[i].length; j++) {
				data[i][j]=regList.get(i);
			}
		}
		csvReader.close();
		return data;
	}

}
