Search in sources :

Example 21 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_ListParameterDataProvider method whenRangeEndIsReachedProviderGoesBackToRangeStart.

@Test
public void whenRangeEndIsReachedProviderGoesBackToRangeStart() {
    List<String> values = new ArrayList<String>();
    for (int i = 10; i < 15; i++) {
        values.add("value" + i);
    }
    ListParameterDataProvider dataProvider = new ListParameterDataProvider("param1", values, ParameterProviderLevel.PER_INVOCATION);
    ArgumentValue generatedValue;
    for (int i = 10; i < 15; i++) {
        generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
        assertEquals("param1", generatedValue.getName());
        assertEquals("value" + i, generatedValue.getValue());
    }
    //make sure only one instance per thread is returned
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("value10", generatedValue.getValue());
}
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 22 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_StringRangeParameterDataProvider method perInvocationGeneration.

@Test
public void perInvocationGeneration() {
    StringRangeParameterDataProvider dataProvider = new StringRangeParameterDataProvider("param1", "user{0}@test.com", 10, 20, ParameterProviderLevel.PER_INVOCATION);
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("user10@test.com", generatedValue.getValue());
    //make sure only one instance per thread is returned
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("user11@test.com", generatedValue.getValue());
}
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 23 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_StringRangeParameterDataProvider method whenRangeEndIsReachedProviderGoesBackToRangeStart.

@Test
public void whenRangeEndIsReachedProviderGoesBackToRangeStart() {
    StringRangeParameterDataProvider dataProvider = new StringRangeParameterDataProvider("param1", "user{0}@test.com", 10, 14, ParameterProviderLevel.PER_INVOCATION);
    ArgumentValue generatedValue;
    for (int i = 10; i < 15; i++) {
        generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
        assertEquals("param1", generatedValue.getName());
        assertEquals("user" + i + "@test.com", generatedValue.getValue());
    }
    //make sure only one instance per thread is returned
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("user10@test.com", generatedValue.getValue());
}
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 24 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_StringRangeParameterDataProvider method initialize.

@Test
public void initialize() throws AgentException {
    StringRangeParameterDataProvider dataProvider = new StringRangeParameterDataProvider("param1", "user{0}@test.com", 10, 20, ParameterProviderLevel.PER_INVOCATION);
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("user10@test.com", generatedValue.getValue());
    dataProvider.initialize();
    //make sure only one instance per thread is returned
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("user10@test.com", generatedValue.getValue());
}
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 25 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_StringRangeParameterDataProvider method perThreadStaticGeneration.

@Test
public void perThreadStaticGeneration() {
    StringRangeParameterDataProvider dataProvider = new StringRangeParameterDataProvider("param1", "user{0}@test.com", 10, 20, ParameterProviderLevel.PER_THREAD_STATIC);
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("user10@test.com", generatedValue.getValue());
    //make sure only one instance per thread is returned
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("user10@test.com", generatedValue.getValue());
}
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)

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