|
24 | 24 | import java.util.Date;
|
25 | 25 | import java.util.LinkedHashSet;
|
26 | 26 | import java.util.List;
|
| 27 | +import java.util.Map; |
27 | 28 | import java.util.Map.Entry;
|
28 | 29 | import java.util.TimeZone;
|
29 | 30 |
|
|
54 | 55 | import org.springframework.boot.actuate.endpoint.Show;
|
55 | 56 | import org.springframework.boot.actuate.quartz.QuartzEndpoint;
|
56 | 57 | import org.springframework.boot.actuate.quartz.QuartzEndpointWebExtension;
|
| 58 | +import org.springframework.boot.json.JsonWriter; |
57 | 59 | import org.springframework.context.annotation.Bean;
|
58 | 60 | import org.springframework.context.annotation.Configuration;
|
59 | 61 | import org.springframework.context.annotation.Import;
|
| 62 | +import org.springframework.http.MediaType; |
60 | 63 | import org.springframework.restdocs.payload.FieldDescriptor;
|
61 | 64 | import org.springframework.restdocs.payload.JsonFieldType;
|
62 | 65 | import org.springframework.scheduling.quartz.DelegatingJob;
|
|
68 | 71 | import static org.mockito.BDDMockito.given;
|
69 | 72 | import static org.mockito.Mockito.mock;
|
70 | 73 | import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
| 74 | +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; |
| 75 | +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; |
| 76 | +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; |
71 | 77 | import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
72 | 78 | import static org.springframework.restdocs.payload.PayloadDocumentation.relaxedResponseFields;
|
| 79 | +import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; |
73 | 80 | import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
74 | 81 | import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
|
75 | 82 |
|
@@ -385,6 +392,23 @@ void quartzTriggerCustom() throws Exception {
|
385 | 392 | .andWithPrefix("custom.", customTriggerSummary)));
|
386 | 393 | }
|
387 | 394 |
|
| 395 | + @Test |
| 396 | + void quartzTriggerJob() throws Exception { |
| 397 | + mockJobs(jobOne); |
| 398 | + String json = JsonWriter.standard().writeToString(Map.of("state", "running")); |
| 399 | + assertThat(this.mvc.post() |
| 400 | + .content(json) |
| 401 | + .contentType(MediaType.APPLICATION_JSON) |
| 402 | + .uri("/actuator/quartz/jobs/samples/jobOne")) |
| 403 | + .hasStatusOk() |
| 404 | + .apply(document("quartz/trigger-job", preprocessRequest(), preprocessResponse(prettyPrint()), |
| 405 | + requestFields(fieldWithPath("state").description("The desired state of the job.")), |
| 406 | + responseFields(fieldWithPath("group").description("Name of the group."), |
| 407 | + fieldWithPath("name").description("Name of the job."), |
| 408 | + fieldWithPath("className").description("Fully qualified name of the job implementation."), |
| 409 | + fieldWithPath("triggerTime").description("Time the job is triggered.")))); |
| 410 | + } |
| 411 | + |
388 | 412 | private <T extends Trigger> void setupTriggerDetails(TriggerBuilder<T> builder, TriggerState state)
|
389 | 413 | throws SchedulerException {
|
390 | 414 | T trigger = builder.withIdentity("example", "samples")
|
|
0 commit comments