Search in sources :

Example 6 with ArgumentValue

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()));
}
Also used : ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 7 with ArgumentValue

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 8 with ArgumentValue

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));
}
Also used : ArrayList(java.util.ArrayList) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 9 with ArgumentValue

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 10 with ArgumentValue

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());
}
Also used : RangeDataConfig(com.axway.ats.agent.core.threading.data.config.RangeDataConfig) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Aggregations

ArgumentValue (com.axway.ats.agent.core.action.ArgumentValue)33 BaseTest (com.axway.ats.agent.core.BaseTest)32 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)25 RangeDataConfig (com.axway.ats.agent.core.threading.data.config.RangeDataConfig)2 HashMap (java.util.HashMap)2 FileNamesDataConfig (com.axway.ats.agent.core.threading.data.config.FileNamesDataConfig)1 ListDataConfig (com.axway.ats.agent.core.threading.data.config.ListDataConfig)1 File (java.io.File)1 URL (java.net.URL)1 Pattern (java.util.regex.Pattern)1