| 1 | package edu.ucsb.cs156.courses.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.jobs.services.JobContext; | |
| 4 | import edu.ucsb.cs156.jobs.services.JobContextConsumer; | |
| 5 | import lombok.Builder; | |
| 6 | ||
| 7 | /** | |
| 8 | * A trivial job for testing the jobs infrastructure from the admin console: logs a line, sleeps, | |
| 9 | * then either fails or logs a goodbye. The admin frontend already has a form wired up to launch | |
| 10 | * this (TestJobForm/SingleButtonJobForm), but this app had no backend endpoint to receive it. | |
| 11 | */ | |
| 12 | @Builder | |
| 13 | public class TestJob implements JobContextConsumer { | |
| 14 | ||
| 15 | private boolean fail; | |
| 16 | private int sleepMs; | |
| 17 | ||
| 18 | @Override | |
| 19 | public void accept(JobContext ctx) throws Exception { | |
| 20 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("Hello World! from test job!"); |
| 21 |
1
1. accept : removed call to java/lang/Thread::sleep → KILLED |
Thread.sleep(sleepMs); |
| 22 |
1
1. accept : negated conditional → KILLED |
if (fail) { |
| 23 | throw new Exception("Fail!"); | |
| 24 | } | |
| 25 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("Goodbye from test job!"); |
| 26 | } | |
| 27 | } | |
Mutations | ||
| 20 |
1.1 |
|
| 21 |
1.1 |
|
| 22 |
1.1 |
|
| 25 |
1.1 |