Search in sources :

Example 26 with TestCaseStepActionControlExecution

use of org.cerberus.crud.entity.TestCaseStepActionControlExecution in project cerberus-source by cerberustesting.

the class ControlServiceTest method testVerifyElementEqualsWithNotCompatibleApplication.

// @Ignore
// @Test
// public void testDoControlElementInElementWhenValueIsNotChildOfProperty() {
// String property = "id=parent";
// String value = "id=child";
// String msg = "Element '" + value + "' is not child of element '" + property + "'.";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// Identifier identifierValue = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test2");
// 
// when(webdriverService.isElementInElement(session, identifier, identifierValue)).thenReturn(Boolean.FALSE);
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementInElement");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
// Assert.assertEquals("KO", tcsace.getReturnCode());
// Assert.assertEquals("Y", tcsace.getFatal());
// }
// 
// @Ignore
// @Test
// public void testDoControlElementInElementWhenValueIsChildOfProperty() {
// String property = "id=parent";
// String value = "id=child";
// String msg = "Element '" + value + "' in child of element '" + property + "'.";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// Identifier identifierValue = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test2");
// 
// when(webdriverService.isElementInElement(session, identifier, identifierValue)).thenReturn(Boolean.TRUE);
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementInElement");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
// Assert.assertEquals("OK", tcsace.getReturnCode());
// Assert.assertEquals("Y", tcsace.getFatal());
// }
@Test
public void testVerifyElementEqualsWithNotCompatibleApplication() {
    String xpath = "/foo/bar";
    String expectedElement = "<bar>baz</bar>";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyElementEquals");
    tcsace.setValue1(xpath);
    tcsace.setValue2(expectedElement);
    tcsace.setFatal("Y");
    TestCaseStepExecution tcse = new TestCaseStepExecution();
    tcse.settCExecution(tCExecution);
    TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
    tcsae.setTestCaseStepExecution(tcse);
    tcsace.setTestCaseStepActionExecution(tcsae);
    this.controlService.doControl(tcsace);
    Assert.assertEquals(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION.getCode(), tcsace.getControlResultMessage().getCode());
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) Test(org.junit.Test)

Example 27 with TestCaseStepActionControlExecution

use of org.cerberus.crud.entity.TestCaseStepActionControlExecution in project cerberus-source by cerberustesting.

the class ControlServiceTest method testDoControlElementNotVisibleWhenPropertyNull.

// @Ignore
// @Test
// public void testDoControlElementNotPresentWhenWebDriverException() {
// String property = "id=test";
// String value = "null";
// String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementNotPresent");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// when(webdriverService.isElementPresent(session, identifier)).thenThrow(new WebDriverException());
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg));
// Assert.assertEquals("CA", tcsace.getReturnCode());
// Assert.assertEquals("Y", tcsace.getFatal());
// }
// @Ignore
// @Test
// public void testDoControlElementNotVisibleWhenSuccess() {
// String property = "id=test";
// String value = "null";
// String msg = "Element '" + property + "' is present and not visible on the page.";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementNotVisible");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);
// when(webdriverService.isElementNotVisible(session, identifier)).thenReturn(true);
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
// Assert.assertEquals("OK", tcsace.getReturnCode());
// }
// 
// @Ignore
// @Test
// public void testDoControlElementNotVisibleWhenFail() {
// String property = "id=test";
// String value = "null";
// String msg = "Element '" + property + "' is visible on the page.";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementNotVisible");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);
// when(webdriverService.isElementNotVisible(session, identifier)).thenReturn(false);
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
// Assert.assertEquals("KO", tcsace.getReturnCode());
// Assert.assertEquals("Y", tcsace.getFatal());
// }
@Test
public void testDoControlElementNotVisibleWhenPropertyNull() {
    String property = "null";
    String value = "id=test";
    String msg = "Object is 'null'. This is mandatory in order to perform the control verify element not visible";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyElementNotVisible");
    tcsace.setValue1(property);
    tcsace.setValue2(value);
    tcsace.setFatal("Y");
    TestCaseStepExecution tcse = new TestCaseStepExecution();
    tcse.settCExecution(tCExecution);
    TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
    tcsae.setTestCaseStepExecution(tcse);
    tcsace.setTestCaseStepActionExecution(tcsae);
    this.controlService.doControl(tcsace);
    Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
    Assert.assertEquals("KO", tcsace.getReturnCode());
    Assert.assertEquals("Y", tcsace.getFatal());
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) Test(org.junit.Test)

