Search in sources :

Example 41 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testVariableCreateNewVariable.

@Test(groups = { "ut" })
public void testVariableCreateNewVariable() throws UnirestException {
    configureMockedVariableServerConnection();
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    TestVariable existingVariable = new TestVariable("key", "value");
    TestVariable variable = connector.upsertVariable(existingVariable, true);
    PowerMockito.verifyStatic(Unirest.class);
    Unirest.post(ArgumentMatchers.contains(SeleniumRobotVariableServerConnector.VARIABLE_API_URL));
    Assert.assertEquals(variable.getValue(), "value");
    Assert.assertEquals(variable.getName(), "key");
    Assert.assertEquals(variable.getInternalName(), TestVariable.TEST_VARIABLE_PREFIX + "key");
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 42 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testVariableUpdateExistingVariable.

@Test(groups = { "ut" })
public void testVariableUpdateExistingVariable() throws UnirestException {
    configureMockedVariableServerConnection();
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    TestVariable existingVariable = new TestVariable(12, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key");
    TestVariable variable = connector.upsertVariable(existingVariable, true);
    PowerMockito.verifyStatic(Unirest.class);
    Unirest.patch(ArgumentMatchers.contains(SeleniumRobotVariableServerConnector.VARIABLE_API_URL));
    Assert.assertEquals(variable.getValue(), "value");
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 43 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testVariableUpdateExistingVariableThatDisappeard.

/**
 * issue #429: if variable has been deleted, recreate one
 * @throws UnirestException
 */
@Test(groups = { "ut" })
public void testVariableUpdateExistingVariableThatDisappeard() throws UnirestException {
    configureMockedVariableServerConnection();
    createServerMock(SERVER_URL, "PATCH", String.format(SeleniumRobotVariableServerConnector.EXISTING_VARIABLE_API_URL, 12), 404, "{}");
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    TestVariable existingVariable = new TestVariable(12, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key");
    TestVariable variable = connector.upsertVariable(existingVariable, true);
    // check we tried a PATCH and then create the variable with a POST
    PowerMockito.verifyStatic(Unirest.class);
    Unirest.patch(ArgumentMatchers.contains(SeleniumRobotVariableServerConnector.VARIABLE_API_URL));
    PowerMockito.verifyStatic(Unirest.class);
    Unirest.post(ArgumentMatchers.contains(SeleniumRobotVariableServerConnector.VARIABLE_API_URL));
    Assert.assertEquals(variable.getValue(), "value");
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 44 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testVariableDereservationNullId.

@Test(groups = { "ut" })
public void testVariableDereservationNullId() throws UnirestException {
    configureMockedVariableServerConnection();
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    List<TestVariable> variables = Arrays.asList(new TestVariable("key", "value"));
    connector.unreserveVariables(variables);
    // only one dereservation should be called
    PowerMockito.verifyStatic(Unirest.class, times(0));
    Unirest.patch(ArgumentMatchers.contains(String.format(SeleniumRobotVariableServerConnector.EXISTING_VARIABLE_API_URL, 2)));
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 45 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testVariableUpdateExistingVariableWithNetworkError.

@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testVariableUpdateExistingVariableWithNetworkError() throws UnirestException {
    configureMockedVariableServerConnection();
    HttpRequest<HttpRequest> req = createServerMock(SERVER_URL, "PATCH", String.format(SeleniumRobotVariableServerConnector.EXISTING_VARIABLE_API_URL, 12), 200, "{}");
    when(req.asString()).thenThrow(UnirestException.class);
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    TestVariable existingVariable = new TestVariable(12, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key");
    connector.upsertVariable(existingVariable, true);
}
Also used : HttpRequest(kong.unirest.HttpRequest) TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

TestVariable (com.seleniumtests.core.TestVariable)72 Test (org.testng.annotations.Test)66 GenericTest (com.seleniumtests.GenericTest)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)38 XmlTest (org.testng.xml.XmlTest)34 ConnectorsTest (com.seleniumtests.ConnectorsTest)19 MockitoTest (com.seleniumtests.MockitoTest)19 ITestResult (org.testng.ITestResult)14 HashMap (java.util.HashMap)13 SeleniumRobotVariableServerConnector (com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 SeleniumTestsContext (com.seleniumtests.core.SeleniumTestsContext)7 File (java.io.File)3 ArrayList (java.util.ArrayList)3 JSONObject (kong.unirest.json.JSONObject)3 BrowserExtension (com.seleniumtests.browserfactory.BrowserExtension)2 ConfigReader (com.seleniumtests.core.config.ConfigReader)2 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)2 IOException (java.io.IOException)2 HttpRequest (kong.unirest.HttpRequest)2