use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class FactoryTestCase method create.
@Override
public TestCase create(String test, String testCase, String description) {
TestCase newTestCase = new TestCase();
newTestCase.setTest(test);
newTestCase.setTestCase(testCase);
newTestCase.setDescription(description);
return newTestCase;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class CountryEnvironmentService method getEnvironmentAvailable.
@Override
public List<String[]> getEnvironmentAvailable(String test, String testCase, String country) {
try {
List<String[]> list = null;
TestCase tc = this.testCaseService.findTestCaseByKey(test, testCase);
if (tc != null) {
list = this.countryEnvironmentParametersDAO.getEnvironmentAvailable(country, tc.getApplication());
}
return list;
} catch (CerberusException ex) {
LOG.warn(ex);
}
return null;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class ExecutionCheckService method checkRangeBuildRevision.
private boolean checkRangeBuildRevision(TestCaseExecution tCExecution) {
if (LOG.isDebugEnabled()) {
LOG.debug("Checking if test can be executed in this build and revision");
}
TestCase tc = tCExecution.getTestCaseObj();
CountryEnvParam env = tCExecution.getCountryEnvParam();
String tcFromSprint = ParameterParserUtil.parseStringParam(tc.getFromBuild(), "");
String tcToSprint = ParameterParserUtil.parseStringParam(tc.getToBuild(), "");
String tcFromRevision = ParameterParserUtil.parseStringParam(tc.getFromRev(), "");
String tcToRevision = ParameterParserUtil.parseStringParam(tc.getToRev(), "");
String sprint = ParameterParserUtil.parseStringParam(env.getBuild(), "");
String revision = ParameterParserUtil.parseStringParam(env.getRevision(), "");
int dif = -1;
if (!tcFromSprint.isEmpty() && sprint != null) {
try {
if (sprint.isEmpty()) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);
return false;
} else {
dif = this.compareBuild(sprint, tcFromSprint, env.getSystem());
}
if (dif == 0) {
if (!tcFromRevision.isEmpty() && revision != null) {
if (revision.isEmpty()) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);
return false;
} else if (this.compareRevision(revision, tcFromRevision, env.getSystem()) < 0) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);
return false;
}
}
} else if (dif < 0) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);
return false;
}
} catch (NumberFormatException exception) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_WRONGFORMAT);
return false;
} catch (CerberusException ex) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED);
return false;
}
}
if (!tcToSprint.isEmpty() && sprint != null) {
try {
if (sprint.isEmpty()) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);
return false;
} else {
dif = this.compareBuild(tcToSprint, sprint, env.getSystem());
}
if (dif == 0) {
if (!tcToRevision.isEmpty() && revision != null) {
if (revision.isEmpty()) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);
return false;
} else if (this.compareRevision(tcToRevision, revision, env.getSystem()) < 0) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);
return false;
}
}
} else if (dif < 0) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);
return false;
}
} catch (NumberFormatException exception) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_WRONGFORMAT);
return false;
} catch (CerberusException ex) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED);
return false;
}
}
return true;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class ExecutionCheckService method checkActiveEnvironmentGroup.
private boolean checkActiveEnvironmentGroup(TestCaseExecution tCExecution) {
if (LOG.isDebugEnabled()) {
LOG.debug("Checking environment " + tCExecution.getCountryEnvParam().getEnvironment());
}
TestCase tc = tCExecution.getTestCaseObj();
if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("QA")) {
return this.checkRunQA(tc, tCExecution.getEnvironmentData());
} else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("UAT")) {
return this.checkRunUAT(tc, tCExecution.getEnvironmentData());
} else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("PROD")) {
return this.checkRunPROD(tc, tCExecution.getEnvironmentData());
} else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("DEV")) {
return true;
}
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_NOTDEFINED);
message.setDescription(message.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));
message.setDescription(message.getDescription().replace("%ENVGP%", tCExecution.getEnvironmentDataObj().getGp1()));
return false;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseCountryPropertiesService method findAllWithDependencies.
@Override
public List<TestCaseCountryProperties> findAllWithDependencies(String test, String testcase, String country) throws CerberusException {
if (parameterService.getParameterBooleanByKey("cerberus_property_countrylevelheritage", "", false)) {
// Heritage is done at property + country level.
List<TestCaseCountryProperties> tccpList = new ArrayList();
List<TestCaseCountryProperties> tccpListPerCountry = new ArrayList();
TestCase mainTC = testCaseService.findTestCaseByKey(test, testcase);
// find all properties of preTests
List<TestCase> tcptList = testCaseService.findTestCaseActiveByCriteria("Pre Testing", mainTC.getApplication(), country);
for (TestCase tcase : tcptList) {
tccpList.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCase(tcase.getTest(), tcase.getTestCase()));
tccpListPerCountry.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCaseCountry(tcase.getTest(), tcase.getTestCase(), country));
}
// find all properties of the used step
List<TestCase> tcList = testCaseService.findUseTestCaseList(test, testcase);
for (TestCase tcase : tcList) {
tccpList.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCase(tcase.getTest(), tcase.getTestCase()));
tccpListPerCountry.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCaseCountry(tcase.getTest(), tcase.getTestCase(), country));
}
// find all properties of the testcase
tccpList.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCase(test, testcase));
tccpListPerCountry.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCaseCountry(test, testcase, country));
// Keep only one property by name
// all properties that are defined for the country are included
HashMap tccpMap = new HashMap();
for (TestCaseCountryProperties tccp : tccpListPerCountry) {
tccpMap.put(tccp.getProperty(), tccp);
}
// the properties exist for the country.
for (TestCaseCountryProperties tccp : tccpList) {
TestCaseCountryProperties p = (TestCaseCountryProperties) tccpMap.get(tccp.getProperty());
if (p == null) {
tccpMap.put(tccp.getProperty(), tccp);
} else if (p.getCountry().compareTo(country) != 0 && tccp.getCountry().compareTo(country) == 0) {
tccpMap.put(tccp.getProperty(), tccp);
}
}
List<TestCaseCountryProperties> result = new ArrayList<TestCaseCountryProperties>(tccpMap.values());
return result;
} else {
// Heritage is done at property + country level.
List<TestCaseCountryProperties> tccpList = new ArrayList();
TestCase mainTC = testCaseService.findTestCaseByKey(test, testcase);
/**
* We load here all the properties countries from all related
* testcases linked with test/testcase The order the load is done is
* important as it will define the priority of each property.
* properties coming from Pre Testing is the lower prio then, the
* property coming from the useStep and then, top priority is the
* property on the test + testcase.
*/
// find all properties of preTests
List<TestCase> tcptList = testCaseService.findTestCaseActiveByCriteria("Pre Testing", mainTC.getApplication(), country);
for (TestCase tcase : tcptList) {
tccpList.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCase(tcase.getTest(), tcase.getTestCase()));
}
// find all properties of the used step
List<TestCase> tcList = testCaseService.findUseTestCaseList(test, testcase);
for (TestCase tcase : tcList) {
tccpList.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCase(tcase.getTest(), tcase.getTestCase()));
}
// find all properties of the testcase
tccpList.addAll(testCaseCountryPropertiesDAO.findListOfPropertyPerTestTestCase(test, testcase));
/**
* We loop here the previous list, keeping by property, the last
* value (top priority). That will define the level to consider
* property on the test. testcase.
*/
HashMap<String, TestCaseCountryProperties> tccpMap1 = new HashMap<String, TestCaseCountryProperties>();
for (TestCaseCountryProperties tccp : tccpList) {
tccpMap1.put(tccp.getProperty(), tccp);
}
/**
* We then loop again in order to keep the selected properties for
* the given country and level found on the previous step by
* property.
*/
List<TestCaseCountryProperties> result = new ArrayList<TestCaseCountryProperties>();
for (TestCaseCountryProperties tccp : tccpList) {
if (tccp.getCountry().equals(country)) {
TestCaseCountryProperties tccp_level = (TestCaseCountryProperties) tccpMap1.get(tccp.getProperty());
if ((tccp_level != null) && (((tccp.getTest().equals("Pre Testing")) && (tccp_level.getTest().equals("Pre Testing"))) || ((tccp.getTest().equals(test)) && (tccp.getTestCase().equals(testcase)) && (tccp_level.getTest().equals(test)) && (tccp_level.getTestCase().equals(testcase))) || ((tccp.getTest().equals(tccp_level.getTest())) && (tccp.getTestCase().equals(tccp_level.getTestCase()))))) {
result.add(tccp);
}
}
}
return result;
}
}
Aggregations