use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.
the class Test_FileNamesParameterDataProvider method testGenerateNewValuePerInvocation.
@Test
public void testGenerateNewValuePerInvocation() throws AgentException {
FileNamesParameterDataProvider fileNamesDP = new FileNamesParameterDataProvider("fileNameParam", fileContainers, true, true, ParameterProviderLevel.PER_INVOCATION);
fileNamesDP.initialize();
ArgumentValue arg1 = fileNamesDP.generateNewValuePerInvocation(new ArrayList<ArgumentValue>());
ArgumentValue arg2 = fileNamesDP.generateNewValuePerInvocation(new ArrayList<ArgumentValue>());
ArgumentValue arg3 = fileNamesDP.generateNewValuePerInvocation(new ArrayList<ArgumentValue>());
ArgumentValue arg4 = fileNamesDP.generateNewValuePerInvocation(new ArrayList<ArgumentValue>());
// the files in the target directory are 3 so only the arg1 and arg4 must have the same values
assertTrue(!arg1.getValue().equals(arg2.getValue()));
assertTrue(!arg2.getValue().equals(arg3.getValue()));
assertTrue(!arg3.getValue().equals(arg1.getValue()));
assertTrue(arg1.getValue().equals(arg4.getValue()));
}
use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.
the class Test_FileNamesParameterDataProvider method testFileContainerPercentageUsage_50_50.
@Test
public void testFileContainerPercentageUsage_50_50() throws AgentException {
List<FileContainer> fileContainers = new ArrayList<FileContainer>();
fileContainers.add(new FileContainer(folderName, 50, ".eadme.*"));
fileContainers.add(new FileContainer(folderName, 50, ".*loader.*"));
FileNamesParameterDataProvider fileNamesDP = new FileNamesParameterDataProvider("fileNameParam", fileContainers, false, false, ParameterProviderLevel.PER_THREAD);
fileNamesDP.initialize();
ArgumentValue previousValue = new ArgumentValue("fileNamePart", "read");
List<ArgumentValue> previousValues = new ArrayList<ArgumentValue>();
previousValues.add(previousValue);
Map<String, Integer> valuesMap = new HashMap<String, Integer>();
for (int i = 0; i < 100; i++) {
ArgumentValue generatedValue = fileNamesDP.getValue(previousValues);
String value = (String) generatedValue.getValue();
int occurance = 0;
if (valuesMap.containsKey(value)) {
occurance = valuesMap.get(value);
}
valuesMap.put(value, occurance + 1);
}
assertTrue(valuesMap.size() == 2);
assertTrue(valuesMap.get("classloader.html") == valuesMap.get("readme.html"));
assertTrue(valuesMap.get("classloader.html") == 50);
}
use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.
the class Test_FileNamesParameterDataProvider method perInvocationGenerationRecursive.
@Test
public void perInvocationGenerationRecursive() throws AgentException {
FileNamesParameterDataProvider dataProvider = new FileNamesParameterDataProvider("param1", fileContainers, true, true, ParameterProviderLevel.PER_INVOCATION);
dataProvider.initialize();
ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
assertEquals("param1", generatedValue.getName());
assertTrue(((String) generatedValue.getValue()).matches(".*[\\\\/](classloader|readme|release\\-notes).html"));
String firstValue = (String) generatedValue.getValue();
//make sure new instance is returned for the new invocation
generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
assertEquals("param1", generatedValue.getName());
assertFalse(((String) generatedValue.getValue()).equals(firstValue));
}
use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.
the class Test_FileNamesParameterDataProvider method testFileContainerPercentageUsage_75_25.
@Test
public void testFileContainerPercentageUsage_75_25() throws AgentException {
List<FileContainer> fileContainers = new ArrayList<FileContainer>();
fileContainers.add(new FileContainer(folderName, 75, ".eadme.*"));
fileContainers.add(new FileContainer(folderName, 25, ".*loader.*"));
FileNamesParameterDataProvider fileNamesDP = new FileNamesParameterDataProvider("fileNameParam", fileContainers, false, false, ParameterProviderLevel.PER_THREAD);
fileNamesDP.initialize();
ArgumentValue previousValue = new ArgumentValue("fileNamePart", "read");
List<ArgumentValue> previousValues = new ArrayList<ArgumentValue>();
previousValues.add(previousValue);
Map<String, Integer> valuesMap = new HashMap<String, Integer>();
for (int i = 0; i < 100; i++) {
ArgumentValue generatedValue = fileNamesDP.getValue(previousValues);
String value = (String) generatedValue.getValue();
int occurance = 0;
if (valuesMap.containsKey(value)) {
occurance = valuesMap.get(value);
}
valuesMap.put(value, occurance + 1);
}
assertTrue(valuesMap.size() == 2);
assertTrue(valuesMap.get("classloader.html") == 25);
assertTrue(valuesMap.get("readme.html") == 75);
}
use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.
the class Test_ParameterDataProviderFactory method createIntegerRangeProvider.
@Test
public void createIntegerRangeProvider() throws AgentException {
RangeDataConfig rangeConfig = new RangeDataConfig("param1", 10, 20);
ParameterDataProvider dataProvider = ParameterDataProviderFactory.createDataProvider(rangeConfig);
assertEquals(IntegerRangeParameterDataProvider.class, dataProvider.getClass());
ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
assertEquals("param1", generatedValue.getName());
assertEquals(10, generatedValue.getValue());
}
Aggregations