/** * Creates a job based on the specified Activiti XML classpath resource location and defines a EMR cluster definition. * * @param activitiXmlClasspathResourceName the Activiti XML classpath resource location. * @param parameters the job parameters. * * @return the job. * @throws Exception if any errors were encountered. */ public Job createJobForCreateCluster(String activitiXmlClasspathResourceName, List<Parameter> parameters) throws Exception { return createJobForCreateCluster(activitiXmlClasspathResourceName, parameters, null); }
/** * This method tests the scenario where any other exception other than BpmnError is not re-thrown. */ @Test public void testDelegateCallExceptionNotThrown() throws Exception { List<Parameter> parameters = new ArrayList<>(); executeWithoutLogging(ActivitiRuntimeHelper.class, () -> { // Run a job with Activiti XML that will start cluster. // clusterName is not set as parameter, hence error will occur but will not be re-thrown jobServiceTestHelper.createJobForCreateCluster(ACTIVITI_XML_CREATE_CLUSTER_WITH_CLASSPATH, parameters); }); } }
/** * This method tests the terminate cluster activiti task */ @Test public void testTerminateCluster() throws Exception { List<Parameter> parameters = new ArrayList<>(); Parameter parameter = new Parameter("clusterName", "testCluster1"); parameters.add(parameter); // Run a job with Activiti XML that will start cluster and terminate. Job job = jobServiceTestHelper.createJobForCreateCluster(ACTIVITI_XML_TERMINATE_CLUSTER_WITH_CLASSPATH, parameters); assertNotNull(job); } }
private Map<String, Object> createJob(String clusterName, String dryRun, String contentType, String emrClusterDefinitionOverride) throws Exception { List<Parameter> parameters = new ArrayList<>(); parameters.add(new Parameter("clusterName", clusterName)); parameters.add(new Parameter("dryRun", dryRun)); parameters.add(new Parameter("contentType", contentType)); parameters.add(new Parameter("emrClusterDefinitionOverride", emrClusterDefinitionOverride)); // Run a job with Activiti XML that will start cluster. Job job = jobServiceTestHelper.createJobForCreateCluster(ACTIVITI_XML_CREATE_CLUSTER_WITH_CLASSPATH, parameters); assertNotNull(job); HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult(); return hisInstance.getProcessVariables(); }
@Test public void testCheckCluster() throws Exception { // Run a job with Activiti XML that will start cluster, check status and terminate. Job job = jobServiceTestHelper.createJobForCreateCluster(ACTIVITI_XML_CHECK_CLUSTER_WITH_CLASSPATH, getParameters(true, "", "false")); assertNotNull(job); HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult(); Map<String, Object> variables = hisInstance.getProcessVariables(); //check to be sure fields exist. These should exist whether verbose is set or not assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_ID)); assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_STATUS)); assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_CREATION_TIME)); assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_READY_TIME)); assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_END_TIME)); assertTrue( variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_STATUS_CHANGE_REASON_CODE)); assertTrue( variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_STATUS_CHANGE_REASON_MESSAGE)); }
Job job = jobServiceTestHelper.createJobForCreateCluster(ACTIVITI_XML_CHECK_CLUSTER_AND_RECEIVE_TASK_WITH_CLASSPATH, parameters); assertNotNull(job);