Skip to content

Commit

Permalink
* new options on actions and controls in order to force screenshot be…
Browse files Browse the repository at this point in the history
…fore and after (that avoid the necessary takeScreenshot control)

* new options on actions and controls in order to add a wait in ms before and after (that avoid the necessary wait action). This is to be used with care as Cerberus already wait for an element before interacting with it.
  • Loading branch information
vertigo17 committed Jan 28, 2024
1 parent 1e51eb5 commit 0942cb9
Show file tree
Hide file tree
Showing 25 changed files with 636 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,40 @@ public class TestcaseStepActionDTOV001 {
@ApiModelProperty(position = 17)
private String screenshotFilename;

@JsonView(value = {View.Public.GET.class})
@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 18)
private boolean doScreenshotBefore;

@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 19)
private boolean doScreenshotAfter;

@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 20)
private int waitBefore;

@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 21)
private int waitAfter;

@JsonView(value = {View.Public.GET.class})
@ApiModelProperty(position = 22)
private String usrCreated;

@JsonView(value = {View.Public.GET.class})
@ApiModelProperty(position = 19)
@ApiModelProperty(position = 23)
private String dateCreated;

@JsonView(value = {View.Public.GET.class})
@ApiModelProperty(position = 20)
@ApiModelProperty(position = 24)
private String usrModif;

@JsonView(value = {View.Public.GET.class})
@ApiModelProperty(position = 21)
@ApiModelProperty(position = 25)
private String dateModif;

@Valid
@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 22, required = false)
@ApiModelProperty(position = 26, required = false)
List<TestcaseStepActionControlDTOV001> controls;
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,37 @@ public class TestcaseStepActionControlDTOV001 {

@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 18)
private boolean doScreenshotBefore;

@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 19)
private boolean doScreenshotAfter;

@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 20)
private int waitBefore;

@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 21)
private int waitAfter;

@JsonView(value = {View.Public.GET.class, View.Public.PUT.class, View.Public.POST.class})
@ApiModelProperty(position = 22)
private String screenshotFilename;

@JsonView(value = {View.Public.GET.class})
@ApiModelProperty(position = 19)
@ApiModelProperty(position = 23)
private String usrCreated;

@JsonView(value = {View.Public.GET.class})
@ApiModelProperty(position = 20)
@ApiModelProperty(position = 24)
private String dateCreated;

@JsonView(value = {View.Public.GET.class})
@ApiModelProperty(position = 21)
@ApiModelProperty(position = 25)
private String usrModif;

