diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java index 99d2b445281..aaf3805f91d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentatio import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; -import java.util.Arrays; import java.util.Collections; +import java.util.List; import org.junit.jupiter.api.Test; @@ -56,7 +56,7 @@ class AuditEventsEndpointDocumentationTests extends MockMvcEndpointDocumentation void allAuditEvents() throws Exception { String queryTimestamp = "2017-11-07T09:37Z"; given(this.repository.find(any(), any(), any())) - .willReturn(Arrays.asList(new AuditEvent("alice", "logout", Collections.emptyMap()))); + .willReturn(List.of(new AuditEvent("alice", "logout", Collections.emptyMap()))); this.mockMvc.perform(get("/actuator/auditevents").param("after", queryTimestamp)) .andExpect(status().isOk()) .andDo(document("auditevents/all", @@ -72,7 +72,7 @@ class AuditEventsEndpointDocumentationTests extends MockMvcEndpointDocumentation OffsetDateTime now = OffsetDateTime.now(); String queryTimestamp = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(now); given(this.repository.find("alice", now.toInstant(), "logout")) - .willReturn(Arrays.asList(new AuditEvent("alice", "logout", Collections.emptyMap()))); + .willReturn(List.of(new AuditEvent("alice", "logout", Collections.emptyMap()))); this.mockMvc .perform(get("/actuator/auditevents").param("principal", "alice") .param("after", queryTimestamp) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/BeansEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/BeansEndpointDocumentationTests.java index 282eb162f18..4eb3fb8bcd4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/BeansEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/BeansEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; -import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; @@ -50,7 +49,7 @@ class BeansEndpointDocumentationTests extends MockMvcEndpointDocumentationTests @Test void beans() throws Exception { - List beanFields = Arrays.asList(fieldWithPath("aliases").description("Names of any aliases."), + List beanFields = List.of(fieldWithPath("aliases").description("Names of any aliases."), fieldWithPath("scope").description("Scope of the bean."), fieldWithPath("type").description("Fully qualified type of the bean."), fieldWithPath("resource").description("Resource in which the bean was defined, if any.") diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java index ba1fc9346e6..44cf427a296 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -50,8 +49,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { - private static final List levelFields = Arrays.asList( - fieldWithPath("name").description("Cache name."), + private static final List levelFields = List.of(fieldWithPath("name").description("Cache name."), fieldWithPath("cacheManager").description("Cache manager name."), fieldWithPath("target").description("Fully qualified name of the native cache.")); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ConditionsReportEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ConditionsReportEndpointDocumentationTests.java index 3e36dff8ad7..58586569d14 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ConditionsReportEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ConditionsReportEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,10 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; -import java.util.Arrays; import java.util.List; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint; import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; @@ -30,13 +27,9 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.restdocs.RestDocumentationContextProvider; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; import org.springframework.restdocs.payload.FieldDescriptor; import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; @@ -51,26 +44,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ class ConditionsReportEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { - private MockMvc mockMvc; - - @Autowired - private WebApplicationContext applicationContext; - - @Override - @BeforeEach - void setup(RestDocumentationContextProvider restDocumentation) { - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.applicationContext) - .apply(MockMvcRestDocumentation.documentationConfiguration(restDocumentation).uris()) - .build(); - } - @Test void conditions() throws Exception { - List positiveMatchFields = Arrays.asList( + List positiveMatchFields = List.of( fieldWithPath("").description("Classes and methods with conditions that were matched."), fieldWithPath(".*.[].condition").description("Name of the condition."), fieldWithPath(".*.[].message").description("Details of why the condition was matched.")); - List negativeMatchFields = Arrays.asList( + List negativeMatchFields = List.of( fieldWithPath("").description("Classes and methods with conditions that were not matched."), fieldWithPath(".*.notMatched").description("Conditions that were matched."), fieldWithPath(".*.notMatched.[].condition").description("Name of the condition."), @@ -104,7 +84,7 @@ class ConditionsReportEndpointDocumentationTests extends MockMvcEndpointDocument ConditionEvaluationReport conditionEvaluationReport = ConditionEvaluationReport .get(context.getBeanFactory()); conditionEvaluationReport - .recordEvaluationCandidates(Arrays.asList(PropertyPlaceholderAutoConfiguration.class.getName())); + .recordEvaluationCandidates(List.of(PropertyPlaceholderAutoConfiguration.class.getName())); return new ConditionsReportEndpoint(context); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java index 154f0f217a4..591b40e7231 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; -import java.util.Arrays; import java.util.List; import javax.sql.DataSource; @@ -61,7 +60,7 @@ class FlywayEndpointDocumentationTests extends MockMvcEndpointDocumentationTests } private List migrationFieldDescriptors() { - return Arrays.asList(fieldWithPath("checksum").description("Checksum of the migration, if any.").optional(), + return List.of(fieldWithPath("checksum").description("Checksum of the migration, if any.").optional(), fieldWithPath("description").description("Description of the migration, if any.").optional(), fieldWithPath("executionTime").description("Execution time in milliseconds of an applied migration.") .optional(), diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java index a001d686991..cc6920b3bf3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; import java.io.File; -import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -68,7 +67,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { - private static final List componentFields = Arrays.asList( + private static final List componentFields = List.of( fieldWithPath("status").description("Status of a specific part of the application"), subsectionWithPath("details").description("Details of the health of a specific part of the application.")); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HttpExchangesEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HttpExchangesEndpointDocumentationTests.java index 9f757f2af55..95a91984ce7 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HttpExchangesEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HttpExchangesEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ import java.time.Clock; import java.time.Duration; import java.time.Instant; import java.time.ZoneId; -import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; +import java.util.List; import java.util.UUID; import org.junit.jupiter.api.Test; @@ -66,11 +66,11 @@ class HttpExchangesEndpointDocumentationTests extends MockMvcEndpointDocumentati given(request.getUri()).willReturn(URI.create("https://api.example.com")); given(request.getMethod()).willReturn("GET"); given(request.getHeaders()) - .willReturn(Collections.singletonMap(HttpHeaders.ACCEPT, Arrays.asList("application/json"))); + .willReturn(Collections.singletonMap(HttpHeaders.ACCEPT, List.of("application/json"))); RecordableHttpResponse response = mock(RecordableHttpResponse.class); given(response.getStatus()).willReturn(200); given(response.getHeaders()) - .willReturn(Collections.singletonMap(HttpHeaders.CONTENT_TYPE, Arrays.asList("application/json"))); + .willReturn(Collections.singletonMap(HttpHeaders.CONTENT_TYPE, List.of("application/json"))); Principal principal = mock(Principal.class); given(principal.getName()).willReturn("alice"); Instant instant = Instant.parse("2022-12-22T13:43:41.00Z"); @@ -78,7 +78,7 @@ class HttpExchangesEndpointDocumentationTests extends MockMvcEndpointDocumentati Clock end = Clock.offset(start, Duration.ofMillis(23)); HttpExchange exchange = HttpExchange.start(start, request) .finish(end, response, () -> principal, () -> UUID.randomUUID().toString(), EnumSet.allOf(Include.class)); - given(this.repository.findAll()).willReturn(Arrays.asList(exchange)); + given(this.repository.findAll()).willReturn(List.of(exchange)); this.mockMvc.perform(get("/actuator/httpexchanges")) .andExpect(status().isOk()) .andDo(document("httpexchanges", responseFields( diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java index 50329c8f86a..cd12c81c2ca 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; -import java.util.Arrays; import java.util.List; import liquibase.changelog.ChangeSet.ExecType; @@ -59,7 +58,7 @@ class LiquibaseEndpointDocumentationTests extends MockMvcEndpointDocumentationTe } private List getChangeSetFieldDescriptors() { - return Arrays.asList(fieldWithPath("author").description("Author of the change set."), + return List.of(fieldWithPath("author").description("Author of the change set."), fieldWithPath("changeLog").description("Change log that contains the change set."), fieldWithPath("comments").description("Comments on the change set."), fieldWithPath("contexts").description("Contexts of the change set."), diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java index 33f90fbe756..acc1b10a216 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; -import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; import java.util.List; @@ -55,18 +54,14 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { - private static final List levelFields = Arrays.asList( + private static final List levelFields = List.of( fieldWithPath("configuredLevel").description("Configured level of the logger, if any.").optional(), fieldWithPath("effectiveLevel").description("Effective level of the logger.")); - private static final List groupLevelFields; - - static { - groupLevelFields = Arrays - .asList(fieldWithPath("configuredLevel").description("Configured level of the logger group, if any.") - .type(JsonFieldType.STRING) - .optional(), fieldWithPath("members").description("Loggers that are part of this group")); - } + private static final List groupLevelFields = List + .of(fieldWithPath("configuredLevel").description("Configured level of the logger group, if any.") + .type(JsonFieldType.STRING) + .optional(), fieldWithPath("members").description("Loggers that are part of this group")); @MockBean private LoggingSystem loggingSystem; @@ -78,7 +73,7 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest void allLoggers() throws Exception { given(this.loggingSystem.getSupportedLogLevels()).willReturn(EnumSet.allOf(LogLevel.class)); given(this.loggingSystem.getLoggerConfigurations()) - .willReturn(Arrays.asList(new LoggerConfiguration("ROOT", LogLevel.INFO, LogLevel.INFO), + .willReturn(List.of(new LoggerConfiguration("ROOT", LogLevel.INFO, LogLevel.INFO), new LoggerConfiguration("com.example", LogLevel.DEBUG, LogLevel.DEBUG))); this.mockMvc.perform(get("/actuator/loggers")) .andExpect(status().isOk()) @@ -164,7 +159,7 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest } private Map> getLoggerGroups() { - return Collections.singletonMap("test", Arrays.asList("test.member1", "test.member2")); + return Collections.singletonMap("test", List.of("test.member1", "test.member2")); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointReactiveDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointReactiveDocumentationTests.java index 79c673e8128..ea189c393f3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointReactiveDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointReactiveDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentatio import java.time.Duration; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -81,7 +80,7 @@ class MappingsEndpointReactiveDocumentationTests extends AbstractEndpointDocumen @Test void mappings() { - List requestMappingConditions = Arrays.asList( + List requestMappingConditions = List.of( requestMappingConditionField("").description("Details of the request mapping conditions.").optional(), requestMappingConditionField(".consumes").description("Details of the consumes condition"), requestMappingConditionField(".consumes.[].mediaType").description("Consumed media type."), @@ -101,7 +100,7 @@ class MappingsEndpointReactiveDocumentationTests extends AbstractEndpointDocumen requestMappingConditionField(".produces").description("Details of the produces condition."), requestMappingConditionField(".produces.[].mediaType").description("Produced media type."), requestMappingConditionField(".produces.[].negated").description("Whether the media type is negated.")); - List handlerMethod = Arrays.asList( + List handlerMethod = List.of( fieldWithPath("*.[].details.handlerMethod").optional() .type(JsonFieldType.OBJECT) .description("Details of the method, if any, that will handle requests to this mapping."), @@ -111,13 +110,13 @@ class MappingsEndpointReactiveDocumentationTests extends AbstractEndpointDocumen .description("Name of the method."), fieldWithPath("*.[].details.handlerMethod.descriptor").type(JsonFieldType.STRING) .description("Descriptor of the method as specified in the Java Language Specification.")); - List handlerFunction = Arrays.asList( + List handlerFunction = List.of( fieldWithPath("*.[].details.handlerFunction").optional() .type(JsonFieldType.OBJECT) .description("Details of the function, if any, that will handle requests to this mapping."), fieldWithPath("*.[].details.handlerFunction.className").type(JsonFieldType.STRING) .description("Fully qualified name of the class of the function.")); - List dispatcherHandlerFields = new ArrayList<>(Arrays.asList( + List dispatcherHandlerFields = new ArrayList<>(List.of( fieldWithPath("*") .description("Dispatcher handler mappings, if any, keyed by dispatcher handler bean name."), fieldWithPath("*.[].details").optional() diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointServletDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointServletDocumentationTests.java index b6399c7c3d4..b11040e97f8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointServletDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointServletDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentatio import java.time.Duration; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -94,7 +93,7 @@ class MappingsEndpointServletDocumentationTests extends AbstractEndpointDocument .optional() .type(JsonFieldType.OBJECT), parentIdField()); - List dispatcherServletFields = new ArrayList<>(Arrays.asList( + List dispatcherServletFields = new ArrayList<>(List.of( fieldWithPath("*") .description("Dispatcher servlet mappings, if any, keyed by dispatcher servlet bean name."), fieldWithPath("*.[].details").optional() @@ -102,7 +101,7 @@ class MappingsEndpointServletDocumentationTests extends AbstractEndpointDocument .description("Additional implementation-specific details about the mapping. Optional."), fieldWithPath("*.[].handler").description("Handler for the mapping."), fieldWithPath("*.[].predicate").description("Predicate for the mapping."))); - List requestMappingConditions = Arrays.asList( + List requestMappingConditions = List.of( requestMappingConditionField("").description("Details of the request mapping conditions.").optional(), requestMappingConditionField(".consumes").description("Details of the consumes condition"), requestMappingConditionField(".consumes.[].mediaType").description("Consumed media type."), @@ -122,7 +121,7 @@ class MappingsEndpointServletDocumentationTests extends AbstractEndpointDocument requestMappingConditionField(".produces").description("Details of the produces condition."), requestMappingConditionField(".produces.[].mediaType").description("Produced media type."), requestMappingConditionField(".produces.[].negated").description("Whether the media type is negated.")); - List handlerMethod = Arrays.asList( + List handlerMethod = List.of( fieldWithPath("*.[].details.handlerMethod").optional() .type(JsonFieldType.OBJECT) .description("Details of the method, if any, that will handle requests to this mapping."), diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/QuartzEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/QuartzEndpointDocumentationTests.java index 63093af47b9..fd51daf5d11 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/QuartzEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/QuartzEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,10 +130,10 @@ class QuartzEndpointDocumentationTests extends MockMvcEndpointDocumentationTests .withInterval(1, IntervalUnit.HOUR)) .build(); - private static final List triggerSummary = Arrays.asList(previousFireTime(""), nextFireTime(""), + private static final List triggerSummary = List.of(previousFireTime(""), nextFireTime(""), priority("")); - private static final List cronTriggerSummary = Arrays.asList( + private static final List cronTriggerSummary = List.of( fieldWithPath("expression").description("Cron expression to use."), fieldWithPath("timeZone").type(JsonFieldType.STRING) .optional() @@ -158,8 +158,8 @@ class QuartzEndpointDocumentationTests extends MockMvcEndpointDocumentationTests fieldWithPath("timeZone").type(JsonFieldType.STRING) .description("Time zone within which time calculations will be performed, if any.")); - private static final List customTriggerSummary = Collections.singletonList( - fieldWithPath("trigger").description("A toString representation of the custom trigger instance.")); + private static final List customTriggerSummary = List + .of(fieldWithPath("trigger").description("A toString representation of the custom trigger instance.")); private static final FieldDescriptor[] commonCronDetails = new FieldDescriptor[] { fieldWithPath("group").description("Name of the group."), @@ -280,7 +280,7 @@ class QuartzEndpointDocumentationTests extends MockMvcEndpointDocumentationTests setPreviousNextFireTime(secondTrigger, "2020-12-04T03:00:00Z", "2020-12-04T12:00:00Z"); mockTriggers(firstTrigger, secondTrigger); given(this.scheduler.getTriggersOfJob(jobOne.getKey())) - .willAnswer((invocation) -> Arrays.asList(firstTrigger, secondTrigger)); + .willAnswer((invocation) -> List.of(firstTrigger, secondTrigger)); this.mockMvc.perform(get("/actuator/quartz/jobs/samples/jobOne")) .andExpect(status().isOk()) .andDo(document("quartz/job-details", responseFields( @@ -398,7 +398,7 @@ class QuartzEndpointDocumentationTests extends MockMvcEndpointDocumentationTests .andWithPrefix("custom.", customTriggerSummary))); } - private T setupTriggerDetails(TriggerBuilder builder, TriggerState state) + private void setupTriggerDetails(TriggerBuilder builder, TriggerState state) throws SchedulerException { T trigger = builder.withIdentity("example", "samples") .withDescription("Example trigger") @@ -409,7 +409,6 @@ class QuartzEndpointDocumentationTests extends MockMvcEndpointDocumentationTests setPreviousNextFireTime(trigger, "2020-12-04T03:00:00Z", "2020-12-07T03:00:00Z"); given(this.scheduler.getTriggerState(trigger.getKey())).willReturn(state); mockTriggers(trigger); - return trigger; } private static FieldDescriptor startTime(String prefix) { @@ -481,7 +480,7 @@ class QuartzEndpointDocumentationTests extends MockMvcEndpointDocumentationTests } } - private T setPreviousNextFireTime(T trigger, String previousFireTime, String nextFireTime) { + private void setPreviousNextFireTime(T trigger, String previousFireTime, String nextFireTime) { OperableTrigger operableTrigger = (OperableTrigger) trigger; if (previousFireTime != null) { operableTrigger.setPreviousFireTime(fromUtc(previousFireTime)); @@ -489,7 +488,6 @@ class QuartzEndpointDocumentationTests extends MockMvcEndpointDocumentationTests if (nextFireTime != null) { operableTrigger.setNextFireTime(fromUtc(nextFireTime)); } - return trigger; } private static Date fromUtc(String utcTime) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ScheduledTasksEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ScheduledTasksEndpointDocumentationTests.java index efcc258699f..cd757aa6cd5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ScheduledTasksEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ScheduledTasksEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.config.ScheduledTaskHolder; -import org.springframework.test.web.servlet.result.MockMvcResultHandlers; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; @@ -73,8 +72,7 @@ class ScheduledTasksEndpointDocumentationTests extends MockMvcEndpointDocumentat initialDelayWithPrefix("fixedRate.[]."), fieldWithPath("custom").description("Tasks with custom triggers, if any."), targetFieldWithPrefix("custom.[]."), - fieldWithPath("custom.[].trigger").description("Trigger for the task.")))) - .andDo(MockMvcResultHandlers.print()); + fieldWithPath("custom.[].trigger").description("Trigger for the task.")))); } private FieldDescriptor targetFieldWithPrefix(String prefix) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java index 0d43d8fa122..c33020828cf 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; import java.time.Instant; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -65,7 +64,7 @@ class SessionsEndpointDocumentationTests extends MockMvcEndpointDocumentationTes private static final Session sessionThree = createSession(Instant.now().minusSeconds(60 * 60 * 2), Instant.now().minusSeconds(12)); - private static final List sessionFields = Arrays.asList( + private static final List sessionFields = List.of( fieldWithPath("id").description("ID of the session."), fieldWithPath("attributeNames").description("Names of the attributes stored in the session."), fieldWithPath("creationTime").description("Timestamp of when the session was created."), diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ShutdownEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ShutdownEndpointDocumentationTests.java index 033312870bf..36e5d3fdbf6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ShutdownEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ShutdownEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.core.env.Environment; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; @@ -51,7 +50,7 @@ class ShutdownEndpointDocumentationTests extends MockMvcEndpointDocumentationTes static class TestConfiguration { @Bean - ShutdownEndpoint endpoint(Environment environment) { + ShutdownEndpoint endpoint() { ShutdownEndpoint endpoint = new ShutdownEndpoint(); endpoint.setApplicationContext(new AnnotationConfigApplicationContext()); return endpoint;