use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testCreateEnvironmentInError.
@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testCreateEnvironmentInError() throws UnirestException {
SeleniumRobotSnapshotServerConnector connector = configureMockedSnapshotServerConnection();
// reset to be sure it's recreated
connector.setEnvironmentId(null);
HttpRequest<HttpRequest> req = createServerMock("POST", SeleniumRobotSnapshotServerConnector.ENVIRONMENT_API_URL, 200, "{'id': '9'}", "body");
when(req.asString()).thenThrow(UnirestException.class);
connector.createEnvironment();
Assert.assertNull(connector.getEnvironmentId());
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testGetStepReferenceSnapshotInError.
@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testGetStepReferenceSnapshotInError() throws UnirestException, IOException {
SeleniumRobotSnapshotServerConnector connector = configureMockedSnapshotServerConnection();
Integer sessionId = connector.createSession("Session1");
Integer testCaseId = connector.createTestCase("Test 1");
Integer testCaseInSessionId = connector.createTestCaseInSession(sessionId, testCaseId, "Test 1");
Integer testStepId = connector.createTestStep("Step 1", testCaseInSessionId);
Integer stepResultId = connector.recordStepResult(true, "", 1, sessionId, testCaseInSessionId, testStepId);
HttpRequest<HttpRequest> req = createServerMock("GET", String.format("%s%d/", SeleniumRobotSnapshotServerConnector.STEP_REFERENCE_API_URL, stepResultId), 200, createImageFromResource("tu/ffLogo1.png"));
when(req.asBytes()).thenThrow(UnirestException.class);
connector.getReferenceSnapshot(stepResultId);
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testCreateVersionApplicationNull.
// version creation
@Test(groups = { "ut" })
public void testCreateVersionApplicationNull() throws UnirestException {
SeleniumRobotSnapshotServerConnector connector = spy(configureMockedSnapshotServerConnection());
// reset to be sure it's recreated
connector.setApplicationId(null);
connector.createVersion();
// check application has also been created
Assert.assertNotNull(connector.getApplicationId());
Assert.assertNotNull(connector.getVersionId());
Assert.assertEquals((int) connector.getVersionId(), 11);
verify(connector).createApplication();
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testCreateTestCaseInSession.
@Test(groups = { "ut" })
public void testCreateTestCaseInSession() throws UnirestException {
SeleniumRobotSnapshotServerConnector connector = spy(configureMockedSnapshotServerConnection());
Integer sessionId = connector.createSession("Session1");
Integer testCaseId = connector.createTestCase("Test 1");
Integer testCaseInSessionId = connector.createTestCaseInSession(sessionId, testCaseId, "Test 1");
Assert.assertEquals((int) testCaseInSessionId, 15);
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testGetComparisonResultSkipped.
/**
* In case computing errors occur, comparison may return isOkWithSnapshots: null, handle it as "skipped"
*/
@Test(groups = { "ut" })
public void testGetComparisonResultSkipped() throws UnirestException {
SeleniumRobotSnapshotServerConnector connector = spy(configureMockedSnapshotServerConnection());
createServerMock("GET", SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL + "15", 200, "{'testSteps': [], 'completed': true, 'isOkWithSnapshots': null, 'computingError': ['img1: computing error', 'img2: computing error']}");
Integer sessionId = connector.createSession("Session1");
Integer testCaseId = connector.createTestCase("Test 1");
Integer testCaseInSessionId = connector.createTestCaseInSession(sessionId, testCaseId, "Test 1");
StringBuilder errorMessage = new StringBuilder();
int comparisonResult = connector.getTestCaseInSessionComparisonResult(testCaseInSessionId, errorMessage);
Assert.assertEquals(comparisonResult, ITestResult.SKIP);
Assert.assertEquals(errorMessage.toString(), "\"img1: computing error\"\n" + "\"img2: computing error\"");
}
Aggregations