@JsonView(value = {View.Public.GET.class})
@ApiModelProperty(position = 22)
@ApiModelProperty(position = 26)
private String dateModif;
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public TestCaseStepActionControl findTestCaseStepActionControlByKey(String test,
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);) {

preStat.setString(1, test);
preStat.setString(2, testcase);
Expand Down Expand Up @@ -116,8 +115,7 @@ public List<TestCaseStepActionControl> findControlByTestTestCaseStepIdActionId(S
LOG.debug("SQL.param.actionId : " + actionId);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

preStat.setString(1, test);
preStat.setString(2, testcase);
Expand Down Expand Up @@ -152,8 +150,7 @@ public void insertTestCaseStepActionControl(TestCaseStepActionControl testCaseSt
LOG.debug("SQL : " + query.toString());
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString());) {

int i = 1;
preStat.setString(i++, testCaseStepActionControl.getTest());
Expand Down Expand Up @@ -194,8 +191,7 @@ public List<TestCaseStepActionControl> findControlByTestTestCaseStepId(String te
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

preStat.setString(1, test);
preStat.setString(2, testcase);
Expand Down Expand Up @@ -252,8 +248,7 @@ public void updateTestCaseStepActionControl(TestCaseStepActionControl testCaseSt
LOG.debug("SQL.param.options : " + testCaseStepActionControl.getOptions().toString());
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

int i = 1;
preStat.setString(i++, testCaseStepActionControl.getTest());
Expand Down Expand Up @@ -305,8 +300,7 @@ public void updateApplicationObject(String field, String application, String old
LOG.debug("SQL.param.service " + "%\\%object." + oldObject + ".%");
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

int i = 1;
preStat.setString(i++, application);
Expand All @@ -328,8 +322,7 @@ public void deleteTestCaseStepActionControl(TestCaseStepActionControl tcsac) thr
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {
preStat.setString(1, tcsac.getTest());
preStat.setString(2, tcsac.getTestcase());
preStat.setInt(3, tcsac.getStepId());
Expand Down Expand Up @@ -361,8 +354,7 @@ public List<TestCaseStepActionControl> findControlByTestTestCase(String test, St
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString());) {

preStat.setString(1, test);
preStat.setString(2, testcase);
Expand Down Expand Up @@ -396,15 +388,12 @@ public AnswerList<TestCaseStepActionControl> readByTestTestCase(String test, Str
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());
Statement stm = connection.createStatement();) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString()); Statement stm = connection.createStatement();) {

preStat.setString(1, test);
preStat.setString(2, testcase);

try (ResultSet resultSet = preStat.executeQuery();
ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()");) {
try (ResultSet resultSet = preStat.executeQuery(); ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()");) {
//gets the data
while (resultSet.next()) {
controlList.add(this.loadFromResultSet(resultSet));
Expand Down Expand Up @@ -458,17 +447,14 @@ public AnswerList<TestCaseStepActionControl> readByVarious1(String test, String
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());
Statement stm = connection.createStatement();) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString()); Statement stm = connection.createStatement();) {

preStat.setString(1, test);
preStat.setString(2, testcase);
preStat.setInt(3, stepId);
preStat.setInt(4, actionId);

try (ResultSet resultSet = preStat.executeQuery();
ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()");) {
try (ResultSet resultSet = preStat.executeQuery(); ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()");) {
//gets the data
while (resultSet.next()) {
controlList.add(this.loadFromResultSet(resultSet));
Expand Down Expand Up @@ -524,8 +510,7 @@ public Answer create(TestCaseStepActionControl testCaseStepActionControl) {
LOG.debug("SQL : " + query);
}

try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString())) {
try (Connection connection = databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString())) {
// Prepare and execute query
int i = 1;
preStat.setString(i++, testCaseStepActionControl.getTest());
Expand Down Expand Up @@ -583,12 +568,20 @@ private TestCaseStepActionControl loadFromResultSet(ResultSet resultSet) throws
String value3 = resultSet.getString("Value3");
JSONArray options = SqlUtil.getJSONArrayFromColumn(resultSet, "options");
String description = resultSet.getString("Description");
boolean doScreenshotBefore = resultSet.getBoolean("doScreenshotBefore");
boolean doScreenshotAfter = resultSet.getBoolean("doScreenshotAfter");
int waitBefore = resultSet.getInt("waitBefore");
int waitAfter = resultSet.getInt("waitAfter");
String screenshotFilename = resultSet.getString("screenshotFilename");
String usrCreated = resultSet.getString("UsrCreated");
Timestamp dateCreated = resultSet.getTimestamp("DateCreated");
String usrModif = resultSet.getString("UsrModif");
Timestamp dateModif = resultSet.getTimestamp("DateModif");

return factoryTestCaseStepActionControl.create(test, testcase, stepId, actionId, controlId, sort, conditionOperator, conditionValue1, conditionValue2, conditionValue3, conditionOptions, control, value1, value2, value3, options, isFatal, description, screenshotFilename, usrCreated, dateCreated, usrModif, dateModif);
return factoryTestCaseStepActionControl.create(test, testcase, stepId, actionId, controlId, sort, conditionOperator, conditionValue1, conditionValue2, conditionValue3, conditionOptions,
control, value1, value2, value3,
options, isFatal, description, screenshotFilename,
doScreenshotBefore, doScreenshotAfter, waitBefore, waitAfter,
usrCreated, dateCreated, usrModif, dateModif);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public TestCaseStepAction readByKey(String test, String testcase, int stepId, in
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {

preStat.setString(1, test);
preStat.setString(2, testcase);
Expand Down Expand Up @@ -112,8 +111,7 @@ public List<TestCaseStepAction> findActionByTestTestCaseStep(String test, String
LOG.debug("SQL.param.stepId : " + stepId);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

preStat.setString(1, test);
preStat.setString(2, testcase);
Expand Down Expand Up @@ -148,8 +146,7 @@ public AnswerList<TestCaseStepAction> readByTestTestCase(String test, String tes
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString())) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString())) {

try {
preStat.setString(1, test);
Expand Down Expand Up @@ -230,8 +227,7 @@ public AnswerList<TestCaseStepAction> readByVarious1(String test, String testcas
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString());) {

preStat.setString(1, test);
preStat.setString(2, testcase);
Expand Down Expand Up @@ -312,8 +308,7 @@ public void createTestCaseStepAction(TestCaseStepAction testCaseStepAction) thro
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString());) {

int i = 1;
preStat.setString(i++, testCaseStepAction.getTest());
Expand Down Expand Up @@ -378,8 +373,7 @@ public void update(TestCaseStepAction testCaseStepAction) throws CerberusExcepti
LOG.debug("SQL.param.options " + testCaseStepAction.getOptions().toString());
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

int i = 1;
preStat.setString(i++, testCaseStepAction.getTest());
Expand Down Expand Up @@ -427,8 +421,7 @@ public void updateService(String oldService, String service) throws CerberusExce
LOG.debug("SQL.param.service " + service);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

int i = 1;
preStat.setString(i++, service);
Expand All @@ -455,8 +448,7 @@ public void updateApplicationObject(String field, String application, String old
LOG.debug("SQL.param.service " + "%\\%object." + oldObject + ".%");
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

int i = 1;
preStat.setString(i++, application);
Expand All @@ -478,8 +470,7 @@ public void delete(TestCaseStepAction tcsa) throws CerberusException {
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

preStat.setString(1, tcsa.getTest());
preStat.setString(2, tcsa.getTestcase());
Expand All @@ -506,8 +497,7 @@ public boolean changeTestCaseStepActionActionId(String test, String testcase, in
LOG.debug("SQL : " + query);
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query);) {
try (Connection connection = this.databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query);) {

preStat.setInt(1, newActionId);
preStat.setString(2, test);
Expand Down Expand Up @@ -538,8 +528,7 @@ public Answer create(TestCaseStepAction testCaseStepAction) {
LOG.debug("SQL : " + query);
}

try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString())) {
try (Connection connection = databaseSpring.connect(); PreparedStatement preStat = connection.prepareStatement(query.toString())) {
// Prepare and execute query
int i = 1;
preStat.setString(i++, testCaseStepAction.getTest());
Expand Down Expand Up @@ -596,15 +585,20 @@ private TestCaseStepAction loadFromResultSet(ResultSet resultSet) throws SQLExce
String description = resultSet.getString("tca.description");
String screenshotFilename = resultSet.getString("tca.screenshotFilename");
boolean isFatal = resultSet.getBoolean("tca.isFatal");
boolean doScreenshotBefore = resultSet.getBoolean("tca.doScreenshotBefore");
boolean doScreenshotAfter = resultSet.getBoolean("tca.doScreenshotAfter");
int waitBefore = resultSet.getInt("tca.waitBefore");
int waitAfter = resultSet.getInt("tca.waitAfter");
String usrCreated = resultSet.getString("tca.UsrCreated");
Timestamp dateCreated = resultSet.getTimestamp("tca.DateCreated");
String usrModif = resultSet.getString("tca.UsrModif");
Timestamp dateModif = resultSet.getTimestamp("tca.DateModif");

return factoryTestCaseStepAction.create(test, testcase, stepId, actionId, sort, conditionOperator,
conditionValue1, conditionValue2, conditionValue3, conditionOptions, action, value1,
value2, value3, options, isFatal, description, screenshotFilename, usrCreated, dateCreated,
usrModif, dateModif);
value2, value3, options, isFatal, description, screenshotFilename,
doScreenshotBefore, doScreenshotAfter, waitBefore, waitAfter,
usrCreated, dateCreated, usrModif, dateModif);
}

}
Loading

0 comments on commit 0942cb9

Please sign in to comment.