@Test public void testJobComplete() { AsyncJob<?> job = AsyncJob.builder().id("100") .status(Status.SUCCEEDED).resultCode(ResultCode.SUCCESS).build(); expect((Object) asyncJobClient.getAsyncJob(job.getId())).andReturn(job); replay(client, asyncJobClient); assertTrue(new JobComplete(client).apply(job.getId())); verify(client, asyncJobClient); }
public boolean apply(String jobId) { logger.trace(">> looking for status on job %s", checkNotNull(jobId, "jobId")); AsyncJob<?> job = refresh(jobId); if (job == null) { return false; } logger.trace("%s: looking for job status %s: currently: %s", job.getId(), 1, job.getStatus()); if (job.hasFailed()) { throw new AsyncJobException(String.format("job %s failed with exception %s", job.toString(), job.getError().toString())); } return job.hasSucceed(); }
@Test public void testJobComplete() { AsyncJob<?> job = AsyncJob.builder().id("100") .status(Status.SUCCEEDED).resultCode(ResultCode.SUCCESS).build(); expect((Object) asyncJobClient.getAsyncJob(job.getId())).andReturn(job); replay(client, asyncJobClient); assertTrue(new JobComplete(client).apply(job.getId())); verify(client, asyncJobClient); }
@Test(enabled = true) public void testListAsyncJobs() throws Exception { Set<AsyncJob<?>> response = client.getAsyncJobClient().listAsyncJobs(); assert null != response; long asyncJobCount = response.size(); assertTrue(asyncJobCount >= 0); for (AsyncJob<?> asyncJob : response) { assert asyncJob.getCmd() != null : asyncJob; assert asyncJob.getUserId() != null : asyncJob; checkJob(asyncJob); AsyncJob<?> query = client.getAsyncJobClient().getAsyncJob(asyncJob.getId()); assertEquals(query.getId(), asyncJob.getId()); assert query.getResultType() != null : query; checkJob(query); } }
public boolean apply(String jobId) { logger.trace(">> looking for status on job %s", checkNotNull(jobId, "jobId")); AsyncJob<?> job = refresh(jobId); if (job == null) { return false; } logger.trace("%s: looking for job status %s: currently: %s", job.getId(), 1, job.getStatus()); if (job.hasFailed()) { throw new AsyncJobException(String.format("job %s failed with exception %s", job.toString(), job.getError().toString())); } return job.hasSucceed(); }
public boolean apply(String jobId) { logger.trace(">> looking for status on job %s", checkNotNull(jobId, "jobId")); AsyncJob<?> job = refresh(jobId); if (job == null) { return false; } logger.trace("%s: looking for job status %s: currently: %s", job.getId(), 1, job.getStatus()); if (job.hasFailed()) { throw new AsyncJobException(String.format("job %s failed with exception %s", job.toString(), job.getError().toString())); } return job.hasSucceed(); }
@Test(enabled = true) public void testListAsyncJobs() throws Exception { Set<AsyncJob<?>> response = client.getAsyncJobApi().listAsyncJobs(); assert null != response; long asyncJobCount = response.size(); assertTrue(asyncJobCount >= 0); for (AsyncJob<?> asyncJob : response) { assert asyncJob.getCmd() != null : asyncJob; assert asyncJob.getUserId() != null : asyncJob; checkJob(asyncJob); AsyncJob<?> query = client.getAsyncJobApi().getAsyncJob(asyncJob.getId()); assertEquals(query.getId(), asyncJob.getId()); assert query.getResultType() != null : query; checkJob(query); } }
@Test public void testFailedJobComplete() { AsyncJob<?> job = AsyncJob.builder().id("100") .status(Status.FAILED).resultCode(ResultCode.FAIL) .error(AsyncJobError.builder().errorCode(ErrorCode.INTERNAL_ERROR).errorText("Dummy test error").build()).build(); expect((Object) asyncJobClient.getAsyncJob(job.getId())).andReturn(job); replay(client, asyncJobClient); try { new JobComplete(client).apply(job.getId()); fail("No exception thrown"); } catch (AsyncJobException e) { assertTrue(e.toString().contains("Dummy test error")); } verify(client, asyncJobClient); } }
@Test public void testFailedJobComplete() { AsyncJob<?> job = AsyncJob.builder().id("100") .status(Status.FAILED).resultCode(ResultCode.FAIL) .error(AsyncJobError.builder().errorCode(ErrorCode.INTERNAL_ERROR).errorText("Dummy test error").build()).build(); expect((Object) asyncJobClient.getAsyncJob(job.getId())).andReturn(job); replay(client, asyncJobClient); try { new JobComplete(client).apply(job.getId()); fail("No exception thrown"); } catch (AsyncJobException e) { assertTrue(e.toString().contains("Dummy test error")); } verify(client, asyncJobClient); } }
public T fromAsyncJob(AsyncJob<S> in) { return this .accountId(in.getAccountId()) .cmd(in.getCmd()) .created(in.getCreated()) .id(in.getId()) .instanceId(in.getInstanceId()) .instanceType(in.getInstanceType()) .progress(in.getProgress()) .result(in.getResult()) .resultCode(in.getResultCode()) .resultType(in.getResultType()) .status(in.getStatus()) .userId(in.getUserId()) .error(in.getError()); }
public T fromAsyncJob(AsyncJob<S> in) { return this .accountId(in.getAccountId()) .cmd(in.getCmd()) .created(in.getCreated()) .id(in.getId()) .instanceId(in.getInstanceId()) .instanceType(in.getInstanceType()) .progress(in.getProgress()) .result(in.getResult()) .resultCode(in.getResultCode()) .resultType(in.getResultType()) .status(in.getStatus()) .userId(in.getUserId()) .error(in.getError()); }
public T fromAsyncJob(AsyncJob<S> in) { return this .accountId(in.getAccountId()) .cmd(in.getCmd()) .created(in.getCreated()) .id(in.getId()) .instanceId(in.getInstanceId()) .instanceType(in.getInstanceType()) .progress(in.getProgress()) .result(in.getResult()) .resultCode(in.getResultCode()) .resultType(in.getResultType()) .status(in.getStatus()) .userId(in.getUserId()) .error(in.getError()); }