Example 28 with TestCaseStepActionControlExecution

use of org.cerberus.crud.entity.TestCaseStepActionControlExecution in project cerberus-source by cerberustesting.

the class ControlServiceTest method testDoControlIntegerGreaterWhenSuccess.

@Test
public void testDoControlIntegerGreaterWhenSuccess() {
    String property = "10";
    String value = "5";
    String msg = "'" + property + "' is greater than '" + value + "'.";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyNumericGreater");
    tcsace.setValue1(property);
    tcsace.setValue2(value);
    TestCaseStepExecution tcse = new TestCaseStepExecution();
    tcse.settCExecution(tCExecution);
    TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
    tcsae.setTestCaseStepExecution(tcse);
    tcsace.setTestCaseStepActionExecution(tcsae);
    this.controlService.doControl(tcsace);
    Assert.assertEquals("OK", tcsace.getReturnCode());
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) Test(org.junit.Test)

Example 29 with TestCaseStepActionControlExecution

use of org.cerberus.crud.entity.TestCaseStepActionControlExecution in project cerberus-source by cerberustesting.

the class ControlServiceTest method testDoControlStringDifferentWhenSuccess.

@Test
public void testDoControlStringDifferentWhenSuccess() {
    String property = "test";
    String value = "test success";
    String msg = "'" + property + "' is different from '" + value + "'.";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyStringDifferent");
    tcsace.setValue1(property);
    tcsace.setValue2(value);
    TestCaseStepExecution tcse = new TestCaseStepExecution();
    tcse.settCExecution(tCExecution);
    TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
    tcsae.setTestCaseStepExecution(tcse);
    tcsace.setTestCaseStepActionExecution(tcsae);
    this.controlService.doControl(tcsace);
    Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
    Assert.assertEquals("OK", tcsace.getReturnCode());
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) Test(org.junit.Test)

Example 30 with TestCaseStepActionControlExecution

use of org.cerberus.crud.entity.TestCaseStepActionControlExecution in project cerberus-source by cerberustesting.

the class ControlServiceTest method testDoControlIntegerDifferentWhenFail.

@Test
public void testDoControlIntegerDifferentWhenFail() {
    String property = "5";
    String value = "5";
    String msg = "'" + property + "' is not different from '" + value + "'.";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyNumericDifferent");
    tcsace.setValue1(property);
    tcsace.setValue2(value);
    tcsace.setFatal("Y");
    TestCaseStepExecution tcse = new TestCaseStepExecution();
    tcse.settCExecution(tCExecution);
    TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
    tcsae.setTestCaseStepExecution(tcse);
    tcsace.setTestCaseStepActionExecution(tcsae);
    this.controlService.doControl(tcsace);
    Assert.assertEquals("KO", tcsace.getReturnCode());
    Assert.assertEquals("Y", tcsace.getFatal());
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) Test(org.junit.Test)

Aggregations

TestCaseStepActionControlExecution (org.cerberus.crud.entity.TestCaseStepActionControlExecution)39 TestCaseStepActionExecution (org.cerberus.crud.entity.TestCaseStepActionExecution)29 TestCaseStepExecution (org.cerberus.crud.entity.TestCaseStepExecution)26 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)5 IFactoryTestCaseStepActionControlExecution (org.cerberus.crud.factory.IFactoryTestCaseStepActionControlExecution)5 TestCaseExecutionFile (org.cerberus.crud.entity.TestCaseExecutionFile)4 MessageEvent (org.cerberus.engine.entity.MessageEvent)4 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 AnswerList (org.cerberus.util.answer.AnswerList)3 JSONObject (org.json.JSONObject)3 AnswerItem (org.cerberus.util.answer.AnswerItem)2 Ignore (org.junit.Ignore)2 Gson (com.google.gson.Gson)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 FileItem (org.apache.commons.fileupload.FileItem)1