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");
}
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");
}
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");
}
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)));
}
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);
}
Aggregations