Search in sources :

Example 26 with SeleniumRobotVariableServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testVariableDereservation.

@Test(groups = { "ut" })
public void testVariableDereservation() throws UnirestException {
    configureMockedVariableServerConnection();
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    List<TestVariable> variables = new ArrayList<>(connector.getVariables().values());
    connector.unreserveVariables(variables);
    // only one dereservation should be called
    PowerMockito.verifyStatic(Unirest.class);
    Unirest.patch(ArgumentMatchers.contains(String.format(SeleniumRobotVariableServerConnector.EXISTING_VARIABLE_API_URL, 2)));
}
Also used : ArrayList(java.util.ArrayList) 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 27 with SeleniumRobotVariableServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testGetTestCaseIdWithoutToken.

/**
 * Check tokens are not added to request when not provided
 * @throws UnirestException
 */
@Test(groups = { "ut" })
public void testGetTestCaseIdWithoutToken() throws UnirestException {
    configureMockedVariableServerConnection();
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    Assert.assertEquals((int) connector.createTestCase("foo"), 3);
    verify(namedTestCaseRequest, never()).header(eq("Authorization"), anyString());
}
Also used : SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 28 with SeleniumRobotVariableServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector 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 29 with SeleniumRobotVariableServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector 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 30 with SeleniumRobotVariableServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testServerActiveAndAlive.

@Test(groups = { "ut" })
public void testServerActiveAndAlive() throws UnirestException {
    configureMockedVariableServerConnection();
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    Assert.assertTrue(connector.getActive());
    Assert.assertEquals(connector.getApplicationId(), 1);
    Assert.assertEquals(connector.getEnvironmentId(), 2);
    Assert.assertEquals((int) connector.createTestCase("Test1"), 3);
    Assert.assertEquals(connector.getVersionId(), 4);
}
Also used : SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

SeleniumRobotVariableServerConnector (com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector)36 ConnectorsTest (com.seleniumtests.ConnectorsTest)34 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)34 Test (org.testng.annotations.Test)34 TestVariable (com.seleniumtests.core.TestVariable)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 HttpRequest (kong.unirest.HttpRequest)2 ScenarioException (com.seleniumtests.customexception.ScenarioException)1 ArrayList (java.util.ArrayList)1 SkipException (org.testng.SkipException)1 BeforeMethod (org.testng.annotations.BeforeMethod)1