use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.
the class JobChainBuilderTest method setUp.
@Before
public void setUp() {
this.counter = new JobCounter(4);
this.builder = new JobChainBuilder(createJob("Job 1", counter));
createJobs(3, null, builder, counter);
counter.setBuilder(builder);
}
use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.
the class JobChainBuilderTest method should_schedule_4_jobs_given_null_condition_wont_stop_scheduling.
@Test
public void should_schedule_4_jobs_given_null_condition_wont_stop_scheduling() {
// given
JobCounter counter = new JobCounter(4);
JobChainBuilder builder = new JobChainBuilder(createJob("Job 1", counter));
counter.setBuilder(builder);
createJobs(3, new ISchedulingCondition[] { null, null, null }, builder, counter);
// when
builder.schedule();
// then
assertThat(counter.getDone()).isEqualTo(4);
}
use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.
the class OpenShiftServerEditorSection method loadResources.
private void loadResources(final Composite container, DataBindingContext dbc) {
IServerWorkingCopy server = input.getServer();
Cursor busyCursor = new Cursor(container.getDisplay(), SWT.CURSOR_WAIT);
IProgressMonitor chainProgressMonitor = new NullProgressMonitor() {
@Override
public boolean isCanceled() {
return container.isDisposed();
}
};
new JobChainBuilder(new DisableAllWidgetsJobFixed(true, container, busyCursor, dbc), chainProgressMonitor).runWhenDone(new LoadResourcesJob(server)).runWhenDone(new DisableAllWidgetsJobFixed(false, container, false, busyCursor, dbc)).runWhenDone(new InitializeWidgetsJob()).schedule();
}
use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.
the class DeployImageWizard method getJobChain.
/**
* Gets the Job to run as a chain of smaller jobs, depending on the use-case
* @param model the wizard model
* @param shell the current shell
* @return
*/
private Job getJobChain(final IDeployImageParameters model, final Shell shell) {
final DeployImageJob deployJob = getDeployImageJob(getModel(), getShell());
final boolean pushImageToRegistry = model.isPushImageToRegistry();
if (pushImageToRegistry) {
final PushImageToRegistryJob pushImageToRegistryJob = getPushImageToRegistryJob(model);
return new JobChainBuilder(pushImageToRegistryJob).runWhenSuccessfullyDone(deployJob).runWhenSuccessfullyDone(new RefreshResourcesJob(deployJob, true)).build();
}
return new JobChainBuilder(deployJob).runWhenSuccessfullyDone(new RefreshResourcesJob(deployJob, true)).build();
}
use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.
the class JobChainBuilderTest method should_schedule_2_jobs_given_condition_that_stops_after_2.
@Test
public void should_schedule_2_jobs_given_condition_that_stops_after_2() {
// given
JobCounter counter = new JobCounter(4);
JobChainBuilder builder = new JobChainBuilder(createJob("Job 1", counter));
counter.setBuilder(builder);
createJobs(3, new ISchedulingCondition[] { new JobChainBuilder.NullCondition(), new JobChainBuilder.ISchedulingCondition() {
@Override
public boolean isFullfilled(Job preceedingJob) {
return false;
}
}, new JobChainBuilder.NullCondition() }, builder, counter);
// when
builder.schedule();
// then
assertThat(counter.getDone()).isEqualTo(2);
}
Aggregations