@Test public void testGetJobNames() { List<String> jobNames = new ArrayList<>(); jobNames.add("job1"); jobNames.add("job2"); when(jobExplorer.getJobNames()).thenReturn(jobNames); Set<String> result = jsrJobOperator.getJobNames(); assertEquals(2, result.size()); assertTrue(result.contains("job1")); assertTrue(result.contains("job2")); }
public List<String> getJobNames() throws JobSecurityException { return new ArrayList<String>(jobOp.getJobNames()); }
@Override public String[] getJobNames() { final Set<String> jobNames = operator.getJobNames(); return jobNames.toArray(new String[jobNames.size()]); }
@GET @Path("job-names") public String[] getJobNames() { final Set<String> jobNames = operator.getJobNames(); return jobNames.toArray(new String[jobNames.size()]); }
private void listJobs(final HttpServletRequest req) throws ServletException, IOException { final Set<String> names = new HashSet<String>(appBatches); final Set<String> registered = operator.getJobNames(); if (registered != null) { names.addAll(registered); } req.setAttribute("view", "jobs"); req.setAttribute("names", names); }
@Override public Set<String> getJobNames() throws JobSecurityException { return getDelegate().getJobNames(); }
@Override public Set<String> getJobNames() throws JobSecurityException { Transaction tran = suspendTran(); try { return jobOperator.getJobNames(); } finally { resumeTran(tran); } }
@Override public void execute() throws MojoExecutionException, MojoFailureException { final Set<String> names = getOrCreateOperator().getJobNames(); getLog().info("Job names (" + names.size() + "):"); for (final String name : names) { getLog().info(" - " + name); } } }
@GET @Path("/jobs") @Produces(MediaType.APPLICATION_JSON) public Response listBatchJobs() { try { final List<JobExecutionEntity> executionEntities = new ArrayList<>(); final JobOperator jobOperator = BatchRuntime.getJobOperator(); final Set<String> names = jobOperator.getJobNames(); for (String name : names) { final int end = jobOperator.getJobInstanceCount(name); final List<JobInstance> jobInstances = jobOperator.getJobInstances(name, 0, end); for (JobInstance jobInstance : jobInstances) { final List<JobExecution> executions = jobOperator.getJobExecutions(jobInstance); for (JobExecution execution : executions) { executionEntities.add(JobExecutionEntity.create(execution)); } } } return Response.ok("{ \"jobs\": \n" + mapper.writeValueAsString(executionEntities) + "\n}").build(); } catch (Exception e) { return Response.ok(EMPTY_JSON_LIST).build(); } }
private List<JobExecution> findJobExecutions() throws JobSecurityException, NoSuchJobException, NoSuchJobInstanceException { List<JobExecution> jobExecutions = new ArrayList<>(); JobOperator jobOperator = AbstractListCommand.getJobOperatorFromBatchRuntime(); if (jobName != null) { List<JobInstance> exe = jobOperator.getJobInstances(jobName, 0, Integer.MAX_VALUE - 1); if (exe != null) { for (JobInstance ji : exe) { jobExecutions.addAll(jobOperator.getJobExecutions(ji)); } } } else { Set<String> jobNames = jobOperator.getJobNames(); if (jobNames != null) { for (String jn : jobOperator.getJobNames()) { List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1); if (exe != null) { for (JobInstance ji : exe) { jobExecutions.addAll(jobOperator.getJobExecutions(ji)); } } } } } return jobExecutions; }
private static List<JobExecution> getJobExecutionForInstance(long instId) throws JobSecurityException, NoSuchJobException, NoSuchJobInstanceException, NoSuchJobExecutionException { JobOperator jobOperator = AbstractListCommand.getJobOperatorFromBatchRuntime(); JobInstance jobInstance = null; for (String jn : jobOperator.getJobNames()) { List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1); if (exe != null) { for (JobInstance ji : exe) { if (ji.getInstanceId() == instId) { jobInstance = ji; break; } } } } List<JobExecution> jeList = new ArrayList<JobExecution>(); if (jobInstance == null) throw new RuntimeException("No Job Executions found for instanceid = " + instId); List<JobExecution> lst = AbstractListCommand.getJobOperatorFromBatchRuntime().getJobExecutions(jobInstance); if (lst != null) { for (JobExecution je : lst) { jeList.add(jobOperator.getJobExecution(je.getExecutionId())); } } return jeList; }
Set<String> jobNames = jobOperator.getJobNames(); if (jobNames != null) { for (String jn : jobOperator.getJobNames()) { List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1); if (exe != null) {
/** * */ @Test public void testGetJobNamesNoTran() throws Exception { final JobOperator mockJobOperator = mockery.mock(JobOperator.class); final TransactionManager mockTranMgr = mockery.mock(TransactionManager.class); final Set<String> retMe = new HashSet<String>(); mockery.checking( new Expectations() { { oneOf(mockTranMgr).suspend(); will(returnValue(null)); oneOf(mockJobOperator).getJobNames(); will(returnValue(retMe)); } }); assertEquals( retMe, buildJobOperator(mockJobOperator, mockTranMgr).getJobNames() ); }
/** * */ @Test(expected = IllegalArgumentException.class) public void testGetJobNamesFail() throws Exception { final JobOperator mockJobOperator = mockery.mock(JobOperator.class); final TransactionManager mockTranMgr = mockery.mock(TransactionManager.class); final Transaction mockTran = mockery.mock(Transaction.class); mockery.checking( new Expectations() { { oneOf(mockTranMgr).suspend(); will(returnValue(mockTran)); oneOf(mockJobOperator).getJobNames(); will(throwException(new IllegalArgumentException())); oneOf(mockTranMgr).resume(mockTran); } }); buildJobOperator(mockJobOperator, mockTranMgr).getJobNames(); }
/** * */ @Test public void testGetJobNames() throws Exception { final JobOperator mockJobOperator = mockery.mock(JobOperator.class); final TransactionManager mockTranMgr = mockery.mock(TransactionManager.class); final Transaction mockTran = mockery.mock(Transaction.class); final Set<String> retMe = new HashSet<String>(); mockery.checking( new Expectations() { { oneOf(mockTranMgr).suspend(); will(returnValue(mockTran)); oneOf(mockJobOperator).getJobNames(); will(returnValue(retMe)); oneOf(mockTranMgr).resume(mockTran); } }); assertEquals( retMe, buildJobOperator(mockJobOperator, mockTranMgr).getJobNames() ); }