Created
May 21, 2013 14:11
-
-
Save pluto-atom-4/5620083 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package local.example.testng; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.List; | |
import org.testng.Reporter; | |
import org.testng.annotations.DataProvider; | |
import local.example.common.Props; | |
import local.example.order.OrderInformation; | |
public class OrderInformationProvider { | |
private static String listFilePath; | |
public static void setListFilePath(String listFilePath){ | |
OrderInformationProvider.listFilePath = listFilePath; | |
Reporter.log("[INFO] List File" + listFilePath, true); | |
} | |
// This function will provide a order information | |
@DataProvider(name = Props.DP_SINGLE_ORDER_INFO) | |
public static Iterator<Object[]> singleOrderPreference() throws IOException { | |
String filePath = System.getProperty(Props.ORDER_INFO_DIR) + Props.FILE_SEPARATOR + System.getProperty(Props.ORDER_INFO_FILE); | |
List<Object[]> dataToBeReturned = new ArrayList<Object[]>(); | |
OrderInformation info = OrderInformation.load(filePath); | |
dataToBeReturned.add(new Object[] {info}); | |
return dataToBeReturned.iterator(); | |
} | |
// This function will provide multiple order references | |
@DataProvider(name = Props.DP_MULTI_ORDER_INFO) | |
public static Iterator<Object[]> orderReferenceProvider() throws IOException { | |
List<String> orderList = FileListProvider.getFileList(listFilePath); | |
List<Object[]> dataToBeReturned = new ArrayList<Object[]>(); | |
for (String orderInformationFileName : orderList) { | |
OrderInformation info = OrderInformation.load(orderInformationFileName); | |
dataToBeReturned.add(new Object[] {info}); | |
} | |
return dataToBeReturned.iterator(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment