private void undeploy(Deployment.Environment environment, String botId, Integer version) { Callable<Void> undeployBot = () -> { try { botFactory.undeployBot(environment, botId, version); deploymentStore.setDeploymentInfo(environment.toString(), botId, version, DeploymentStatus.undeployed); } catch (ServiceException e) { throwError(botId, version, e, "Error while undeploying bot! (botId=%s , version=%s)"); } catch (IllegalAccessException e) { return throwErrorForbidden(botId, version, e); } catch (Exception e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(e.getLocalizedMessage(), e); } return null; }; SystemRuntime.getRuntime().submitCallable(undeployBot, ThreadContext.getResources()); }
private void deploy(final Deployment.Environment environment, final String botId, final Integer version, final Boolean autoDeploy) { Callable<Void> deployBot = () -> { try { if (EnumSet.of(Status.NOT_FOUND, Status.ERROR).contains(checkDeploymentStatus(environment, botId, version))) { botFactory.deployBot(environment, botId, version, status -> { if (status == Status.READY && autoDeploy) { deploymentStore.setDeploymentInfo(environment.toString(), botId, version, DeploymentStatus.deployed); } }); } } catch (ServiceException e) { throwError(botId, version, e, "Error while deploying bot! (botId=%s , version=%s)"); } catch (IllegalAccessException e) { throwErrorForbidden(botId, version, e); } catch (Exception e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(e.getLocalizedMessage(), e); } return null; }; SystemRuntime.getRuntime().submitCallable(deployBot, ThreadContext.getResources()); }
public void executeTestCase(final String id, final TestCase testCase) { SystemRuntime.getRuntime().submitCallable((Callable<Void>) () -> { try { testCaseStore.setTestCaseState(id, TestCaseState.IN_PROGRESS); if (!isBotDeployed(testCase.getBotId(), testCase.getBotVersion())) { deployBot(testCase.getBotId(), testCase.getBotVersion()); } ConversationMemorySnapshot actual = runTestCase(testCase.getBotId(), testCase); testCase.setActual(actual); testCase.setLastRun(new Date(System.currentTimeMillis())); testCase.setTestCaseState(testCase.getExpected().equals(testCase.getActual()) ? TestCaseState.SUCCESS : TestCaseState.FAILED); testCaseStore.storeTestCase(id, testCase); } catch (Exception e) { testCaseStore.setTestCaseState(id, TestCaseState.ERROR); throw e; } return null; }, ThreadContext.getResources()); }