|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
|
18 | 18 |
|
19 |
| -import java.util.Arrays; |
20 | 19 | import java.util.List;
|
21 | 20 |
|
22 |
| -import org.junit.jupiter.api.BeforeEach; |
23 | 21 | import org.junit.jupiter.api.Test;
|
24 | 22 |
|
25 |
| -import org.springframework.beans.factory.annotation.Autowired; |
26 | 23 | import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint;
|
27 | 24 | import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
|
28 | 25 | import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
29 | 26 | import org.springframework.context.ConfigurableApplicationContext;
|
30 | 27 | import org.springframework.context.annotation.Bean;
|
31 | 28 | import org.springframework.context.annotation.Configuration;
|
32 | 29 | import org.springframework.context.annotation.Import;
|
33 |
| -import org.springframework.restdocs.RestDocumentationContextProvider; |
34 | 30 | import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
35 | 31 | import org.springframework.restdocs.payload.FieldDescriptor;
|
36 | 32 | import org.springframework.restdocs.payload.JsonFieldType;
|
37 |
| -import org.springframework.test.web.servlet.MockMvc; |
38 |
| -import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
39 |
| -import org.springframework.web.context.WebApplicationContext; |
40 | 33 |
|
41 | 34 | import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
42 | 35 | import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
|
51 | 44 | */
|
52 | 45 | class ConditionsReportEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
|
53 | 46 |
|
54 |
| - private MockMvc mockMvc; |
55 |
| - |
56 |
| - @Autowired |
57 |
| - private WebApplicationContext applicationContext; |
58 |
| - |
59 |
| - @Override |
60 |
| - @BeforeEach |
61 |
| - void setup(RestDocumentationContextProvider restDocumentation) { |
62 |
| - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.applicationContext) |
63 |
| - .apply(MockMvcRestDocumentation.documentationConfiguration(restDocumentation).uris()) |
64 |
| - .build(); |
65 |
| - } |
66 |
| - |
67 | 47 | @Test
|
68 | 48 | void conditions() throws Exception {
|
69 |
| - List<FieldDescriptor> positiveMatchFields = Arrays.asList( |
| 49 | + List<FieldDescriptor> positiveMatchFields = List.of( |
70 | 50 | fieldWithPath("").description("Classes and methods with conditions that were matched."),
|
71 | 51 | fieldWithPath(".*.[].condition").description("Name of the condition."),
|
72 | 52 | fieldWithPath(".*.[].message").description("Details of why the condition was matched."));
|
73 |
| - List<FieldDescriptor> negativeMatchFields = Arrays.asList( |
| 53 | + List<FieldDescriptor> negativeMatchFields = List.of( |
74 | 54 | fieldWithPath("").description("Classes and methods with conditions that were not matched."),
|
75 | 55 | fieldWithPath(".*.notMatched").description("Conditions that were matched."),
|
76 | 56 | fieldWithPath(".*.notMatched.[].condition").description("Name of the condition."),
|
@@ -104,7 +84,7 @@ ConditionsReportEndpoint autoConfigurationReportEndpoint(ConfigurableApplication
|
104 | 84 | ConditionEvaluationReport conditionEvaluationReport = ConditionEvaluationReport
|
105 | 85 | .get(context.getBeanFactory());
|
106 | 86 | conditionEvaluationReport
|
107 |
| - .recordEvaluationCandidates(Arrays.asList(PropertyPlaceholderAutoConfiguration.class.getName())); |
| 87 | + .recordEvaluationCandidates(List.of(PropertyPlaceholderAutoConfiguration.class.getName())); |
108 | 88 | return new ConditionsReportEndpoint(context);
|
109 | 89 | }
|
110 | 90 |
|
|
0 commit comments