WorkerService { public void scheduleJobBuild(Build build, String stageName, Job job) { JobBuild jobBuild = jobBuildDao.findByBuildAndStageAndName(build, stageName, job.getName()).get(); jobBuild.setStatus(JobBuild.Status.READY); jobBuild.setWorkerName(null); jobBuild.setEnvironmentVariables(getEnvironment(build)); jobBuildDao.save(jobBuild); }  String registerWorker(); @Transactional void onHeartbeat(String name); void scheduleJobBuild(Build build, String stageName, Job job); @Transactional void assignJobBuildToWorker(JobBuild jobBuild); List<WorkerModel> getWorkers(int page, int size); WorkerModel getWorker(String name); @Transactional void deleteWorker(String name); @Transactional void readyWorker(Optional<Worker> workerOptional);  }
@Test public void shouldScheduleExecution() { Build build = prepareBuild(); Stage firstStage = new Stage("first", true); Dickfile dickfile = prepareDickfile(firstStage); jobBuildService.prepareJobs(build, dickfile); workerService.scheduleJobBuild(build, "first", dickfile.getJobs(firstStage).get(0)); List<JobBuild> builds = jobBuildDao.findByBuild(build); assertThat(builds).hasSize(1); assertThat(builds.get(0).getEnvironmentVariables()).extracting("variableKey", "variableValue") .contains(Tuple.tuple("FOOKEY", "foo")); assertThat(builds.get(0).getDeploy()).containsExactly("echo foo"); }