How to use checkMaintenanceTime method of org.cerberus.engine.execution.impl.ExecutionCheckService class

Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.ExecutionCheckService.checkMaintenanceTime

Source:ExecutionCheckService.java Github

copy

Full Screen

...64 if (this.checkTestCaseActive(tCExecution.getTestCaseObj())65 && this.checkTestActive(tCExecution.getTestObj())66 && this.checkTestCaseNotManual(tCExecution)67 && this.checkCountry(tCExecution)68 && this.checkMaintenanceTime(tCExecution)) {69 LOG.debug("Execution is checked and can proceed.");70 return new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CHECKINGPARAMETERS);71 }72 } else /**73 * Automatic application connectivity parameter (from database)74 */75 if (this.checkEnvironmentActive(tCExecution.getCountryEnvParam())76 && this.checkRangeBuildRevision(tCExecution)77 && this.checkTargetBuildRevision(tCExecution)78 && this.checkActiveEnvironmentGroup(tCExecution)79 && this.checkTestCaseActive(tCExecution.getTestCaseObj())80 && this.checkTestActive(tCExecution.getTestObj())81 && this.checkCountry(tCExecution)82 && this.checkMaintenanceTime(tCExecution)) {83 LOG.debug("Execution is checked and can proceed.");84 return new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CHECKINGPARAMETERS);85 }86 return message;87 }88 private boolean checkEnvironmentActive(CountryEnvParam cep) {89 if (LOG.isDebugEnabled()) {90 LOG.debug("Checking if environment is active");91 }92 if (cep != null && cep.isActive()) {93 return true;94 }95 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_NOTACTIVE);96 return false;97 }98 private boolean checkTestCaseActive(TestCase testCase) {99 if (LOG.isDebugEnabled()) {100 LOG.debug("Checking if testcase is active");101 }102 if (testCase.getTcActive().equals("Y")) {103 return true;104 }105 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TESTCASE_NOTACTIVE);106 return false;107 }108 private boolean checkTestActive(Test test) {109 if (LOG.isDebugEnabled()) {110 LOG.debug("Checking if test is active");111 }112 if (test.getActive().equals("Y")) {113 return true;114 }115 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TEST_NOTACTIVE);116 message.setDescription(message.getDescription().replace("%TEST%", test.getTest()));117 return false;118 }119 private boolean checkTestCaseNotManual(TestCaseExecution tCExecution) {120 if (LOG.isDebugEnabled()) {121 LOG.debug("Checking if testcase is not MANUAL");122 }123 if (!tCExecution.getManualExecution().equals("Y") && tCExecution.getTestCaseObj().getGroup().equals("MANUAL")) {124 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TESTCASE_ISMANUAL);125 return false;126 }127 return true;128 }129 private boolean checkRangeBuildRevision(TestCaseExecution tCExecution) {130 if (LOG.isDebugEnabled()) {131 LOG.debug("Checking if test can be executed in this build and revision");132 }133 TestCase tc = tCExecution.getTestCaseObj();134 CountryEnvParam env = tCExecution.getCountryEnvParam();135 String tcFromSprint = ParameterParserUtil.parseStringParam(tc.getFromBuild(), "");136 String tcToSprint = ParameterParserUtil.parseStringParam(tc.getToBuild(), "");137 String tcFromRevision = ParameterParserUtil.parseStringParam(tc.getFromRev(), "");138 String tcToRevision = ParameterParserUtil.parseStringParam(tc.getToRev(), "");139 String sprint = ParameterParserUtil.parseStringParam(env.getBuild(), "");140 String revision = ParameterParserUtil.parseStringParam(env.getRevision(), "");141 int dif = -1;142 if (!tcFromSprint.isEmpty() && sprint != null) {143 try {144 if (sprint.isEmpty()) {145 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);146 return false;147 } else {148 dif = this.compareBuild(sprint, tcFromSprint, env.getSystem());149 }150 if (dif == 0) {151 if (!tcFromRevision.isEmpty() && revision != null) {152 if (revision.isEmpty()) {153 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);154 return false;155 } else if (this.compareRevision(revision, tcFromRevision, env.getSystem()) < 0) {156 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);157 return false;158 }159 }160 } else if (dif < 0) {161 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);162 return false;163 }164 } catch (NumberFormatException exception) {165 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_WRONGFORMAT);166 return false;167 } catch (CerberusException ex) {168 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED);169 return false;170 }171 }172 if (!tcToSprint.isEmpty() && sprint != null) {173 try {174 if (sprint.isEmpty()) {175 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);176 return false;177 } else {178 dif = this.compareBuild(tcToSprint, sprint, env.getSystem());179 }180 if (dif == 0) {181 if (!tcToRevision.isEmpty() && revision != null) {182 if (revision.isEmpty()) {183 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);184 return false;185 } else if (this.compareRevision(tcToRevision, revision, env.getSystem()) < 0) {186 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);187 return false;188 }189 }190 } else if (dif < 0) {191 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);192 return false;193 }194 } catch (NumberFormatException exception) {195 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_WRONGFORMAT);196 return false;197 } catch (CerberusException ex) {198 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED);199 return false;200 }201 }202 return true;203 }204 private boolean checkTargetBuildRevision(TestCaseExecution tCExecution) {205 if (LOG.isDebugEnabled()) {206 LOG.debug("Checking target build");207 }208 TestCase tc = tCExecution.getTestCaseObj();209 CountryEnvParam env = tCExecution.getCountryEnvParam();210 String tcSprint = ParameterParserUtil.parseStringParam(tc.getTargetBuild(), "");211 String tcRevision = ParameterParserUtil.parseStringParam(tc.getTargetRev(), "");212 String sprint = ParameterParserUtil.parseStringParam(env.getBuild(), "");213 String revision = ParameterParserUtil.parseStringParam(env.getRevision(), "");214 int dif = -1;215 if (!tcSprint.isEmpty() && sprint != null) {216 try {217 if (sprint.isEmpty()) {218 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);219 return false;220 } else {221 dif = this.compareBuild(sprint, tcSprint, env.getSystem());222 }223 if (dif == 0) {224 if (!tcRevision.isEmpty() && revision != null) {225 if (revision.isEmpty()) {226 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);227 return false;228 } else if (this.compareRevision(revision, tcRevision, env.getSystem()) < 0) {229 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_DIFFERENT);230 return false;231 }232 }233 } else if (dif < 0) {234 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_DIFFERENT);235 return false;236 }237 } catch (NumberFormatException exception) {238 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_WRONGFORMAT);239 return false;240 } catch (CerberusException ex) {241 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED);242 return false;243 }244 }245 return true;246 }247 private boolean checkActiveEnvironmentGroup(TestCaseExecution tCExecution) {248 if (LOG.isDebugEnabled()) {249 LOG.debug("Checking environment " + tCExecution.getCountryEnvParam().getEnvironment());250 }251 TestCase tc = tCExecution.getTestCaseObj();252 if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("QA")) {253 return this.checkRunQA(tc, tCExecution.getEnvironmentData());254 } else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("UAT")) {255 return this.checkRunUAT(tc, tCExecution.getEnvironmentData());256 } else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("PROD")) {257 return this.checkRunPROD(tc, tCExecution.getEnvironmentData());258 } else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("DEV")) {259 return true;260 }261 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_NOTDEFINED);262 message.setDescription(message.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));263 message.setDescription(message.getDescription().replace("%ENVGP%", tCExecution.getEnvironmentDataObj().getGp1()));264 return false;265 }266 private boolean checkRunQA(TestCase tc, String env) {267 if (tc.getActiveQA().equals("Y")) {268 return true;269 }270 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RUNQA_NOTDEFINED);271 message.setDescription(message.getDescription().replace("%ENV%", env));272 return false;273 }274 private boolean checkRunUAT(TestCase tc, String env) {275 if (tc.getActiveUAT().equals("Y")) {276 return true;277 }278 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RUNUAT_NOTDEFINED);279 message.setDescription(message.getDescription().replace("%ENV%", env));280 return false;281 }282 private boolean checkRunPROD(TestCase tc, String env) {283 if (tc.getActivePROD().equals("Y")) {284 return true;285 }286 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RUNPROD_NOTDEFINED);287 message.setDescription(message.getDescription().replace("%ENV%", env));288 return false;289 }290 private boolean checkCountry(TestCaseExecution tCExecution) {291 if (LOG.isDebugEnabled()) {292 LOG.debug("Checking if country is setup for this testcase. " + tCExecution.getTest() + "-" + tCExecution.getTestCase() + "-" + tCExecution.getCountry());293 }294 try {295 testCaseCountryService.findTestCaseCountryByKey(tCExecution.getTest(), tCExecution.getTestCase(), tCExecution.getCountry());296 } catch (CerberusException e) {297 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRY_NOTDEFINED);298 return false;299 }300 return true;301 }302 private int compareBuild(String build1, String build2, String system) throws CerberusException {303 BuildRevisionInvariant b1;304 BuildRevisionInvariant b2;305 try {306 b1 = buildRevisionInvariantService.convert(buildRevisionInvariantService.readByKey(system, 1, build1));307 b2 = buildRevisionInvariantService.convert(buildRevisionInvariantService.readByKey(system, 1, build2));308 } catch (CerberusException e) {309 throw new NumberFormatException();310 }311 if (null == b1 || null == b2) {312 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED));313 }314 return b1.getSeq().compareTo(b2.getSeq());315 }316 private int compareRevision(String rev1, String rev2, String system) {317 try {318 BuildRevisionInvariant r1 = buildRevisionInvariantService.convert(buildRevisionInvariantService.readByKey(system, 2, rev1));319 BuildRevisionInvariant r2 = buildRevisionInvariantService.convert(buildRevisionInvariantService.readByKey(system, 2, rev2));320 return r1.getSeq().compareTo(r2.getSeq());321 } catch (CerberusException e) {322 throw new NumberFormatException();323 }324 }325 private boolean checkMaintenanceTime(TestCaseExecution tCExecution) {326 if (tCExecution.getCountryEnvParam().isMaintenanceAct()) {327 SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");328 String nowDate = sdf.format(new Date());329 try {330 long now = sdf.parse(nowDate).getTime();331 long startMaintenance = sdf.parse(nowDate).getTime();332 long endMaintenance = sdf.parse(nowDate).getTime();333 if (tCExecution.getCountryEnvParam() != null) {334 if (tCExecution.getCountryEnvParam().getMaintenanceStr() != null) {335 startMaintenance = sdf.parse(tCExecution.getCountryEnvParam().getMaintenanceStr()).getTime();336 }337 if (tCExecution.getCountryEnvParam().getMaintenanceStr() != null) {338 endMaintenance = sdf.parse(tCExecution.getCountryEnvParam().getMaintenanceEnd()).getTime();339 }...

Full Screen

Full Screen

checkMaintenanceTime

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.execution.impl.ExecutionCheckService;2import org.cerberus.engine.entity.MessageEvent;3import org.cerberus.crud.entity.TestCaseExecution;4import org.cerberus.crud.entity.TestCaseExecutionQueue;5import org.cerberus.crud.entity.TestCaseExecutionQueueDep;6import org.cerberus.crud.entity.TestCaseExecutionQueueDepList;7import org.cerberus.crud.entity.TestCaseExecutionQueueDepListValue;8import org.cerberus.crud.entity.TestCaseExecutionQueueDepListValueList;9import org.cerberus.crud.entity.TestCaseExecutionQueueDepListValueListValue;10import org.cerberus.crud.entity.TestCaseExecutionQueueDepListValueListValueList;11import org.cerberus.crud.entity.TestCaseExecutionQueueDepParameter;12import org.cerberus.crud.entity.TestCaseExecutionQueueDepParameterList;13import org.cerberus.crud.entity.TestCaseExecutionQueueDepParameterListValue;14import org.cerberus.crud.entity.TestCaseExecutionQueueDepParameterListValueList;15import org.cerberus.crud.entity.TestCaseExecutionQueueDepParameterListValueListValue;16import org.cerberus.crud.entity.TestCaseExecutionQueueDepParameterListValueListValueList;17import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountry;18import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryList;19import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryListValue;20import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryListValueList;21import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryListValueListValue;22import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryListValueListValueList;23import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryProperty;24import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryPropertyList;25import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryPropertyListValue;26import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryPropertyListValueList;27import org.cerberus.crud.entity.TestCaseExecutionQueueDepTestCaseCountryPropertyListValueListValue;28import org.cer

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful