Skip to content

Commit

Permalink
New condition : fix issue in control
Browse files Browse the repository at this point in the history
  • Loading branch information
bcivel committed Aug 15, 2024
1 parent e2b8628 commit 8980043
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class TestCaseStepActionControlExecution {
*
*/
private TestCaseStepActionExecution testCaseStepActionExecution;
private TestCaseStepActionControl testCaseStepActionControl;
private List<TestCaseExecutionFile> fileList; // Host the list of the files stored at control level
private MessageEvent controlResultMessage;
private MessageGeneral executionResultMessage;
Expand Down Expand Up @@ -415,6 +416,14 @@ public void setValue3Init(String value3Init) {
this.value3Init = value3Init;
}

public TestCaseStepActionControl getTestCaseStepActionControl() {
return testCaseStepActionControl;
}

public void setTestCaseStepActionControl(TestCaseStepActionControl testCaseStepActionControl) {
this.testCaseStepActionControl = testCaseStepActionControl;
}

/**
* Convert the current TestCaseStepActionControlExecution into JSON format
* Note that if withChilds and withParents are both set to true, only the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public void addTestCaseStepActionExecutionList(List<TestCaseStepActionControlExe

public TestCaseStepActionControlExecution getTestCaseStepActionControlExecutionBySortId(int sortID){
for(TestCaseStepActionControlExecution tcsace : this.testCaseStepActionControlExecutionList){
if (sortID == tcsace.getSort()){
if (sortID == tcsace.getTestCaseStepActionControl().getSort()){
return tcsace;
}
}
Expand All @@ -460,7 +460,7 @@ public TestCaseStepActionControlExecution getTestCaseStepActionControlExecutionB

public TestCaseStepActionControlExecution getTestCaseStepActionControlExecutionByControlId(int sortID){
for(TestCaseStepActionControlExecution tcsace : this.testCaseStepActionControlExecutionList){
if (sortID == tcsace.getControlId()){
if (sortID == tcsace.getTestCaseStepActionControl().getControlId()){
return tcsace;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ public String cleanValue3(String condition, String value3) {
case CONDITIONOPERATOR_IFSTRINGNOTCONTAINS:
case CONDITIONOPERATOR_IFTEXTINELEMENT:
case CONDITIONOPERATOR_IFTEXTNOTINELEMENT:
case CONDITIONOPERATOR_IFCONTROLSTATUSOK:
case CONDITIONOPERATOR_IFCONTROLSTATUSNE:
return value3;
default:
return "";
Expand Down Expand Up @@ -1094,20 +1096,20 @@ private AnswerItem<Boolean> evaluateCondition_ifStepStatusOK(String conditionVal

try {

String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)).getReturnCode();
String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)).getReturnCode();


if (status.equals("OK")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STEPEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STEPEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
);
}
if (status.equals("OK")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STEPEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STEPEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
);
}

} catch (Exception ex){
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_STEPEXECUTIONOK);
Expand All @@ -1124,16 +1126,23 @@ private AnswerItem<Boolean> evaluateCondition_ifStepStatusNE(String conditionVal
AnswerItem<Boolean> ans = new AnswerItem<>();
MessageEvent mes;

String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)).getReturnCode();
try {
String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)).getReturnCode();


if (status.equals("NE")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STEPEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STEPEXECUTIONNE);
if (status.equals("NE")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STEPEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STEPEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
);
}
} catch (Exception ex){
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_STEPEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
);
Expand All @@ -1147,19 +1156,27 @@ private AnswerItem<Boolean> evaluateCondition_ifActionStatusOK(String conditionV
AnswerItem<Boolean> ans = new AnswerItem<>();
MessageEvent mes;

String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1))
.getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2))
.getReturnCode();
try {
String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1))
.getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2))
.getReturnCode();


if (status.equals("OK")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_ACTIONEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_ACTIONEXECUTIONOK);
if (status.equals("OK")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_ACTIONEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_ACTIONEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
);
}
} catch (Exception ex){
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_ACTIONEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
Expand All @@ -1174,19 +1191,27 @@ private AnswerItem<Boolean> evaluateCondition_ifActionStatusNE(String conditionV
AnswerItem<Boolean> ans = new AnswerItem<>();
MessageEvent mes;

String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1))
.getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2))
.getReturnCode();
try {
String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1))
.getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2))
.getReturnCode();


if (status.equals("NE")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_ACTIONEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_ACTIONEXECUTIONNE);
if (status.equals("NE")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_ACTIONEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_ACTIONEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
);
}
} catch (Exception ex){
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_ACTIONEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
Expand All @@ -1201,20 +1226,29 @@ private AnswerItem<Boolean> evaluateCondition_ifControlStatusOK(String condition
AnswerItem<Boolean> ans = new AnswerItem<>();
MessageEvent mes;

String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1))
.getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2))
.getTestCaseStepActionControlExecutionByControlId(Integer.valueOf(conditionValue3))
.getReturnCode();

if (status.equals("OK")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_CONTROLEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
.replace("%STR3%", conditionValue3)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_CONTROLEXECUTIONOK);
try {
String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1))
.getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2))
.getTestCaseStepActionControlExecutionByControlId(Integer.valueOf(conditionValue3))
.getReturnCode();

if (status.equals("OK")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_CONTROLEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
.replace("%STR3%", conditionValue3)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_CONTROLEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
.replace("%STR3%", conditionValue3)
);
}
} catch (Exception ex){
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_CONTROLEXECUTIONOK);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
Expand All @@ -1230,21 +1264,30 @@ private AnswerItem<Boolean> evaluateCondition_ifControlStatusNE(String condition
AnswerItem<Boolean> ans = new AnswerItem<>();
MessageEvent mes;

String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1))
.getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2))
.getTestCaseStepActionControlExecutionByControlId(Integer.valueOf(conditionValue3))
.getReturnCode();


if (status.equals("NE")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_CONTROLEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
.replace("%STR3%", conditionValue3)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_CONTROLEXECUTIONNE);
try {
String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1))
.getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2))
.getTestCaseStepActionControlExecutionByControlId(Integer.valueOf(conditionValue3))
.getReturnCode();


if (status.equals("NE")) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_CONTROLEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
.replace("%STR3%", conditionValue3)
);
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_CONTROLEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
.replace("%STR3%", conditionValue3)
);
}
} catch (Exception ex){
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_CONTROLEXECUTIONNE);
mes.setDescription(mes.getDescription()
.replace("%STR1%", conditionValue1)
.replace("%STR2%", conditionValue2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,7 @@ private TestCaseStepActionExecution executeAction(TestCaseStepActionExecution ac
controlExecution.setDoScreenshotAfter(control.isDoScreenshotAfter());
controlExecution.setWaitBefore(control.getWaitBefore());
controlExecution.setWaitAfter(control.getWaitAfter());
controlExecution.setTestCaseStepActionControl(control);

this.testCaseStepActionControlExecutionService.insertTestCaseStepActionControlExecution(controlExecution, execution.getSecrets());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ public enum MessageEventEnum {
CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_MESSAGETYPE(1220, "FA", "Message type %TYPE% not supported for condition '%CONDITION%'.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_IFNUMERIC_GENERICCONVERSIONERROR(1230, "FA", "Cannot convert %STRINGVALUE% to numeric.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_STEPEXECUTIONOK(1210, "FA", "Mandatory parameter '%STR1%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_ACTIONEXECUTIONOK(1210, "FA", "Mandatory parameter '%STR1%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_CONTROLEXECUTIONOK(1210, "FA", "Mandatory parameter '%STR1%' or '%STR2%' is missing or in a bad format (integer expected), or expected step/action doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_ACTIONEXECUTIONOK(1210, "FA", "Mandatory parameter '%STR1%' or '%STR2%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_CONTROLEXECUTIONOK(1210, "FA", "Mandatory parameter '%STR1%', '%STR2%' or '%STR3%' is missing or in a bad format (integer expected), or expected step/action doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_STEPEXECUTIONNE(1210, "FA", "Mandatory parameter '%STR1%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_ACTIONEXECUTIONNE(1210, "FA", "Mandatory parameter '%STR1%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_CONTROLEXECUTIONNE(1210, "FA", "Mandatory parameter '%STR1%' or '%STR2%' is missing or in a bad format (integer expected), or expected step/action doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_ACTIONEXECUTIONNE(1210, "FA", "Mandatory parameter '%STR1%' or '%STR2%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_CONTROLEXECUTIONNE(1210, "FA", "Mandatory parameter '%STR1%', '%STR2%' or '%STR3%' is missing or in a bad format (integer expected), or expected step/action doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_SELENIUM_CONNECTIVITY(1230, "FA", "Lost connection to Selenium Server! Detailed error : %ERROR%.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_GENERIC(1230, "FA", "Failed to evaluate condition. Detailed error : %ERROR%.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION),
CONDITIONEVAL_FAILED_TEXTINELEMENT(1240, "FA", "%ERRORMESS%", true, true, true, MessageGeneralEnum.EXECUTION_KO),
Expand Down

0 comments on commit 8980043

Please sign in to comment.