Unify actuator descriptor class names

Update actuator endpoints to consistently use `...Descriptor` for
JSON support classes.

Closes gh-33022
pull/33064/head
Phillip Webb 2 years ago
parent 0fa7dba87a
commit 179aa987ee

@ -60,14 +60,14 @@ public class ConditionsReportEndpoint {
}
@ReadOperation
public ApplicationConditionEvaluation applicationConditionEvaluation() {
Map<String, ContextConditionEvaluation> contextConditionEvaluations = new HashMap<>();
public ConditionsDescriptor conditions() {
Map<String, ContextConditionsDescriptor> contextConditionEvaluations = new HashMap<>();
ConfigurableApplicationContext target = this.context;
while (target != null) {
contextConditionEvaluations.put(target.getId(), new ContextConditionEvaluation(target));
contextConditionEvaluations.put(target.getId(), new ContextConditionsDescriptor(target));
target = getConfigurableParent(target);
}
return new ApplicationConditionEvaluation(contextConditionEvaluations);
return new ConditionsDescriptor(contextConditionEvaluations);
}
private ConfigurableApplicationContext getConfigurableParent(ConfigurableApplicationContext context) {
@ -79,18 +79,17 @@ public class ConditionsReportEndpoint {
}
/**
* A description of an application's condition evaluation, primarily intended for
* serialization to JSON.
* A description of an application's condition evaluation.
*/
public static final class ApplicationConditionEvaluation {
public static final class ConditionsDescriptor {
private final Map<String, ContextConditionEvaluation> contexts;
private final Map<String, ContextConditionsDescriptor> contexts;
private ApplicationConditionEvaluation(Map<String, ContextConditionEvaluation> contexts) {
private ConditionsDescriptor(Map<String, ContextConditionsDescriptor> contexts) {
this.contexts = contexts;
}
public Map<String, ContextConditionEvaluation> getContexts() {
public Map<String, ContextConditionsDescriptor> getContexts() {
return this.contexts;
}
@ -101,11 +100,11 @@ public class ConditionsReportEndpoint {
* for serialization to JSON.
*/
@JsonInclude(Include.NON_EMPTY)
public static final class ContextConditionEvaluation {
public static final class ContextConditionsDescriptor {
private final MultiValueMap<String, MessageAndCondition> positiveMatches;
private final MultiValueMap<String, MessageAndConditionDescriptor> positiveMatches;
private final Map<String, MessageAndConditions> negativeMatches;
private final Map<String, MessageAndConditionsDescriptor> negativeMatches;
private final List<String> exclusions;
@ -113,7 +112,7 @@ public class ConditionsReportEndpoint {
private final String parentId;
public ContextConditionEvaluation(ConfigurableApplicationContext context) {
public ContextConditionsDescriptor(ConfigurableApplicationContext context) {
ConditionEvaluationReport report = ConditionEvaluationReport.get(context.getBeanFactory());
this.positiveMatches = new LinkedMultiValueMap<>();
this.negativeMatches = new LinkedHashMap<>();
@ -127,18 +126,18 @@ public class ConditionsReportEndpoint {
String name = ClassUtils.getShortName(source);
if (conditionAndOutcomes.isFullMatch()) {
conditionAndOutcomes.forEach((conditionAndOutcome) -> this.positiveMatches.add(name,
new MessageAndCondition(conditionAndOutcome)));
new MessageAndConditionDescriptor(conditionAndOutcome)));
}
else {
this.negativeMatches.put(name, new MessageAndConditions(conditionAndOutcomes));
this.negativeMatches.put(name, new MessageAndConditionsDescriptor(conditionAndOutcomes));
}
}
public Map<String, List<MessageAndCondition>> getPositiveMatches() {
public Map<String, List<MessageAndConditionDescriptor>> getPositiveMatches() {
return this.positiveMatches;
}
public Map<String, MessageAndConditions> getNegativeMatches() {
public Map<String, MessageAndConditionsDescriptor> getNegativeMatches() {
return this.negativeMatches;
}
@ -160,25 +159,25 @@ public class ConditionsReportEndpoint {
* Adapts {@link ConditionAndOutcomes} to a JSON friendly structure.
*/
@JsonPropertyOrder({ "notMatched", "matched" })
public static class MessageAndConditions {
public static class MessageAndConditionsDescriptor {
private final List<MessageAndCondition> notMatched = new ArrayList<>();
private final List<MessageAndConditionDescriptor> notMatched = new ArrayList<>();
private final List<MessageAndCondition> matched = new ArrayList<>();
private final List<MessageAndConditionDescriptor> matched = new ArrayList<>();
public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) {
public MessageAndConditionsDescriptor(ConditionAndOutcomes conditionAndOutcomes) {
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
List<MessageAndCondition> target = (conditionAndOutcome.getOutcome().isMatch() ? this.matched
List<MessageAndConditionDescriptor> target = (conditionAndOutcome.getOutcome().isMatch() ? this.matched
: this.notMatched);
target.add(new MessageAndCondition(conditionAndOutcome));
target.add(new MessageAndConditionDescriptor(conditionAndOutcome));
}
}
public List<MessageAndCondition> getNotMatched() {
public List<MessageAndConditionDescriptor> getNotMatched() {
return this.notMatched;
}
public List<MessageAndCondition> getMatched() {
public List<MessageAndConditionDescriptor> getMatched() {
return this.matched;
}
@ -188,13 +187,13 @@ public class ConditionsReportEndpoint {
* Adapts {@link ConditionAndOutcome} to a JSON friendly structure.
*/
@JsonPropertyOrder({ "condition", "message" })
public static class MessageAndCondition {
public static class MessageAndConditionDescriptor {
private final String condition;
private final String message;
public MessageAndCondition(ConditionAndOutcome conditionAndOutcome) {
public MessageAndConditionDescriptor(ConditionAndOutcome conditionAndOutcome) {
Condition condition = conditionAndOutcome.getCondition();
ConditionOutcome outcome = conditionAndOutcome.getOutcome();
this.condition = ClassUtils.getShortName(condition.getClass());

@ -22,7 +22,7 @@ import java.util.Collections;
import jakarta.annotation.PostConstruct;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint.ContextConditionEvaluation;
import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint.ContextConditionsDescriptor;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -47,8 +47,8 @@ class ConditionsReportEndpointTests {
@Test
void invoke() {
new ApplicationContextRunner().withUserConfiguration(Config.class).run((context) -> {
ContextConditionEvaluation report = context.getBean(ConditionsReportEndpoint.class)
.applicationConditionEvaluation().getContexts().get(context.getId());
ContextConditionsDescriptor report = context.getBean(ConditionsReportEndpoint.class).conditions()
.getContexts().get(context.getId());
assertThat(report.getPositiveMatches()).isEmpty();
assertThat(report.getNegativeMatches()).containsKey("a");
assertThat(report.getUnconditionalClasses()).contains("b");

@ -22,7 +22,7 @@ import java.util.Set;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpointWebExtension;
import org.springframework.boot.actuate.endpoint.SanitizingFunction;
import org.springframework.boot.actuate.endpoint.Show;
@ -115,7 +115,7 @@ class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
assertThat(context).hasSingleBean(ConfigurationPropertiesReportEndpoint.class);
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties properties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor properties = endpoint.configurationProperties();
Map<String, Object> nestedProperties = properties.getContexts().get(context.getId()).getBeans()
.get("testProperties").getProperties();
assertThat(nestedProperties).isNotNull();

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 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.
@ -53,8 +53,7 @@ public class AuditEventsEndpoint {
}
/**
* A description of an application's {@link AuditEvent audit events}. Primarily
* intended for serialization to JSON.
* Description of an application's {@link AuditEvent audit events}.
*/
public static final class AuditEventsDescriptor {

@ -52,14 +52,14 @@ public class BeansEndpoint {
}
@ReadOperation
public ApplicationBeans beans() {
Map<String, ContextBeans> contexts = new HashMap<>();
public BeansDescriptor beans() {
Map<String, ContextBeansDescriptor> contexts = new HashMap<>();
ConfigurableApplicationContext context = this.context;
while (context != null) {
contexts.put(context.getId(), ContextBeans.describing(context));
contexts.put(context.getId(), ContextBeansDescriptor.describing(context));
context = getConfigurableParent(context);
}
return new ApplicationBeans(contexts);
return new BeansDescriptor(contexts);
}
private static ConfigurableApplicationContext getConfigurableParent(ConfigurableApplicationContext context) {
@ -71,34 +71,32 @@ public class BeansEndpoint {
}
/**
* A description of an application's beans, primarily intended for serialization to
* JSON.
* Description of an application's beans.
*/
public static final class ApplicationBeans {
public static final class BeansDescriptor {
private final Map<String, ContextBeans> contexts;
private final Map<String, ContextBeansDescriptor> contexts;
private ApplicationBeans(Map<String, ContextBeans> contexts) {
private BeansDescriptor(Map<String, ContextBeansDescriptor> contexts) {
this.contexts = contexts;
}
public Map<String, ContextBeans> getContexts() {
public Map<String, ContextBeansDescriptor> getContexts() {
return this.contexts;
}
}
/**
* A description of an application context, primarily intended for serialization to
* JSON.
* Description of an application context beans.
*/
public static final class ContextBeans {
public static final class ContextBeansDescriptor {
private final Map<String, BeanDescriptor> beans;
private final String parentId;
private ContextBeans(Map<String, BeanDescriptor> beans, String parentId) {
private ContextBeansDescriptor(Map<String, BeanDescriptor> beans, String parentId) {
this.beans = beans;
this.parentId = parentId;
}
@ -111,12 +109,13 @@ public class BeansEndpoint {
return this.beans;
}
private static ContextBeans describing(ConfigurableApplicationContext context) {
private static ContextBeansDescriptor describing(ConfigurableApplicationContext context) {
if (context == null) {
return null;
}
ConfigurableApplicationContext parent = getConfigurableParent(context);
return new ContextBeans(describeBeans(context.getBeanFactory()), (parent != null) ? parent.getId() : null);
return new ContextBeansDescriptor(describeBeans(context.getBeanFactory()),
(parent != null) ? parent.getId() : null);
}
private static Map<String, BeanDescriptor> describeBeans(ConfigurableListableBeanFactory beanFactory) {
@ -144,8 +143,7 @@ public class BeansEndpoint {
}
/**
* A description of a bean in an application context, primarily intended for
* serialization to JSON.
* Description of a bean.
*/
public static final class BeanDescriptor {

@ -51,11 +51,11 @@ public class CachesEndpoint {
}
/**
* Return a {@link CachesReport} of all available {@link Cache caches}.
* Return a {@link CachesDescriptor} of all available {@link Cache caches}.
* @return a caches reports
*/
@ReadOperation
public CachesReport caches() {
public CachesDescriptor caches() {
Map<String, Map<String, CacheDescriptor>> descriptors = new LinkedHashMap<>();
getCacheEntries(matchAll(), matchAll()).forEach((entry) -> {
String cacheName = entry.getName();
@ -66,7 +66,7 @@ public class CachesEndpoint {
});
Map<String, CacheManagerDescriptor> cacheManagerDescriptors = new LinkedHashMap<>();
descriptors.forEach((name, entries) -> cacheManagerDescriptors.put(name, new CacheManagerDescriptor(entries)));
return new CachesReport(cacheManagerDescriptors);
return new CachesDescriptor(cacheManagerDescriptors);
}
/**
@ -78,7 +78,7 @@ public class CachesEndpoint {
* {@code cacheManager} was provided to identify a unique candidate
*/
@ReadOperation
public CacheEntry cache(@Selector String cache, @Nullable String cacheManager) {
public CacheEntryDescriptor cache(@Selector String cache, @Nullable String cacheManager) {
return extractUniqueCacheEntry(cache, getCacheEntries((name) -> name.equals(cache), isNameMatch(cacheManager)));
}
@ -101,32 +101,32 @@ public class CachesEndpoint {
*/
@DeleteOperation
public boolean clearCache(@Selector String cache, @Nullable String cacheManager) {
CacheEntry entry = extractUniqueCacheEntry(cache,
CacheEntryDescriptor entry = extractUniqueCacheEntry(cache,
getCacheEntries((name) -> name.equals(cache), isNameMatch(cacheManager)));
return (entry != null && clearCache(entry));
}
private List<CacheEntry> getCacheEntries(Predicate<String> cacheNamePredicate,
private List<CacheEntryDescriptor> getCacheEntries(Predicate<String> cacheNamePredicate,
Predicate<String> cacheManagerNamePredicate) {
return this.cacheManagers.keySet().stream().filter(cacheManagerNamePredicate)
.flatMap((cacheManagerName) -> getCacheEntries(cacheManagerName, cacheNamePredicate).stream()).toList();
}
private List<CacheEntry> getCacheEntries(String cacheManagerName, Predicate<String> cacheNamePredicate) {
private List<CacheEntryDescriptor> getCacheEntries(String cacheManagerName, Predicate<String> cacheNamePredicate) {
CacheManager cacheManager = this.cacheManagers.get(cacheManagerName);
return cacheManager.getCacheNames().stream().filter(cacheNamePredicate).map(cacheManager::getCache)
.filter(Objects::nonNull).map((cache) -> new CacheEntry(cache, cacheManagerName)).toList();
.filter(Objects::nonNull).map((cache) -> new CacheEntryDescriptor(cache, cacheManagerName)).toList();
}
private CacheEntry extractUniqueCacheEntry(String cache, List<CacheEntry> entries) {
private CacheEntryDescriptor extractUniqueCacheEntry(String cache, List<CacheEntryDescriptor> entries) {
if (entries.size() > 1) {
throw new NonUniqueCacheException(cache,
entries.stream().map(CacheEntry::getCacheManager).distinct().toList());
entries.stream().map(CacheEntryDescriptor::getCacheManager).distinct().toList());
}
return (!entries.isEmpty() ? entries.get(0) : null);
}
private boolean clearCache(CacheEntry entry) {
private boolean clearCache(CacheEntryDescriptor entry) {
String cacheName = entry.getName();
String cacheManager = entry.getCacheManager();
Cache cache = this.cacheManagers.get(cacheManager).getCache(cacheName);
@ -146,14 +146,13 @@ public class CachesEndpoint {
}
/**
* A report of available {@link Cache caches}, primarily intended for serialization to
* JSON.
* Description of the caches.
*/
public static final class CachesReport {
public static final class CachesDescriptor {
private final Map<String, CacheManagerDescriptor> cacheManagers;
public CachesReport(Map<String, CacheManagerDescriptor> cacheManagers) {
public CachesDescriptor(Map<String, CacheManagerDescriptor> cacheManagers) {
this.cacheManagers = cacheManagers;
}
@ -164,8 +163,7 @@ public class CachesEndpoint {
}
/**
* Description of a {@link CacheManager}, primarily intended for serialization to
* JSON.
* Description of a {@link CacheManager}.
*/
public static final class CacheManagerDescriptor {
@ -182,7 +180,7 @@ public class CachesEndpoint {
}
/**
* Basic description of a {@link Cache}, primarily intended for serialization to JSON.
* Description of a {@link Cache}.
*/
public static class CacheDescriptor {
@ -203,15 +201,15 @@ public class CachesEndpoint {
}
/**
* Description of a {@link Cache}, primarily intended for serialization to JSON.
* Description of a {@link Cache} entry.
*/
public static final class CacheEntry extends CacheDescriptor {
public static final class CacheEntryDescriptor extends CacheDescriptor {
private final String name;
private final String cacheManager;
public CacheEntry(Cache cache, String cacheManager) {
public CacheEntryDescriptor(Cache cache, String cacheManager) {
super(cache.getNativeCache().getClass().getName());
this.name = cache.getName();
this.cacheManager = cacheManager;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 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,7 @@
package org.springframework.boot.actuate.cache;
import org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry;
import org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntryDescriptor;
import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
@ -40,9 +40,9 @@ public class CachesEndpointWebExtension {
}
@ReadOperation
public WebEndpointResponse<CacheEntry> cache(@Selector String cache, @Nullable String cacheManager) {
public WebEndpointResponse<CacheEntryDescriptor> cache(@Selector String cache, @Nullable String cacheManager) {
try {
CacheEntry entry = this.delegate.cache(cache, cacheManager);
CacheEntryDescriptor entry = this.delegate.cache(cache, cacheManager);
int status = (entry != null) ? WebEndpointResponse.STATUS_OK : WebEndpointResponse.STATUS_NOT_FOUND;
return new WebEndpointResponse<>(entry, status);
}

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.context;
import java.util.Map;
import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
@ -36,19 +34,15 @@ import org.springframework.context.ConfigurableApplicationContext;
@Endpoint(id = "shutdown", enableByDefault = false)
public class ShutdownEndpoint implements ApplicationContextAware {
private static final Map<String, String> NO_CONTEXT_MESSAGE = Map.of("message", "No context to shutdown.");
private static final Map<String, String> SHUTDOWN_MESSAGE = Map.of("message", "Shutting down, bye...");
private ConfigurableApplicationContext context;
@WriteOperation
public Map<String, String> shutdown() {
public ShutdownDescriptor shutdown() {
if (this.context == null) {
return NO_CONTEXT_MESSAGE;
return ShutdownDescriptor.NO_CONTEXT;
}
try {
return SHUTDOWN_MESSAGE;
return ShutdownDescriptor.DEFAULT;
}
finally {
Thread thread = new Thread(this::performShutdown);
@ -74,4 +68,25 @@ public class ShutdownEndpoint implements ApplicationContextAware {
}
}
/**
* Description of the shutdown.
*/
public static class ShutdownDescriptor {
private static final ShutdownDescriptor DEFAULT = new ShutdownDescriptor("Shutting down, bye...");
private static final ShutdownDescriptor NO_CONTEXT = new ShutdownDescriptor("No context to shutdown.");
private final String message;
ShutdownDescriptor(String message) {
this.message = message;
}
public String getMessage() {
return this.message;
}
}
}

@ -125,37 +125,37 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
}
@ReadOperation
public ApplicationConfigurationProperties configurationProperties() {
public ConfigurationPropertiesDescriptor configurationProperties() {
boolean showUnsanitized = this.showValues.isShown(true);
return getConfigurationProperties(showUnsanitized);
}
ApplicationConfigurationProperties getConfigurationProperties(boolean showUnsanitized) {
ConfigurationPropertiesDescriptor getConfigurationProperties(boolean showUnsanitized) {
return getConfigurationProperties(this.context, (bean) -> true, showUnsanitized);
}
@ReadOperation
public ApplicationConfigurationProperties configurationPropertiesWithPrefix(@Selector String prefix) {
public ConfigurationPropertiesDescriptor configurationPropertiesWithPrefix(@Selector String prefix) {
boolean showUnsanitized = this.showValues.isShown(true);
return getConfigurationProperties(prefix, showUnsanitized);
}
ApplicationConfigurationProperties getConfigurationProperties(String prefix, boolean showUnsanitized) {
ConfigurationPropertiesDescriptor getConfigurationProperties(String prefix, boolean showUnsanitized) {
return getConfigurationProperties(this.context, (bean) -> bean.getAnnotation().prefix().startsWith(prefix),
showUnsanitized);
}
private ApplicationConfigurationProperties getConfigurationProperties(ApplicationContext context,
private ConfigurationPropertiesDescriptor getConfigurationProperties(ApplicationContext context,
Predicate<ConfigurationPropertiesBean> beanFilterPredicate, boolean showUnsanitized) {
ObjectMapper mapper = getObjectMapper();
Map<String, ContextConfigurationProperties> contexts = new HashMap<>();
Map<String, ContextConfigurationPropertiesDescriptor> contexts = new HashMap<>();
ApplicationContext target = context;
while (target != null) {
contexts.put(target.getId(), describeBeans(mapper, target, beanFilterPredicate, showUnsanitized));
target = target.getParent();
}
return new ApplicationConfigurationProperties(contexts);
return new ConfigurationPropertiesDescriptor(contexts);
}
private ObjectMapper getObjectMapper() {
@ -202,13 +202,13 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
builder.serializerFactory(factory);
}
private ContextConfigurationProperties describeBeans(ObjectMapper mapper, ApplicationContext context,
private ContextConfigurationPropertiesDescriptor describeBeans(ObjectMapper mapper, ApplicationContext context,
Predicate<ConfigurationPropertiesBean> beanFilterPredicate, boolean showUnsanitized) {
Map<String, ConfigurationPropertiesBean> beans = ConfigurationPropertiesBean.getAll(context);
Map<String, ConfigurationPropertiesBeanDescriptor> descriptors = beans.values().stream()
.filter(beanFilterPredicate).collect(Collectors.toMap(ConfigurationPropertiesBean::getName,
(bean) -> describeBean(mapper, bean, showUnsanitized)));
return new ContextConfigurationProperties(descriptors,
return new ContextConfigurationPropertiesDescriptor(descriptors,
(context.getParent() != null) ? context.getParent().getId() : null);
}
@ -561,36 +561,34 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
}
/**
* A description of an application's
* {@link ConfigurationProperties @ConfigurationProperties} beans. Primarily intended
* for serialization to JSON.
* Description of an application's
* {@link ConfigurationProperties @ConfigurationProperties} beans.
*/
public static final class ApplicationConfigurationProperties {
public static final class ConfigurationPropertiesDescriptor {
private final Map<String, ContextConfigurationProperties> contexts;
private final Map<String, ContextConfigurationPropertiesDescriptor> contexts;
ApplicationConfigurationProperties(Map<String, ContextConfigurationProperties> contexts) {
ConfigurationPropertiesDescriptor(Map<String, ContextConfigurationPropertiesDescriptor> contexts) {
this.contexts = contexts;
}
public Map<String, ContextConfigurationProperties> getContexts() {
public Map<String, ContextConfigurationPropertiesDescriptor> getContexts() {
return this.contexts;
}
}
/**
* A description of an application context's
* {@link ConfigurationProperties @ConfigurationProperties} beans. Primarily intended
* for serialization to JSON.
* Description of an application context's
* {@link ConfigurationProperties @ConfigurationProperties} beans.
*/
public static final class ContextConfigurationProperties {
public static final class ContextConfigurationPropertiesDescriptor {
private final Map<String, ConfigurationPropertiesBeanDescriptor> beans;
private final String parentId;
private ContextConfigurationProperties(Map<String, ConfigurationPropertiesBeanDescriptor> beans,
private ContextConfigurationPropertiesDescriptor(Map<String, ConfigurationPropertiesBeanDescriptor> beans,
String parentId) {
this.beans = beans;
this.parentId = parentId;
@ -607,8 +605,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
}
/**
* A description of a {@link ConfigurationProperties @ConfigurationProperties} bean.
* Primarily intended for serialization to JSON.
* Description of a {@link ConfigurationProperties @ConfigurationProperties} bean.
*/
public static final class ConfigurationPropertiesBeanDescriptor {

@ -18,7 +18,7 @@ package org.springframework.boot.actuate.context.properties;
import java.util.Set;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.endpoint.SecurityContext;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
@ -50,16 +50,16 @@ public class ConfigurationPropertiesReportEndpointWebExtension {
}
@ReadOperation
public ApplicationConfigurationProperties configurationProperties(SecurityContext securityContext) {
public ConfigurationPropertiesDescriptor configurationProperties(SecurityContext securityContext) {
boolean showUnsanitized = this.showValues.isShown(securityContext, this.roles);
return this.delegate.getConfigurationProperties(showUnsanitized);
}
@ReadOperation
public WebEndpointResponse<ApplicationConfigurationProperties> configurationPropertiesWithPrefix(
public WebEndpointResponse<ConfigurationPropertiesDescriptor> configurationPropertiesWithPrefix(
SecurityContext securityContext, @Selector String prefix) {
boolean showUnsanitized = this.showValues.isShown(securityContext, this.roles);
ApplicationConfigurationProperties configurationProperties = this.delegate.getConfigurationProperties(prefix,
ConfigurationPropertiesDescriptor configurationProperties = this.delegate.getConfigurationProperties(prefix,
showUnsanitized);
boolean foundMatchingBeans = configurationProperties.getContexts().values().stream()
.anyMatch((context) -> !context.getBeans().isEmpty());

@ -201,7 +201,7 @@ public class EnvironmentEndpoint {
}
/**
* A description of an {@link Environment}.
* Description of an {@link Environment}.
*/
public static final class EnvironmentDescriptor {
@ -225,7 +225,7 @@ public class EnvironmentEndpoint {
}
/**
* A description of an entry of the {@link Environment}.
* Description of an entry of the {@link Environment}.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class EnvironmentEntryDescriptor {
@ -258,7 +258,7 @@ public class EnvironmentEndpoint {
}
/**
* A summary of a particular entry of the {@link Environment}.
* Description of a particular entry of the {@link Environment}.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class PropertySummaryDescriptor {
@ -283,7 +283,7 @@ public class EnvironmentEndpoint {
}
/**
* A description of a {@link PropertySource}.
* Description of a {@link PropertySource}.
*/
public static final class PropertySourceDescriptor {
@ -307,7 +307,7 @@ public class EnvironmentEndpoint {
}
/**
* A description of a particular entry of {@link PropertySource}.
* Description of a particular entry of {@link PropertySource}.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class PropertySourceEntryDescriptor {
@ -332,7 +332,7 @@ public class EnvironmentEndpoint {
}
/**
* A description of a property's value, including its origin if available.
* Description of a property's value, including its origin if available.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class PropertyValueDescriptor {

@ -21,6 +21,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.flywaydb.core.Flyway;
@ -50,50 +51,48 @@ public class FlywayEndpoint {
}
@ReadOperation
public ApplicationFlywayBeans flywayBeans() {
public FlywayBeansDescriptor flywayBeans() {
ApplicationContext target = this.context;
Map<String, ContextFlywayBeans> contextFlywayBeans = new HashMap<>();
Map<String, ContextFlywayBeansDescriptor> contextFlywayBeans = new HashMap<>();
while (target != null) {
Map<String, FlywayDescriptor> flywayBeans = new HashMap<>();
target.getBeansOfType(Flyway.class)
.forEach((name, flyway) -> flywayBeans.put(name, new FlywayDescriptor(flyway.info().all())));
ApplicationContext parent = target.getParent();
contextFlywayBeans.put(target.getId(),
new ContextFlywayBeans(flywayBeans, (parent != null) ? parent.getId() : null));
new ContextFlywayBeansDescriptor(flywayBeans, (parent != null) ? parent.getId() : null));
target = parent;
}
return new ApplicationFlywayBeans(contextFlywayBeans);
return new FlywayBeansDescriptor(contextFlywayBeans);
}
/**
* Description of an application's {@link Flyway} beans, primarily intended for
* serialization to JSON.
* Description of an application's {@link Flyway} beans.
*/
public static final class ApplicationFlywayBeans {
public static final class FlywayBeansDescriptor {
private final Map<String, ContextFlywayBeans> contexts;
private final Map<String, ContextFlywayBeansDescriptor> contexts;
private ApplicationFlywayBeans(Map<String, ContextFlywayBeans> contexts) {
private FlywayBeansDescriptor(Map<String, ContextFlywayBeansDescriptor> contexts) {
this.contexts = contexts;
}
public Map<String, ContextFlywayBeans> getContexts() {
public Map<String, ContextFlywayBeansDescriptor> getContexts() {
return this.contexts;
}
}
/**
* Description of an application context's {@link Flyway} beans, primarily intended
* for serialization to JSON.
* Description of an application context's {@link Flyway} beans.
*/
public static final class ContextFlywayBeans {
public static final class ContextFlywayBeansDescriptor {
private final Map<String, FlywayDescriptor> flywayBeans;
private final String parentId;
private ContextFlywayBeans(Map<String, FlywayDescriptor> flywayBeans, String parentId) {
private ContextFlywayBeansDescriptor(Map<String, FlywayDescriptor> flywayBeans, String parentId) {
this.flywayBeans = flywayBeans;
this.parentId = parentId;
}
@ -109,30 +108,30 @@ public class FlywayEndpoint {
}
/**
* Description of a {@link Flyway} bean, primarily intended for serialization to JSON.
* Description of a {@link Flyway} bean.
*/
public static class FlywayDescriptor {
private final List<FlywayMigration> migrations;
private final List<FlywayMigrationDescriptor> migrations;
private FlywayDescriptor(MigrationInfo[] migrations) {
this.migrations = Stream.of(migrations).map(FlywayMigration::new).toList();
this.migrations = Stream.of(migrations).map(FlywayMigrationDescriptor::new).collect(Collectors.toList());
}
public FlywayDescriptor(List<FlywayMigration> migrations) {
public FlywayDescriptor(List<FlywayMigrationDescriptor> migrations) {
this.migrations = migrations;
}
public List<FlywayMigration> getMigrations() {
public List<FlywayMigrationDescriptor> getMigrations() {
return this.migrations;
}
}
/**
* Details of a migration performed by Flyway.
* Description of a migration performed by Flyway.
*/
public static final class FlywayMigration {
public static final class FlywayMigrationDescriptor {
private final String type;
@ -154,7 +153,7 @@ public class FlywayEndpoint {
private final Integer executionTime;
private FlywayMigration(MigrationInfo info) {
private FlywayMigrationDescriptor(MigrationInfo info) {
this.type = info.getType().name();
this.checksum = info.getChecksum();
this.version = nullSafeToString(info.getVersion());

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 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.
@ -51,8 +51,7 @@ public class InfoEndpoint {
for (InfoContributor contributor : this.infoContributors) {
contributor.contribute(builder);
}
Info build = builder.build();
return build.getDetails();
return builder.build().getDetails();
}
}

@ -16,6 +16,9 @@
package org.springframework.boot.actuate.integration;
import java.util.Collection;
import java.util.Map;
import org.springframework.aot.hint.BindingReflectionHintsRegistrar;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@ -34,6 +37,8 @@ import org.springframework.integration.graph.ErrorCapableMessageHandlerNode;
import org.springframework.integration.graph.ErrorCapableRoutingNode;
import org.springframework.integration.graph.Graph;
import org.springframework.integration.graph.IntegrationGraphServer;
import org.springframework.integration.graph.IntegrationNode;
import org.springframework.integration.graph.LinkNode;
import org.springframework.integration.graph.MessageChannelNode;
import org.springframework.integration.graph.MessageGatewayNode;
import org.springframework.integration.graph.MessageHandlerNode;
@ -65,8 +70,8 @@ public class IntegrationGraphEndpoint {
}
@ReadOperation
public Graph graph() {
return this.graphServer.getGraph();
public GraphDescriptor graph() {
return new GraphDescriptor(this.graphServer.getGraph());
}
@WriteOperation
@ -91,4 +96,35 @@ public class IntegrationGraphEndpoint {
}
/**
* Description of a {@link Graph}.
*/
public static class GraphDescriptor {
private final Map<String, Object> contentDescriptor;
private final Collection<IntegrationNode> nodes;
private final Collection<LinkNode> links;
GraphDescriptor(Graph graph) {
this.contentDescriptor = graph.getContentDescriptor();
this.nodes = graph.getNodes();
this.links = graph.getLinks();
}
public Map<String, Object> getContentDescriptor() {
return this.contentDescriptor;
}
public Collection<IntegrationNode> getNodes() {
return this.nodes;
}
public Collection<LinkNode> getLinks() {
return this.links;
}
}
}

@ -55,23 +55,23 @@ public class LiquibaseEndpoint {
}
@ReadOperation
public ApplicationLiquibaseBeans liquibaseBeans() {
public LiquibaseBeansDescriptor liquibaseBeans() {
ApplicationContext target = this.context;
Map<String, ContextLiquibaseBeans> contextBeans = new HashMap<>();
Map<String, ContextLiquibaseBeansDescriptor> contextBeans = new HashMap<>();
while (target != null) {
Map<String, LiquibaseBean> liquibaseBeans = new HashMap<>();
Map<String, LiquibaseBeanDescriptor> liquibaseBeans = new HashMap<>();
DatabaseFactory factory = DatabaseFactory.getInstance();
target.getBeansOfType(SpringLiquibase.class)
.forEach((name, liquibase) -> liquibaseBeans.put(name, createReport(liquibase, factory)));
ApplicationContext parent = target.getParent();
contextBeans.put(target.getId(),
new ContextLiquibaseBeans(liquibaseBeans, (parent != null) ? parent.getId() : null));
new ContextLiquibaseBeansDescriptor(liquibaseBeans, (parent != null) ? parent.getId() : null));
target = parent;
}
return new ApplicationLiquibaseBeans(contextBeans);
return new LiquibaseBeansDescriptor(contextBeans);
}
private LiquibaseBean createReport(SpringLiquibase liquibase, DatabaseFactory factory) {
private LiquibaseBeanDescriptor createReport(SpringLiquibase liquibase, DatabaseFactory factory) {
try {
DataSource dataSource = liquibase.getDataSource();
JdbcConnection connection = new JdbcConnection(dataSource.getConnection());
@ -86,7 +86,8 @@ public class LiquibaseEndpoint {
database.setDatabaseChangeLogLockTableName(liquibase.getDatabaseChangeLogLockTable());
StandardChangeLogHistoryService service = new StandardChangeLogHistoryService();
service.setDatabase(database);
return new LiquibaseBean(service.getRanChangeSets().stream().map(ChangeSet::new).toList());
return new LiquibaseBeanDescriptor(
service.getRanChangeSets().stream().map(ChangeSetDescriptor::new).toList());
}
finally {
if (database != null) {
@ -103,39 +104,37 @@ public class LiquibaseEndpoint {
}
/**
* Description of an application's {@link SpringLiquibase} beans, primarily intended
* for serialization to JSON.
* Description of an application's {@link SpringLiquibase} beans.
*/
public static final class ApplicationLiquibaseBeans {
public static final class LiquibaseBeansDescriptor {
private final Map<String, ContextLiquibaseBeans> contexts;
private final Map<String, ContextLiquibaseBeansDescriptor> contexts;
private ApplicationLiquibaseBeans(Map<String, ContextLiquibaseBeans> contexts) {
private LiquibaseBeansDescriptor(Map<String, ContextLiquibaseBeansDescriptor> contexts) {
this.contexts = contexts;
}
public Map<String, ContextLiquibaseBeans> getContexts() {
public Map<String, ContextLiquibaseBeansDescriptor> getContexts() {
return this.contexts;
}
}
/**
* Description of an application context's {@link SpringLiquibase} beans, primarily
* intended for serialization to JSON.
* Description of an application context's {@link SpringLiquibase} beans.
*/
public static final class ContextLiquibaseBeans {
public static final class ContextLiquibaseBeansDescriptor {
private final Map<String, LiquibaseBean> liquibaseBeans;
private final Map<String, LiquibaseBeanDescriptor> liquibaseBeans;
private final String parentId;
private ContextLiquibaseBeans(Map<String, LiquibaseBean> liquibaseBeans, String parentId) {
private ContextLiquibaseBeansDescriptor(Map<String, LiquibaseBeanDescriptor> liquibaseBeans, String parentId) {
this.liquibaseBeans = liquibaseBeans;
this.parentId = parentId;
}
public Map<String, LiquibaseBean> getLiquibaseBeans() {
public Map<String, LiquibaseBeanDescriptor> getLiquibaseBeans() {
return this.liquibaseBeans;
}
@ -146,27 +145,26 @@ public class LiquibaseEndpoint {
}
/**
* Description of a {@link SpringLiquibase} bean, primarily intended for serialization
* to JSON.
* Description of a {@link SpringLiquibase} bean.
*/
public static final class LiquibaseBean {
public static final class LiquibaseBeanDescriptor {
private final List<ChangeSet> changeSets;
private final List<ChangeSetDescriptor> changeSets;
public LiquibaseBean(List<ChangeSet> changeSets) {
public LiquibaseBeanDescriptor(List<ChangeSetDescriptor> changeSets) {
this.changeSets = changeSets;
}
public List<ChangeSet> getChangeSets() {
public List<ChangeSetDescriptor> getChangeSets() {
return this.changeSets;
}
}
/**
* A Liquibase change set.
* Description of a Liquibase change set.
*/
public static class ChangeSet {
public static class ChangeSetDescriptor {
private final String author;
@ -194,7 +192,7 @@ public class LiquibaseEndpoint {
private final String tag;
public ChangeSet(RanChangeSet ranChangeSet) {
public ChangeSetDescriptor(RanChangeSet ranChangeSet) {
this.author = ranChangeSet.getAuthor();
this.changeLog = ranChangeSet.getChangeLog();
this.comments = ranChangeSet.getComments();
@ -266,13 +264,13 @@ public class LiquibaseEndpoint {
}
/**
* A context expression in a {@link ChangeSet}.
* Description of a context expression in a {@link ChangeSetDescriptor}.
*/
public static class ContextExpression {
public static class ContextExpressionDescriptor {
private final Set<String> contexts;
public ContextExpression(Set<String> contexts) {
public ContextExpressionDescriptor(Set<String> contexts) {
this.contexts = contexts;
}

@ -17,7 +17,6 @@
package org.springframework.boot.actuate.logging;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -30,8 +29,8 @@ import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.boot.actuate.logging.LoggersEndpoint.GroupLoggerLevels;
import org.springframework.boot.actuate.logging.LoggersEndpoint.SingleLoggerLevels;
import org.springframework.boot.actuate.logging.LoggersEndpoint.GroupLoggerLevelsDescriptor;
import org.springframework.boot.actuate.logging.LoggersEndpoint.SingleLoggerLevelsDescriptor;
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.logging.LoggerConfiguration;
import org.springframework.boot.logging.LoggerGroup;
@ -49,7 +48,7 @@ import org.springframework.util.Assert;
* @since 2.0.0
*/
@Endpoint(id = "loggers")
@RegisterReflectionForBinding({ GroupLoggerLevels.class, SingleLoggerLevels.class })
@RegisterReflectionForBinding({ GroupLoggerLevelsDescriptor.class, SingleLoggerLevelsDescriptor.class })
public class LoggersEndpoint {
private final LoggingSystem loggingSystem;
@ -69,34 +68,30 @@ public class LoggersEndpoint {
}
@ReadOperation
public Map<String, Object> loggers() {
public LoggersDescriptor loggers() {
Collection<LoggerConfiguration> configurations = this.loggingSystem.getLoggerConfigurations();
if (configurations == null) {
return Collections.emptyMap();
return LoggersDescriptor.NONE;
}
Map<String, Object> result = new LinkedHashMap<>();
result.put("levels", getLevels());
result.put("loggers", getLoggers(configurations));
result.put("groups", getGroups());
return result;
return new LoggersDescriptor(getLevels(), getLoggers(configurations), getGroups());
}
private Map<String, LoggerLevels> getGroups() {
Map<String, LoggerLevels> groups = new LinkedHashMap<>();
private Map<String, GroupLoggerLevelsDescriptor> getGroups() {
Map<String, GroupLoggerLevelsDescriptor> groups = new LinkedHashMap<>();
this.loggerGroups.forEach((group) -> groups.put(group.getName(),
new GroupLoggerLevels(group.getConfiguredLevel(), group.getMembers())));
new GroupLoggerLevelsDescriptor(group.getConfiguredLevel(), group.getMembers())));
return groups;
}
@ReadOperation
public LoggerLevels loggerLevels(@Selector String name) {
public LoggerLevelsDescriptor loggerLevels(@Selector String name) {
Assert.notNull(name, "Name must not be null");
LoggerGroup group = this.loggerGroups.get(name);
if (group != null) {
return new GroupLoggerLevels(group.getConfiguredLevel(), group.getMembers());
return new GroupLoggerLevelsDescriptor(group.getConfiguredLevel(), group.getMembers());
}
LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration(name);
return (configuration != null) ? new SingleLoggerLevels(configuration) : null;
return (configuration != null) ? new SingleLoggerLevelsDescriptor(configuration) : null;
}
@WriteOperation
@ -115,22 +110,59 @@ public class LoggersEndpoint {
return new TreeSet<>(levels).descendingSet();
}
private Map<String, LoggerLevels> getLoggers(Collection<LoggerConfiguration> configurations) {
Map<String, LoggerLevels> loggers = new LinkedHashMap<>(configurations.size());
private Map<String, LoggerLevelsDescriptor> getLoggers(Collection<LoggerConfiguration> configurations) {
Map<String, LoggerLevelsDescriptor> loggers = new LinkedHashMap<>(configurations.size());
for (LoggerConfiguration configuration : configurations) {
loggers.put(configuration.getName(), new SingleLoggerLevels(configuration));
loggers.put(configuration.getName(), new SingleLoggerLevelsDescriptor(configuration));
}
return loggers;
}
/**
* Levels configured for a given logger exposed in a JSON friendly way.
* Description of loggers.
*/
public static class LoggerLevels {
public static class LoggersDescriptor {
/**
* Empty description.
*/
public static final LoggersDescriptor NONE = new LoggersDescriptor(null, null, null);
private final NavigableSet<LogLevel> levels;
private final Map<String, LoggerLevelsDescriptor> loggers;
private final Map<String, GroupLoggerLevelsDescriptor> groups;
public LoggersDescriptor(NavigableSet<LogLevel> levels, Map<String, LoggerLevelsDescriptor> loggers,
Map<String, GroupLoggerLevelsDescriptor> groups) {
this.levels = levels;
this.loggers = loggers;
this.groups = groups;
}
public NavigableSet<LogLevel> getLevels() {
return this.levels;
}
public Map<String, LoggerLevelsDescriptor> getLoggers() {
return this.loggers;
}
public Map<String, GroupLoggerLevelsDescriptor> getGroups() {
return this.groups;
}
}
/**
* Description of levels configured for a given logger.
*/
public static class LoggerLevelsDescriptor {
private String configuredLevel;
public LoggerLevels(LogLevel configuredLevel) {
public LoggerLevelsDescriptor(LogLevel configuredLevel) {
this.configuredLevel = getName(configuredLevel);
}
@ -144,11 +176,14 @@ public class LoggersEndpoint {
}
public static class GroupLoggerLevels extends LoggerLevels {
/**
* Description of levels configured for a given group logger.
*/
public static class GroupLoggerLevelsDescriptor extends LoggerLevelsDescriptor {
private List<String> members;
public GroupLoggerLevels(LogLevel configuredLevel, List<String> members) {
public GroupLoggerLevelsDescriptor(LogLevel configuredLevel, List<String> members) {
super(configuredLevel);
this.members = members;
}
@ -159,11 +194,14 @@ public class LoggersEndpoint {
}
public static class SingleLoggerLevels extends LoggerLevels {
/**
* Description of levels configured for a given single logger.
*/
public static class SingleLoggerLevelsDescriptor extends LoggerLevelsDescriptor {
private String effectiveLevel;
public SingleLoggerLevels(LoggerConfiguration configuration) {
public SingleLoggerLevelsDescriptor(LoggerConfiguration configuration) {
super(configuration.getConfiguredLevel());
this.effectiveLevel = getName(configuration.getEffectiveLevel());
}

@ -52,7 +52,7 @@ public class ThreadDumpEndpoint {
}
/**
* A description of a thread dump. Primarily intended for serialization to JSON.
* Description of a thread dump.
*/
public static final class ThreadDumpDescriptor {

@ -56,10 +56,10 @@ public class MetricsEndpoint {
}
@ReadOperation
public ListNamesResponse listNames() {
public MetricNamesDescriptor listNames() {
Set<String> names = new TreeSet<>();
collectNames(names, this.registry);
return new ListNamesResponse(names);
return new MetricNamesDescriptor(names);
}
private void collectNames(Set<String> names, MeterRegistry registry) {
@ -76,7 +76,7 @@ public class MetricsEndpoint {
}
@ReadOperation
public MetricResponse metric(@Selector String requiredMetricName, @Nullable List<String> tag) {
public MetricDescriptor metric(@Selector String requiredMetricName, @Nullable List<String> tag) {
List<Tag> tags = parseTags(tag);
Collection<Meter> meters = findFirstMatchingMeters(this.registry, requiredMetricName, tags);
if (meters.isEmpty()) {
@ -86,7 +86,7 @@ public class MetricsEndpoint {
Map<String, Set<String>> availableTags = getAvailableTags(meters);
tags.forEach((t) -> availableTags.remove(t.getKey()));
Meter.Id meterId = meters.iterator().next().getId();
return new MetricResponse(requiredMetricName, meterId.getDescription(), meterId.getBaseUnit(),
return new MetricDescriptor(requiredMetricName, meterId.getDescription(), meterId.getBaseUnit(),
asList(samples, Sample::new), asList(availableTags, AvailableTag::new));
}
@ -157,13 +157,13 @@ public class MetricsEndpoint {
}
/**
* Response payload for a metric name listing.
* Description of metric names.
*/
public static final class ListNamesResponse {
public static final class MetricNamesDescriptor {
private final Set<String> names;
ListNamesResponse(Set<String> names) {
MetricNamesDescriptor(Set<String> names) {
this.names = names;
}
@ -174,9 +174,9 @@ public class MetricsEndpoint {
}
/**
* Response payload for a metric name selector.
* Description of a metric.
*/
public static final class MetricResponse {
public static final class MetricDescriptor {
private final String name;
@ -188,7 +188,7 @@ public class MetricsEndpoint {
private final List<AvailableTag> availableTags;
MetricResponse(String name, String description, String baseUnit, List<Sample> measurements,
MetricDescriptor(String name, String description, String baseUnit, List<Sample> measurements,
List<AvailableTag> availableTags) {
this.name = name;
this.description = description;

@ -84,9 +84,9 @@ public class QuartzEndpoint {
* @throws SchedulerException if retrieving the information from the scheduler failed
*/
@ReadOperation
public QuartzReport quartzReport() throws SchedulerException {
return new QuartzReport(new GroupNames(this.scheduler.getJobGroupNames()),
new GroupNames(this.scheduler.getTriggerGroupNames()));
public QuartzDescriptor quartzReport() throws SchedulerException {
return new QuartzDescriptor(new GroupNamesDescriptor(this.scheduler.getJobGroupNames()),
new GroupNamesDescriptor(this.scheduler.getTriggerGroupNames()));
}
/**
@ -94,14 +94,14 @@ public class QuartzEndpoint {
* @return the available job names
* @throws SchedulerException if retrieving the information from the scheduler failed
*/
public QuartzGroups quartzJobGroups() throws SchedulerException {
public QuartzGroupsDescriptor quartzJobGroups() throws SchedulerException {
Map<String, Object> result = new LinkedHashMap<>();
for (String groupName : this.scheduler.getJobGroupNames()) {
List<String> jobs = this.scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName)).stream()
.map((key) -> key.getName()).toList();
result.put(groupName, Collections.singletonMap("jobs", jobs));
}
return new QuartzGroups(result);
return new QuartzGroupsDescriptor(result);
}
/**
@ -109,7 +109,7 @@ public class QuartzEndpoint {
* @return the available trigger names
* @throws SchedulerException if retrieving the information from the scheduler failed
*/
public QuartzGroups quartzTriggerGroups() throws SchedulerException {
public QuartzGroupsDescriptor quartzTriggerGroups() throws SchedulerException {
Map<String, Object> result = new LinkedHashMap<>();
Set<String> pausedTriggerGroups = this.scheduler.getPausedTriggerGroups();
for (String groupName : this.scheduler.getTriggerGroupNames()) {
@ -119,7 +119,7 @@ public class QuartzEndpoint {
.stream().map((key) -> key.getName()).toList());
result.put(groupName, groupDetails);
}
return new QuartzGroups(result);
return new QuartzGroupsDescriptor(result);
}
/**
@ -129,16 +129,16 @@ public class QuartzEndpoint {
* @return a summary of the jobs in the given {@code group}
* @throws SchedulerException if retrieving the information from the scheduler failed
*/
public QuartzJobGroupSummary quartzJobGroupSummary(String group) throws SchedulerException {
public QuartzJobGroupSummaryDescriptor quartzJobGroupSummary(String group) throws SchedulerException {
List<JobDetail> jobs = findJobsByGroup(group);
if (jobs.isEmpty() && !this.scheduler.getJobGroupNames().contains(group)) {
return null;
}
Map<String, QuartzJobSummary> result = new LinkedHashMap<>();
Map<String, QuartzJobSummaryDescriptor> result = new LinkedHashMap<>();
for (JobDetail job : jobs) {
result.put(job.getKey().getName(), QuartzJobSummary.of(job));
result.put(job.getKey().getName(), QuartzJobSummaryDescriptor.of(job));
}
return new QuartzJobGroupSummary(group, result);
return new QuartzJobGroupSummaryDescriptor(group, result);
}
private List<JobDetail> findJobsByGroup(String group) throws SchedulerException {
@ -157,20 +157,20 @@ public class QuartzEndpoint {
* @return a summary of the triggers in the given {@code group}
* @throws SchedulerException if retrieving the information from the scheduler failed
*/
public QuartzTriggerGroupSummary quartzTriggerGroupSummary(String group) throws SchedulerException {
public QuartzTriggerGroupSummaryDescriptor quartzTriggerGroupSummary(String group) throws SchedulerException {
List<Trigger> triggers = findTriggersByGroup(group);
if (triggers.isEmpty() && !this.scheduler.getTriggerGroupNames().contains(group)) {
return null;
}
Map<TriggerType, Map<String, Object>> result = new LinkedHashMap<>();
triggers.forEach((trigger) -> {
TriggerDescription triggerDescription = TriggerDescription.of(trigger);
Map<String, Object> triggerTypes = result.computeIfAbsent(triggerDescription.getType(),
TriggerDescriptor triggerDescriptor = TriggerDescriptor.of(trigger);
Map<String, Object> triggerTypes = result.computeIfAbsent(triggerDescriptor.getType(),
(key) -> new LinkedHashMap<>());
triggerTypes.put(trigger.getKey().getName(), triggerDescription.buildSummary(true));
triggerTypes.put(trigger.getKey().getName(), triggerDescriptor.buildSummary(true));
});
boolean paused = this.scheduler.getPausedTriggerGroups().contains(group);
return new QuartzTriggerGroupSummary(group, paused, result);
return new QuartzTriggerGroupSummaryDescriptor(group, paused, result);
}
private List<Trigger> findTriggersByGroup(String group) throws SchedulerException {
@ -183,21 +183,21 @@ public class QuartzEndpoint {
}
/**
* Return the {@link QuartzJobDetails details of the job} identified with the given
* group name and job name.
* Return the {@link QuartzJobDetailsDescriptor details of the job} identified with
* the given group name and job name.
* @param groupName the name of the group
* @param jobName the name of the job
* @param showUnsanitized whether to sanitize values in data map
* @return the details of the job or {@code null} if such job does not exist
* @throws SchedulerException if retrieving the information from the scheduler failed
*/
public QuartzJobDetails quartzJob(String groupName, String jobName, boolean showUnsanitized)
public QuartzJobDetailsDescriptor quartzJob(String groupName, String jobName, boolean showUnsanitized)
throws SchedulerException {
JobKey jobKey = JobKey.jobKey(jobName, groupName);
JobDetail jobDetail = this.scheduler.getJobDetail(jobKey);
if (jobDetail != null) {
List<? extends Trigger> triggers = this.scheduler.getTriggersOfJob(jobKey);
return new QuartzJobDetails(jobDetail.getKey().getGroup(), jobDetail.getKey().getName(),
return new QuartzJobDetailsDescriptor(jobDetail.getKey().getGroup(), jobDetail.getKey().getName(),
jobDetail.getDescription(), jobDetail.getJobClass().getName(), jobDetail.isDurable(),
jobDetail.requestsRecovery(), sanitizeJobDataMap(jobDetail.getJobDataMap(), showUnsanitized),
extractTriggersSummary(triggers));
@ -213,7 +213,7 @@ public class QuartzEndpoint {
Map<String, Object> triggerSummary = new LinkedHashMap<>();
triggerSummary.put("group", trigger.getKey().getGroup());
triggerSummary.put("name", trigger.getKey().getName());
triggerSummary.putAll(TriggerDescription.of(trigger).buildSummary(false));
triggerSummary.putAll(TriggerDescriptor.of(trigger).buildSummary(false));
result.add(triggerSummary);
});
return result;
@ -232,10 +232,12 @@ public class QuartzEndpoint {
throws SchedulerException {
TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, groupName);
Trigger trigger = this.scheduler.getTrigger(triggerKey);
return (trigger != null)
? TriggerDescription.of(trigger).buildDetails(this.scheduler.getTriggerState(triggerKey),
sanitizeJobDataMap(trigger.getJobDataMap(), showUnsanitized))
: null;
if (trigger == null) {
return null;
}
TriggerState triggerState = this.scheduler.getTriggerState(triggerKey);
return TriggerDescriptor.of(trigger).buildDetails(triggerState,
sanitizeJobDataMap(trigger.getJobDataMap(), showUnsanitized));
}
private static Duration getIntervalDuration(long amount, IntervalUnit unit) {
@ -275,38 +277,37 @@ public class QuartzEndpoint {
}
/**
* A report of available job and trigger group names, primarily intended for
* serialization to JSON.
* Description of available job and trigger group names.
*/
public static final class QuartzReport {
public static final class QuartzDescriptor {
private final GroupNames jobs;
private final GroupNamesDescriptor jobs;
private final GroupNames triggers;
private final GroupNamesDescriptor triggers;
QuartzReport(GroupNames jobs, GroupNames triggers) {
QuartzDescriptor(GroupNamesDescriptor jobs, GroupNamesDescriptor triggers) {
this.jobs = jobs;
this.triggers = triggers;
}
public GroupNames getJobs() {
public GroupNamesDescriptor getJobs() {
return this.jobs;
}
public GroupNames getTriggers() {
public GroupNamesDescriptor getTriggers() {
return this.triggers;
}
}
/**
* A set of group names, primarily intended for serialization to JSON.
* Description of group names.
*/
public static class GroupNames {
public static class GroupNamesDescriptor {
private final Set<String> groups;
public GroupNames(List<String> groups) {
public GroupNamesDescriptor(List<String> groups) {
this.groups = new LinkedHashSet<>(groups);
}
@ -317,14 +318,13 @@ public class QuartzEndpoint {
}
/**
* A summary for each group identified by name, primarily intended for serialization
* to JSON.
* Description of each group identified by name.
*/
public static class QuartzGroups {
public static class QuartzGroupsDescriptor {
private final Map<String, Object> groups;
public QuartzGroups(Map<String, Object> groups) {
public QuartzGroupsDescriptor(Map<String, Object> groups) {
this.groups = groups;
}
@ -335,15 +335,15 @@ public class QuartzEndpoint {
}
/**
* A summary report of the {@link JobDetail jobs} in a given group.
* Description of the {@link JobDetail jobs} in a given group.
*/
public static final class QuartzJobGroupSummary {
public static final class QuartzJobGroupSummaryDescriptor {
private final String group;
private final Map<String, QuartzJobSummary> jobs;
private final Map<String, QuartzJobSummaryDescriptor> jobs;
private QuartzJobGroupSummary(String group, Map<String, QuartzJobSummary> jobs) {
private QuartzJobGroupSummaryDescriptor(String group, Map<String, QuartzJobSummaryDescriptor> jobs) {
this.group = group;
this.jobs = jobs;
}
@ -352,25 +352,25 @@ public class QuartzEndpoint {
return this.group;
}
public Map<String, QuartzJobSummary> getJobs() {
public Map<String, QuartzJobSummaryDescriptor> getJobs() {
return this.jobs;
}
}
/**
* Details of a {@link Job Quartz Job}, primarily intended for serialization to JSON.
* Description of a {@link Job Quartz Job}.
*/
public static final class QuartzJobSummary {
public static final class QuartzJobSummaryDescriptor {
private final String className;
private QuartzJobSummary(JobDetail job) {
private QuartzJobSummaryDescriptor(JobDetail job) {
this.className = job.getJobClass().getName();
}
private static QuartzJobSummary of(JobDetail job) {
return new QuartzJobSummary(job);
private static QuartzJobSummaryDescriptor of(JobDetail job) {
return new QuartzJobSummaryDescriptor(job);
}
public String getClassName() {
@ -380,9 +380,9 @@ public class QuartzEndpoint {
}
/**
* Details of a {@link Job Quartz Job}, primarily intended for serialization to JSON.
* Description of a {@link Job Quartz Job}.
*/
public static final class QuartzJobDetails {
public static final class QuartzJobDetailsDescriptor {
private final String group;
@ -400,7 +400,7 @@ public class QuartzEndpoint {
private final List<Map<String, Object>> triggers;
QuartzJobDetails(String group, String name, String description, String className, boolean durable,
QuartzJobDetailsDescriptor(String group, String name, String description, String className, boolean durable,
boolean requestRecovery, Map<String, Object> data, List<Map<String, Object>> triggers) {
this.group = group;
this.name = name;
@ -447,9 +447,9 @@ public class QuartzEndpoint {
}
/**
* A summary report of the {@link Trigger triggers} in a given group.
* Description of the {@link Trigger triggers} in a given group.
*/
public static final class QuartzTriggerGroupSummary {
public static final class QuartzTriggerGroupSummaryDescriptor {
private final String group;
@ -457,7 +457,7 @@ public class QuartzEndpoint {
private final Triggers triggers;
private QuartzTriggerGroupSummary(String group, boolean paused,
private QuartzTriggerGroupSummaryDescriptor(String group, boolean paused,
Map<TriggerType, Map<String, Object>> descriptionsByType) {
this.group = group;
this.paused = paused;
@ -550,30 +550,30 @@ public class QuartzEndpoint {
/**
* Base class for descriptions of a {@link Trigger}.
*/
public abstract static class TriggerDescription {
public abstract static class TriggerDescriptor {
private static final Map<Class<? extends Trigger>, Function<Trigger, TriggerDescription>> DESCRIBERS = new LinkedHashMap<>();
private static final Map<Class<? extends Trigger>, Function<Trigger, TriggerDescriptor>> DESCRIBERS = new LinkedHashMap<>();
static {
DESCRIBERS.put(CronTrigger.class, (trigger) -> new CronTriggerDescription((CronTrigger) trigger));
DESCRIBERS.put(SimpleTrigger.class, (trigger) -> new SimpleTriggerDescription((SimpleTrigger) trigger));
DESCRIBERS.put(CronTrigger.class, (trigger) -> new CronTriggerDescriptor((CronTrigger) trigger));
DESCRIBERS.put(SimpleTrigger.class, (trigger) -> new SimpleTriggerDescriptor((SimpleTrigger) trigger));
DESCRIBERS.put(DailyTimeIntervalTrigger.class,
(trigger) -> new DailyTimeIntervalTriggerDescription((DailyTimeIntervalTrigger) trigger));
(trigger) -> new DailyTimeIntervalTriggerDescriptor((DailyTimeIntervalTrigger) trigger));
DESCRIBERS.put(CalendarIntervalTrigger.class,
(trigger) -> new CalendarIntervalTriggerDescription((CalendarIntervalTrigger) trigger));
(trigger) -> new CalendarIntervalTriggerDescriptor((CalendarIntervalTrigger) trigger));
}
private final Trigger trigger;
private final TriggerType type;
private static TriggerDescription of(Trigger trigger) {
private static TriggerDescriptor of(Trigger trigger) {
return DESCRIBERS.entrySet().stream().filter((entry) -> entry.getKey().isInstance(trigger))
.map((entry) -> entry.getValue().apply(trigger)).findFirst()
.orElse(new CustomTriggerDescription(trigger));
.orElse(new CustomTriggerDescriptor(trigger));
}
protected TriggerDescription(Trigger trigger, TriggerType type) {
protected TriggerDescriptor(Trigger trigger, TriggerType type) {
this.trigger = trigger;
this.type = type;
}
@ -653,13 +653,13 @@ public class QuartzEndpoint {
}
/**
* A description of a {@link CronTrigger}.
* Description of a {@link CronTrigger}.
*/
public static final class CronTriggerDescription extends TriggerDescription {
public static final class CronTriggerDescriptor extends TriggerDescriptor {
private final CronTrigger trigger;
public CronTriggerDescription(CronTrigger trigger) {
public CronTriggerDescriptor(CronTrigger trigger) {
super(trigger, TriggerType.CRON);
this.trigger = trigger;
}
@ -678,13 +678,13 @@ public class QuartzEndpoint {
}
/**
* A description of a {@link SimpleTrigger}.
* Description of a {@link SimpleTrigger}.
*/
public static final class SimpleTriggerDescription extends TriggerDescription {
public static final class SimpleTriggerDescriptor extends TriggerDescriptor {
private final SimpleTrigger trigger;
public SimpleTriggerDescription(SimpleTrigger trigger) {
public SimpleTriggerDescriptor(SimpleTrigger trigger) {
super(trigger, TriggerType.SIMPLE);
this.trigger = trigger;
}
@ -704,13 +704,13 @@ public class QuartzEndpoint {
}
/**
* A description of a {@link DailyTimeIntervalTrigger}.
* Description of a {@link DailyTimeIntervalTrigger}.
*/
public static final class DailyTimeIntervalTriggerDescription extends TriggerDescription {
public static final class DailyTimeIntervalTriggerDescriptor extends TriggerDescriptor {
private final DailyTimeIntervalTrigger trigger;
public DailyTimeIntervalTriggerDescription(DailyTimeIntervalTrigger trigger) {
public DailyTimeIntervalTriggerDescriptor(DailyTimeIntervalTrigger trigger) {
super(trigger, TriggerType.DAILY_INTERVAL);
this.trigger = trigger;
}
@ -735,13 +735,13 @@ public class QuartzEndpoint {
}
/**
* A description of a {@link CalendarIntervalTrigger}.
* Description of a {@link CalendarIntervalTrigger}.
*/
public static final class CalendarIntervalTriggerDescription extends TriggerDescription {
public static final class CalendarIntervalTriggerDescriptor extends TriggerDescriptor {
private final CalendarIntervalTrigger trigger;
public CalendarIntervalTriggerDescription(CalendarIntervalTrigger trigger) {
public CalendarIntervalTriggerDescriptor(CalendarIntervalTrigger trigger) {
super(trigger, TriggerType.CALENDAR_INTERVAL);
this.trigger = trigger;
}
@ -766,11 +766,11 @@ public class QuartzEndpoint {
}
/**
* A description of a custom {@link Trigger}.
* Description of a custom {@link Trigger}.
*/
public static final class CustomTriggerDescription extends TriggerDescription {
public static final class CustomTriggerDescriptor extends TriggerDescriptor {
public CustomTriggerDescription(Trigger trigger) {
public CustomTriggerDescriptor(Trigger trigger) {
super(trigger, TriggerType.CUSTOM_TRIGGER);
}

@ -29,10 +29,10 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExtension;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzGroups;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobGroupSummary;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzGroupsDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetailsDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobGroupSummaryDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummaryDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpointWebExtension.QuartzEndpointWebExtensionRuntimeHints;
import org.springframework.context.annotation.ImportRuntimeHints;
@ -59,7 +59,7 @@ public class QuartzEndpointWebExtension {
}
@ReadOperation
public WebEndpointResponse<QuartzGroups> quartzJobOrTriggerGroups(@Selector String jobsOrTriggers)
public WebEndpointResponse<QuartzGroupsDescriptor> quartzJobOrTriggerGroups(@Selector String jobsOrTriggers)
throws SchedulerException {
return handle(jobsOrTriggers, this.delegate::quartzJobGroups, this.delegate::quartzTriggerGroups);
}
@ -110,8 +110,9 @@ public class QuartzEndpointWebExtension {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
this.bindingRegistrar.registerReflectionHints(hints.reflection(), QuartzGroups.class,
QuartzJobDetails.class, QuartzJobGroupSummary.class, QuartzTriggerGroupSummary.class);
this.bindingRegistrar.registerReflectionHints(hints.reflection(), QuartzGroupsDescriptor.class,
QuartzJobDetailsDescriptor.class, QuartzJobGroupSummaryDescriptor.class,
QuartzTriggerGroupSummaryDescriptor.class);
}
}

@ -64,48 +64,47 @@ public class ScheduledTasksEndpoint {
}
@ReadOperation
public ScheduledTasksReport scheduledTasks() {
Map<TaskType, List<TaskDescription>> descriptionsByType = this.scheduledTaskHolders.stream()
public ScheduledTasksDescriptor scheduledTasks() {
Map<TaskType, List<TaskDescriptor>> descriptionsByType = this.scheduledTaskHolders.stream()
.flatMap((holder) -> holder.getScheduledTasks().stream()).map(ScheduledTask::getTask)
.map(TaskDescription::of).filter(Objects::nonNull)
.collect(Collectors.groupingBy(TaskDescription::getType));
return new ScheduledTasksReport(descriptionsByType);
.map(TaskDescriptor::of).filter(Objects::nonNull)
.collect(Collectors.groupingBy(TaskDescriptor::getType));
return new ScheduledTasksDescriptor(descriptionsByType);
}
/**
* A report of an application's scheduled {@link Task Tasks}, primarily intended for
* serialization to JSON.
* Description of an application's scheduled {@link Task Tasks}.
*/
public static final class ScheduledTasksReport {
public static final class ScheduledTasksDescriptor {
private final List<TaskDescription> cron;
private final List<TaskDescriptor> cron;
private final List<TaskDescription> fixedDelay;
private final List<TaskDescriptor> fixedDelay;
private final List<TaskDescription> fixedRate;
private final List<TaskDescriptor> fixedRate;
private final List<TaskDescription> custom;
private final List<TaskDescriptor> custom;
private ScheduledTasksReport(Map<TaskType, List<TaskDescription>> descriptionsByType) {
private ScheduledTasksDescriptor(Map<TaskType, List<TaskDescriptor>> descriptionsByType) {
this.cron = descriptionsByType.getOrDefault(TaskType.CRON, Collections.emptyList());
this.fixedDelay = descriptionsByType.getOrDefault(TaskType.FIXED_DELAY, Collections.emptyList());
this.fixedRate = descriptionsByType.getOrDefault(TaskType.FIXED_RATE, Collections.emptyList());
this.custom = descriptionsByType.getOrDefault(TaskType.CUSTOM_TRIGGER, Collections.emptyList());
}
public List<TaskDescription> getCron() {
public List<TaskDescriptor> getCron() {
return this.cron;
}
public List<TaskDescription> getFixedDelay() {
public List<TaskDescriptor> getFixedDelay() {
return this.fixedDelay;
}
public List<TaskDescription> getFixedRate() {
public List<TaskDescriptor> getFixedRate() {
return this.fixedRate;
}
public List<TaskDescription> getCustom() {
public List<TaskDescriptor> getCustom() {
return this.custom;
}
@ -114,71 +113,71 @@ public class ScheduledTasksEndpoint {
/**
* Base class for descriptions of a {@link Task}.
*/
public abstract static class TaskDescription {
public abstract static class TaskDescriptor {
private static final Map<Class<? extends Task>, Function<Task, TaskDescription>> DESCRIBERS = new LinkedHashMap<>();
private static final Map<Class<? extends Task>, Function<Task, TaskDescriptor>> DESCRIBERS = new LinkedHashMap<>();
static {
DESCRIBERS.put(FixedRateTask.class, (task) -> new FixedRateTaskDescription((FixedRateTask) task));
DESCRIBERS.put(FixedDelayTask.class, (task) -> new FixedDelayTaskDescription((FixedDelayTask) task));
DESCRIBERS.put(CronTask.class, (task) -> new CronTaskDescription((CronTask) task));
DESCRIBERS.put(FixedRateTask.class, (task) -> new FixedRateTaskDescriptor((FixedRateTask) task));
DESCRIBERS.put(FixedDelayTask.class, (task) -> new FixedDelayTaskDescriptor((FixedDelayTask) task));
DESCRIBERS.put(CronTask.class, (task) -> new CronTaskDescriptor((CronTask) task));
DESCRIBERS.put(TriggerTask.class, (task) -> describeTriggerTask((TriggerTask) task));
}
private final TaskType type;
private final RunnableDescription runnable;
private final RunnableDescriptor runnable;
private static TaskDescription of(Task task) {
private static TaskDescriptor of(Task task) {
return DESCRIBERS.entrySet().stream().filter((entry) -> entry.getKey().isInstance(task))
.map((entry) -> entry.getValue().apply(task)).findFirst().orElse(null);
}
private static TaskDescription describeTriggerTask(TriggerTask triggerTask) {
private static TaskDescriptor describeTriggerTask(TriggerTask triggerTask) {
Trigger trigger = triggerTask.getTrigger();
if (trigger instanceof CronTrigger cronTrigger) {
return new CronTaskDescription(triggerTask, cronTrigger);
return new CronTaskDescriptor(triggerTask, cronTrigger);
}
if (trigger instanceof PeriodicTrigger periodicTrigger) {
if (periodicTrigger.isFixedRate()) {
return new FixedRateTaskDescription(triggerTask, periodicTrigger);
return new FixedRateTaskDescriptor(triggerTask, periodicTrigger);
}
return new FixedDelayTaskDescription(triggerTask, periodicTrigger);
return new FixedDelayTaskDescriptor(triggerTask, periodicTrigger);
}
return new CustomTriggerTaskDescription(triggerTask);
return new CustomTriggerTaskDescriptor(triggerTask);
}
protected TaskDescription(TaskType type, Runnable runnable) {
protected TaskDescriptor(TaskType type, Runnable runnable) {
this.type = type;
this.runnable = new RunnableDescription(runnable);
this.runnable = new RunnableDescriptor(runnable);
}
private TaskType getType() {
return this.type;
}
public final RunnableDescription getRunnable() {
public final RunnableDescriptor getRunnable() {
return this.runnable;
}
}
/**
* A description of an {@link IntervalTask}.
* Description of an {@link IntervalTask}.
*/
public static class IntervalTaskDescription extends TaskDescription {
public static class IntervalTaskDescriptor extends TaskDescriptor {
private final long initialDelay;
private final long interval;
protected IntervalTaskDescription(TaskType type, IntervalTask task) {
protected IntervalTaskDescriptor(TaskType type, IntervalTask task) {
super(type, task.getRunnable());
this.initialDelay = task.getInitialDelayDuration().toMillis();
this.interval = task.getIntervalDuration().toMillis();
}
protected IntervalTaskDescription(TaskType type, TriggerTask task, PeriodicTrigger trigger) {
protected IntervalTaskDescriptor(TaskType type, TriggerTask task, PeriodicTrigger trigger) {
super(type, task.getRunnable());
this.initialDelay = trigger.getInitialDelayDuration().toMillis();
this.interval = trigger.getPeriodDuration().toMillis();
@ -195,51 +194,51 @@ public class ScheduledTasksEndpoint {
}
/**
* A description of a {@link FixedDelayTask} or a {@link TriggerTask} with a
* fixed-delay {@link PeriodicTrigger}.
* Description of a {@link FixedDelayTask} or a {@link TriggerTask} with a fixed-delay
* {@link PeriodicTrigger}.
*/
public static final class FixedDelayTaskDescription extends IntervalTaskDescription {
public static final class FixedDelayTaskDescriptor extends IntervalTaskDescriptor {
private FixedDelayTaskDescription(FixedDelayTask task) {
private FixedDelayTaskDescriptor(FixedDelayTask task) {
super(TaskType.FIXED_DELAY, task);
}
private FixedDelayTaskDescription(TriggerTask task, PeriodicTrigger trigger) {
private FixedDelayTaskDescriptor(TriggerTask task, PeriodicTrigger trigger) {
super(TaskType.FIXED_DELAY, task, trigger);
}
}
/**
* A description of a {@link FixedRateTask} or a {@link TriggerTask} with a fixed-rate
* Description of a {@link FixedRateTask} or a {@link TriggerTask} with a fixed-rate
* {@link PeriodicTrigger}.
*/
public static final class FixedRateTaskDescription extends IntervalTaskDescription {
public static final class FixedRateTaskDescriptor extends IntervalTaskDescriptor {
private FixedRateTaskDescription(FixedRateTask task) {
private FixedRateTaskDescriptor(FixedRateTask task) {
super(TaskType.FIXED_RATE, task);
}
private FixedRateTaskDescription(TriggerTask task, PeriodicTrigger trigger) {
private FixedRateTaskDescriptor(TriggerTask task, PeriodicTrigger trigger) {
super(TaskType.FIXED_RATE, task, trigger);
}
}
/**
* A description of a {@link CronTask} or a {@link TriggerTask} with a
* Description of a {@link CronTask} or a {@link TriggerTask} with a
* {@link CronTrigger}.
*/
public static final class CronTaskDescription extends TaskDescription {
public static final class CronTaskDescriptor extends TaskDescriptor {
private final String expression;
private CronTaskDescription(CronTask task) {
private CronTaskDescriptor(CronTask task) {
super(TaskType.CRON, task.getRunnable());
this.expression = task.getExpression();
}
private CronTaskDescription(TriggerTask task, CronTrigger trigger) {
private CronTaskDescriptor(TriggerTask task, CronTrigger trigger) {
super(TaskType.CRON, task.getRunnable());
this.expression = trigger.getExpression();
}
@ -251,15 +250,13 @@ public class ScheduledTasksEndpoint {
}
/**
* A description of a {@link TriggerTask} with a custom {@link Trigger}.
*
* @since 2.1.3
* Description of a {@link TriggerTask} with a custom {@link Trigger}.
*/
public static final class CustomTriggerTaskDescription extends TaskDescription {
public static final class CustomTriggerTaskDescriptor extends TaskDescriptor {
private final String trigger;
private CustomTriggerTaskDescription(TriggerTask task) {
private CustomTriggerTaskDescriptor(TriggerTask task) {
super(TaskType.CUSTOM_TRIGGER, task.getRunnable());
this.trigger = task.getTrigger().toString();
}
@ -271,15 +268,13 @@ public class ScheduledTasksEndpoint {
}
/**
* A description of a {@link Task Task's} {@link Runnable}.
*
* @author Andy Wilkinson
* Description of a {@link Task Task's} {@link Runnable}.
*/
public static final class RunnableDescription {
public static final class RunnableDescriptor {
private final String target;
private RunnableDescription(Runnable runnable) {
private RunnableDescriptor(Runnable runnable) {
if (runnable instanceof ScheduledMethodRunnable scheduledMethodRunnable) {
Method method = scheduledMethodRunnable.getMethod();
this.target = method.getDeclaringClass().getName() + "." + method.getName();
@ -307,8 +302,8 @@ public class ScheduledTasksEndpoint {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
this.bindingRegistrar.registerReflectionHints(hints.reflection(), FixedRateTaskDescription.class,
FixedDelayTaskDescription.class, CronTaskDescription.class, CustomTriggerTaskDescription.class);
this.bindingRegistrar.registerReflectionHints(hints.reflection(), FixedRateTaskDescriptor.class,
FixedDelayTaskDescriptor.class, CronTaskDescriptor.class, CustomTriggerTaskDescriptor.class);
}
}

@ -48,9 +48,9 @@ public class SessionsEndpoint {
}
@ReadOperation
public SessionsReport sessionsForUsername(String username) {
public SessionsDescriptor sessionsForUsername(String username) {
Map<String, ? extends Session> sessions = this.sessionRepository.findByPrincipalName(username);
return new SessionsReport(sessions);
return new SessionsDescriptor(sessions);
}
@ReadOperation
@ -68,14 +68,13 @@ public class SessionsEndpoint {
}
/**
* A report of user's {@link Session sessions}. Primarily intended for serialization
* to JSON.
* Description of user's {@link Session sessions}.
*/
public static final class SessionsReport {
public static final class SessionsDescriptor {
private final List<SessionDescriptor> sessions;
public SessionsReport(Map<String, ? extends Session> sessions) {
public SessionsDescriptor(Map<String, ? extends Session> sessions) {
this.sessions = sessions.values().stream().map(SessionDescriptor::new).toList();
}
@ -86,8 +85,7 @@ public class SessionsEndpoint {
}
/**
* A description of user's {@link Session session}. Primarily intended for
* serialization to JSON.
* Description of user's {@link Session session}.
*/
public static final class SessionDescriptor {

@ -54,28 +54,27 @@ public class StartupEndpoint {
}
@ReadOperation
public StartupResponse startupSnapshot() {
public StartupDescriptor startupSnapshot() {
StartupTimeline startupTimeline = this.applicationStartup.getBufferedTimeline();
return new StartupResponse(startupTimeline);
return new StartupDescriptor(startupTimeline);
}
@WriteOperation
public StartupResponse startup() {
public StartupDescriptor startup() {
StartupTimeline startupTimeline = this.applicationStartup.drainBufferedTimeline();
return new StartupResponse(startupTimeline);
return new StartupDescriptor(startupTimeline);
}
/**
* A description of an application startup, primarily intended for serialization to
* JSON.
* Description of an application startup.
*/
public static final class StartupResponse {
public static final class StartupDescriptor {
private final String springBootVersion;
private final StartupTimeline timeline;
private StartupResponse(StartupTimeline timeline) {
private StartupDescriptor(StartupTimeline timeline) {
this.timeline = timeline;
this.springBootVersion = SpringBootVersion.getVersion();
}

@ -44,19 +44,18 @@ public class HttpExchangesEndpoint {
}
@ReadOperation
public HttpExchanges httpExchanges() {
return new HttpExchanges(this.repository.findAll());
public HttpExchangesDescriptor httpExchanges() {
return new HttpExchangesDescriptor(this.repository.findAll());
}
/**
* A description of an application's {@link HttpExchange} entries. Primarily intended
* for serialization to JSON.
* Description of an application's {@link HttpExchange} entries.
*/
public static final class HttpExchanges {
public static final class HttpExchangesDescriptor {
private final List<HttpExchange> exchanges;
private HttpExchanges(List<HttpExchange> exchanges) {
private HttpExchangesDescriptor(List<HttpExchange> exchanges) {
this.exchanges = exchanges;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 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.
@ -43,53 +43,51 @@ public class MappingsEndpoint {
}
@ReadOperation
public ApplicationMappings mappings() {
public ApplicationMappingsDescriptor mappings() {
ApplicationContext target = this.context;
Map<String, ContextMappings> contextMappings = new HashMap<>();
Map<String, ContextMappingsDescriptor> contextMappings = new HashMap<>();
while (target != null) {
contextMappings.put(target.getId(), mappingsForContext(target));
target = target.getParent();
}
return new ApplicationMappings(contextMappings);
return new ApplicationMappingsDescriptor(contextMappings);
}
private ContextMappings mappingsForContext(ApplicationContext applicationContext) {
private ContextMappingsDescriptor mappingsForContext(ApplicationContext applicationContext) {
Map<String, Object> mappings = new HashMap<>();
this.descriptionProviders.forEach(
(provider) -> mappings.put(provider.getMappingName(), provider.describeMappings(applicationContext)));
return new ContextMappings(mappings,
return new ContextMappingsDescriptor(mappings,
(applicationContext.getParent() != null) ? applicationContext.getId() : null);
}
/**
* A description of an application's request mappings. Primarily intended for
* serialization to JSON.
* Description of an application's request mappings.
*/
public static final class ApplicationMappings {
public static final class ApplicationMappingsDescriptor {
private final Map<String, ContextMappings> contextMappings;
private final Map<String, ContextMappingsDescriptor> contextMappings;
private ApplicationMappings(Map<String, ContextMappings> contextMappings) {
private ApplicationMappingsDescriptor(Map<String, ContextMappingsDescriptor> contextMappings) {
this.contextMappings = contextMappings;
}
public Map<String, ContextMappings> getContexts() {
public Map<String, ContextMappingsDescriptor> getContexts() {
return this.contextMappings;
}
}
/**
* A description of an application context's request mappings. Primarily intended for
* serialization to JSON.
* Description of an application context's request mappings.
*/
public static final class ContextMappings {
public static final class ContextMappingsDescriptor {
private final Map<String, Object> mappings;
private final String parentId;
private ContextMappings(Map<String, Object> mappings, String parentId) {
private ContextMappingsDescriptor(Map<String, Object> mappings, String parentId) {
this.mappings = mappings;
this.parentId = parentId;
}

@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.actuate.beans.BeansEndpoint.ApplicationBeans;
import org.springframework.boot.actuate.beans.BeansEndpoint.BeanDescriptor;
import org.springframework.boot.actuate.beans.BeansEndpoint.ContextBeans;
import org.springframework.boot.actuate.beans.BeansEndpoint.BeansDescriptor;
import org.springframework.boot.actuate.beans.BeansEndpoint.ContextBeansDescriptor;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
@ -48,8 +48,8 @@ class BeansEndpointTests {
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withUserConfiguration(EndpointConfiguration.class);
contextRunner.run((context) -> {
ApplicationBeans result = context.getBean(BeansEndpoint.class).beans();
ContextBeans descriptor = result.getContexts().get(context.getId());
BeansDescriptor result = context.getBean(BeansEndpoint.class).beans();
ContextBeansDescriptor descriptor = result.getContexts().get(context.getId());
assertThat(descriptor.getParentId()).isNull();
Map<String, BeanDescriptor> beans = descriptor.getBeans();
assertThat(beans.size()).isLessThanOrEqualTo(context.getBeanDefinitionCount());
@ -67,8 +67,8 @@ class BeansEndpointTests {
List<String> infrastructureBeans = Stream.of(context.getBeanDefinitionNames())
.filter((name) -> BeanDefinition.ROLE_INFRASTRUCTURE == factory.getBeanDefinition(name).getRole())
.toList();
ApplicationBeans result = context.getBean(BeansEndpoint.class).beans();
ContextBeans contextDescriptor = result.getContexts().get(context.getId());
BeansDescriptor result = context.getBean(BeansEndpoint.class).beans();
ContextBeansDescriptor contextDescriptor = result.getContexts().get(context.getId());
Map<String, BeanDescriptor> beans = contextDescriptor.getBeans();
for (String infrastructureBean : infrastructureBeans) {
assertThat(beans).doesNotContainKey(infrastructureBean);
@ -81,8 +81,8 @@ class BeansEndpointTests {
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withUserConfiguration(EndpointConfiguration.class, LazyBeanConfiguration.class);
contextRunner.run((context) -> {
ApplicationBeans result = context.getBean(BeansEndpoint.class).beans();
ContextBeans contextDescriptor = result.getContexts().get(context.getId());
BeansDescriptor result = context.getBean(BeansEndpoint.class).beans();
ContextBeansDescriptor contextDescriptor = result.getContexts().get(context.getId());
assertThat(context).hasBean("lazyBean");
assertThat(contextDescriptor.getBeans()).doesNotContainKey("lazyBean");
});
@ -95,7 +95,7 @@ class BeansEndpointTests {
parentRunner.run((parent) -> {
new ApplicationContextRunner().withUserConfiguration(EndpointConfiguration.class).withParent(parent)
.run((child) -> {
ApplicationBeans result = child.getBean(BeansEndpoint.class).beans();
BeansDescriptor result = child.getBean(BeansEndpoint.class).beans();
assertThat(result.getContexts().get(parent.getId()).getBeans()).containsKey("bean");
assertThat(result.getContexts().get(child.getId()).getBeans()).containsKey("endpoint");
});

@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry;
import org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntryDescriptor;
import org.springframework.boot.actuate.cache.CachesEndpoint.CacheManagerDescriptor;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
@ -73,7 +73,7 @@ class CachesEndpointTests {
void namedCacheWithSingleCacheManager() {
CachesEndpoint endpoint = new CachesEndpoint(
Collections.singletonMap("test", new ConcurrentMapCacheManager("b", "a")));
CacheEntry entry = endpoint.cache("a", null);
CacheEntryDescriptor entry = endpoint.cache("a", null);
assertThat(entry).isNotNull();
assertThat(entry.getCacheManager()).isEqualTo("test");
assertThat(entry.getName()).isEqualTo("a");
@ -94,7 +94,7 @@ class CachesEndpointTests {
void namedCacheWithUnknownCache() {
CachesEndpoint endpoint = new CachesEndpoint(
Collections.singletonMap("test", new ConcurrentMapCacheManager("b", "a")));
CacheEntry entry = endpoint.cache("unknown", null);
CacheEntryDescriptor entry = endpoint.cache("unknown", null);
assertThat(entry).isNull();
}
@ -104,7 +104,7 @@ class CachesEndpointTests {
cacheManagers.put("test", new ConcurrentMapCacheManager("b", "a"));
cacheManagers.put("another", new ConcurrentMapCacheManager("c", "a"));
CachesEndpoint endpoint = new CachesEndpoint(cacheManagers);
CacheEntry entry = endpoint.cache("c", "test");
CacheEntryDescriptor entry = endpoint.cache("c", "test");
assertThat(entry).isNull();
}
@ -114,7 +114,7 @@ class CachesEndpointTests {
cacheManagers.put("test", new ConcurrentMapCacheManager("b", "a"));
cacheManagers.put("another", new ConcurrentMapCacheManager("c", "a"));
CachesEndpoint endpoint = new CachesEndpoint(cacheManagers);
CacheEntry entry = endpoint.cache("a", "test");
CacheEntryDescriptor entry = endpoint.cache("a", "test");
assertThat(entry).isNotNull();
assertThat(entry.getCacheManager()).isEqualTo("test");
assertThat(entry.getName()).isEqualTo("a");

@ -18,13 +18,13 @@ package org.springframework.boot.actuate.context;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.actuate.context.ShutdownEndpoint.ShutdownDescriptor;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.ApplicationListener;
@ -51,7 +51,7 @@ class ShutdownEndpointTests {
contextRunner.run((context) -> {
EndpointConfig config = context.getBean(EndpointConfig.class);
ClassLoader previousTccl = Thread.currentThread().getContextClassLoader();
Map<String, String> result;
ShutdownDescriptor result;
Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0], getClass().getClassLoader()));
try {
result = context.getBean(ShutdownEndpoint.class).shutdown();
@ -59,7 +59,7 @@ class ShutdownEndpointTests {
finally {
Thread.currentThread().setContextClassLoader(previousTccl);
}
assertThat(result.get("message")).startsWith("Shutting down");
assertThat(result.getMessage()).startsWith("Shutting down");
assertThat(((ConfigurableApplicationContext) context).isActive()).isTrue();
assertThat(config.latch.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(config.threadContextClassLoader).isEqualTo(getClass().getClassLoader());
@ -71,7 +71,7 @@ class ShutdownEndpointTests {
ConfigurableApplicationContext context = new SpringApplicationBuilder(EmptyConfig.class)
.child(EndpointConfig.class).web(WebApplicationType.NONE).run();
CountDownLatch latch = context.getBean(EndpointConfig.class).latch;
assertThat(context.getBean(ShutdownEndpoint.class).shutdown().get("message")).startsWith("Shutting down");
assertThat(context.getBean(ShutdownEndpoint.class).shutdown().getMessage()).startsWith("Shutting down");
assertThat(context.isActive()).isTrue();
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
}
@ -82,7 +82,7 @@ class ShutdownEndpointTests {
.child(EmptyConfig.class).web(WebApplicationType.NONE).run();
CountDownLatch parentLatch = context.getBean(EndpointConfig.class).latch;
CountDownLatch childLatch = context.getBean(EmptyConfig.class).latch;
assertThat(context.getBean(ShutdownEndpoint.class).shutdown().get("message")).startsWith("Shutting down");
assertThat(context.getBean(ShutdownEndpoint.class).shutdown().getMessage()).startsWith("Shutting down");
assertThat(context.isActive()).isTrue();
assertThat(parentLatch.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(childLatch.await(10, TimeUnit.SECONDS)).isTrue();

@ -21,9 +21,9 @@ import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -55,10 +55,11 @@ class ConfigurationPropertiesReportEndpointFilteringTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint
ConfigurationPropertiesDescriptor applicationProperties = endpoint
.configurationPropertiesWithPrefix("foo.");
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
ContextConfigurationPropertiesDescriptor contextProperties = applicationProperties.getContexts()
.get(context.getId());
assertThat(contextProperties.getBeans()).containsOnlyKeys("primaryFoo", "secondaryFoo");
});
}
@ -70,10 +71,11 @@ class ConfigurationPropertiesReportEndpointFilteringTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint
ConfigurationPropertiesDescriptor applicationProperties = endpoint
.configurationPropertiesWithPrefix("foo.third");
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
ContextConfigurationPropertiesDescriptor contextProperties = applicationProperties.getContexts()
.get(context.getId());
assertThat(contextProperties.getBeans()).isEmpty();
});
}
@ -98,10 +100,11 @@ class ConfigurationPropertiesReportEndpointFilteringTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint
ConfigurationPropertiesDescriptor applicationProperties = endpoint
.configurationPropertiesWithPrefix("only.bar");
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
ContextConfigurationPropertiesDescriptor contextProperties = applicationProperties.getContexts()
.get(context.getId());
Optional<String> key = contextProperties.getBeans().keySet().stream()
.filter((id) -> findIdFromPrefix("only.bar", id)).findAny();
ConfigurationPropertiesBeanDescriptor descriptor = contextProperties.getBeans().get(key.get());

@ -20,9 +20,9 @@ import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -47,9 +47,10 @@ class ConfigurationPropertiesReportEndpointMethodAnnotationsTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
ContextConfigurationPropertiesDescriptor contextProperties = applicationProperties.getContexts()
.get(context.getId());
ConfigurationPropertiesBeanDescriptor other = contextProperties.getBeans().get("other");
assertThat(other).isNotNull();
assertThat(other.getPrefix()).isEqualTo("other");
@ -65,9 +66,10 @@ class ConfigurationPropertiesReportEndpointMethodAnnotationsTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
ContextConfigurationPropertiesDescriptor contextProperties = applicationProperties.getContexts()
.get(context.getId());
ConfigurationPropertiesBeanDescriptor bar = contextProperties.getBeans().get("bar");
assertThat(bar).isNotNull();
assertThat(bar.getPrefix()).isEqualTo("other");

@ -20,7 +20,7 @@ import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -46,7 +46,7 @@ class ConfigurationPropertiesReportEndpointParentTests {
.run((child) -> {
ConfigurationPropertiesReportEndpoint endpoint = child
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
assertThat(applicationProperties.getContexts()).containsOnlyKeys(child.getId(), parent.getId());
assertThat(applicationProperties.getContexts().get(child.getId()).getBeans().keySet())
.containsExactly("someProperties");
@ -63,7 +63,7 @@ class ConfigurationPropertiesReportEndpointParentTests {
.withParent(parent).run((child) -> {
ConfigurationPropertiesReportEndpoint endpoint = child
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
assertThat(applicationProperties.getContexts().get(child.getId()).getBeans().keySet())
.containsExactlyInAnyOrder("otherProperties");
assertThat((applicationProperties.getContexts().get(parent.getId()).getBeans().keySet()))

@ -23,8 +23,8 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -59,7 +59,7 @@ class ConfigurationPropertiesReportEndpointProxyTests {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class,
SqlExecutor.class);
contextRunner.run((context) -> {
ApplicationConfigurationProperties applicationProperties = context
ConfigurationPropertiesDescriptor applicationProperties = context
.getBean(ConfigurationPropertiesReportEndpoint.class).configurationProperties();
assertThat(applicationProperties.getContexts().get(context.getId()).getBeans().values().stream()
.map(ConfigurationPropertiesBeanDescriptor::getPrefix).filter("executor.sql"::equals).findFirst())
@ -72,7 +72,7 @@ class ConfigurationPropertiesReportEndpointProxyTests {
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withUserConfiguration(ValidatedConfiguration.class).withPropertyValues("validated.name=baz");
contextRunner.run((context) -> {
ApplicationConfigurationProperties applicationProperties = context
ConfigurationPropertiesDescriptor applicationProperties = context
.getBean(ConfigurationPropertiesReportEndpoint.class).configurationProperties();
Map<String, Object> properties = applicationProperties.getContexts().get(context.getId()).getBeans()
.values().stream().map(ConfigurationPropertiesBeanDescriptor::getProperties).findFirst().get();

@ -29,8 +29,8 @@ import java.util.Map;
import com.zaxxer.hikari.HikariDataSource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
@ -63,7 +63,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor foo = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat(foo).isNotNull();
@ -83,7 +83,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor foo = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat(foo).isNotNull();
@ -102,7 +102,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor foo = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat(foo.getPrefix()).isEqualTo("foo");
@ -123,7 +123,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor cycle = applicationProperties.getContexts().get(context.getId())
.getBeans().get("cycle");
assertThat(cycle.getPrefix()).isEqualTo("cycle");
@ -142,7 +142,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor fooProperties = applicationProperties.getContexts()
.get(context.getId()).getBeans().get("foo");
assertThat(fooProperties).isNotNull();
@ -160,7 +160,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor foo = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat(foo).isNotNull();
@ -180,7 +180,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor foo = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat(foo).isNotNull();
@ -199,7 +199,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor foo = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat(foo).isNotNull();
@ -220,7 +220,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor foo = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat(foo.getPrefix()).isEqualTo("foo");
@ -240,7 +240,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor hikariDataSource = applicationProperties.getContexts()
.get(context.getId()).getBeans().get("hikariDataSource");
Map<String, Object> nestedProperties = hikariDataSource.getProperties();
@ -259,7 +259,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor descriptor = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat((Map<String, Object>) descriptor.getInputs().get("name")).containsEntry("value", "Spring Boot");
@ -277,7 +277,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesDescriptor applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor descriptor = applicationProperties.getContexts().get(context.getId())
.getBeans().get("foo");
assertThat((Map<String, Object>) descriptor.getInputs().get("name")).containsEntry("value",

@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.endpoint.SanitizingFunction;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -330,9 +330,10 @@ class ConfigurationPropertiesReportEndpointTests {
return (context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context
.getBean(ConfigurationPropertiesReportEndpoint.class);
ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties configurationProperties = endpoint
ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor configurationProperties = endpoint
.configurationProperties();
ContextConfigurationProperties allProperties = configurationProperties.getContexts().get(context.getId());
ContextConfigurationPropertiesDescriptor allProperties = configurationProperties.getContexts()
.get(context.getId());
Optional<String> key = allProperties.getBeans().keySet().stream()
.filter((id) -> findIdFromPrefix(prefix, id)).findAny();
assertThat(key).describedAs("No configuration properties with prefix '%s' found", prefix).isPresent();

@ -22,7 +22,7 @@ import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
import org.springframework.boot.actuate.endpoint.SecurityContext;
import org.springframework.boot.actuate.endpoint.Show;
@ -88,7 +88,7 @@ class ConfigurationPropertiesReportEndpointWebExtensionTests {
private void verifyPrefixed(SecurityContext securityContext, boolean showUnsanitized) {
given(this.delegate.getConfigurationProperties("test", showUnsanitized))
.willReturn(new ApplicationConfigurationProperties(Collections.emptyMap()));
.willReturn(new ConfigurationPropertiesDescriptor(Collections.emptyMap()));
this.webExtension.configurationPropertiesWithPrefix(securityContext, "test");
then(this.delegate).should().getConfigurationProperties("test", showUnsanitized);
}

@ -16,6 +16,10 @@
package org.springframework.boot.actuate.integration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import org.junit.jupiter.api.Test;
@ -23,6 +27,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.actuate.integration.IntegrationGraphEndpoint.GraphDescriptor;
import org.springframework.boot.actuate.integration.IntegrationGraphEndpoint.IntegrationGraphEndpointRuntimeHints;
import org.springframework.integration.graph.CompositeMessageHandlerNode;
import org.springframework.integration.graph.DiscardingMessageHandlerNode;
@ -34,6 +39,8 @@ import org.springframework.integration.graph.ErrorCapableMessageHandlerNode;
import org.springframework.integration.graph.ErrorCapableRoutingNode;
import org.springframework.integration.graph.Graph;
import org.springframework.integration.graph.IntegrationGraphServer;
import org.springframework.integration.graph.IntegrationNode;
import org.springframework.integration.graph.LinkNode;
import org.springframework.integration.graph.MessageChannelNode;
import org.springframework.integration.graph.MessageGatewayNode;
import org.springframework.integration.graph.MessageHandlerNode;
@ -62,10 +69,18 @@ class IntegrationGraphEndpointTests {
@Test
void readOperationShouldReturnGraph() {
Graph mockedGraph = mock(Graph.class);
Map<String, Object> contentDescriptor = new LinkedHashMap<>();
Collection<IntegrationNode> nodes = new ArrayList<>();
Collection<LinkNode> links = new ArrayList<>();
given(mockedGraph.getContentDescriptor()).willReturn(contentDescriptor);
given(mockedGraph.getNodes()).willReturn(nodes);
given(mockedGraph.getLinks()).willReturn(links);
given(this.server.getGraph()).willReturn(mockedGraph);
Graph graph = this.endpoint.graph();
GraphDescriptor graph = this.endpoint.graph();
then(this.server).should().getGraph();
assertThat(graph).isEqualTo(mockedGraph);
assertThat(graph.getContentDescriptor()).isSameAs(contentDescriptor);
assertThat(graph.getNodes()).isSameAs(nodes);
assertThat(graph.getLinks()).isSameAs(links);
}
@Test

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@ -27,7 +27,7 @@ import javax.sql.DataSource;
import liquibase.integration.spring.SpringLiquibase;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.liquibase.LiquibaseEndpoint.LiquibaseBean;
import org.springframework.boot.actuate.liquibase.LiquibaseEndpoint.LiquibaseBeanDescriptor;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
@ -60,8 +60,8 @@ class LiquibaseEndpointTests {
@Test
void liquibaseReportIsReturned() {
this.contextRunner.withUserConfiguration(Config.class).run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context.getBean(LiquibaseEndpoint.class).liquibaseBeans()
.getContexts().get(context.getId()).getLiquibaseBeans();
Map<String, LiquibaseBeanDescriptor> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
.liquibaseBeans().getContexts().get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
});
}
@ -70,8 +70,8 @@ class LiquibaseEndpointTests {
void liquibaseReportIsReturnedForContextHierarchy() {
this.contextRunner.withUserConfiguration().run((parent) -> {
this.contextRunner.withUserConfiguration(Config.class).withParent(parent).run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context.getBean(LiquibaseEndpoint.class).liquibaseBeans()
.getContexts().get(parent.getId()).getLiquibaseBeans();
Map<String, LiquibaseBeanDescriptor> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
.liquibaseBeans().getContexts().get(parent.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
});
});
@ -81,7 +81,7 @@ class LiquibaseEndpointTests {
void invokeWithCustomSchema() {
this.contextRunner.withUserConfiguration(Config.class, DataSourceWithSchemaConfiguration.class)
.withPropertyValues("spring.liquibase.default-schema=CUSTOMSCHEMA").run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
Map<String, LiquibaseBeanDescriptor> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
.liquibaseBeans().getContexts().get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
});
@ -93,7 +93,7 @@ class LiquibaseEndpointTests {
.withPropertyValues("spring.liquibase.database-change-log-lock-table=liquibase_database_changelog_lock",
"spring.liquibase.database-change-log-table=liquibase_database_changelog")
.run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
Map<String, LiquibaseBeanDescriptor> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
.liquibaseBeans().getContexts().get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
});
@ -113,7 +113,7 @@ class LiquibaseEndpointTests {
void whenMultipleLiquibaseBeansArePresentChangeSetsAreCorrectlyReportedForEachBean() {
this.contextRunner.withUserConfiguration(Config.class, MultipleDataSourceLiquibaseConfiguration.class)
.run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
Map<String, LiquibaseBeanDescriptor> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
.liquibaseBeans().getContexts().get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
assertThat(liquibaseBeans.get("liquibase").getChangeSets().get(0).getChangeLog())

@ -29,9 +29,10 @@ import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.annotation.ReflectiveRuntimeHintsRegistrar;
import org.springframework.aot.hint.predicate.ReflectionHintsPredicates;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.actuate.logging.LoggersEndpoint.GroupLoggerLevels;
import org.springframework.boot.actuate.logging.LoggersEndpoint.LoggerLevels;
import org.springframework.boot.actuate.logging.LoggersEndpoint.SingleLoggerLevels;
import org.springframework.boot.actuate.logging.LoggersEndpoint.GroupLoggerLevelsDescriptor;
import org.springframework.boot.actuate.logging.LoggersEndpoint.LoggerLevelsDescriptor;
import org.springframework.boot.actuate.logging.LoggersEndpoint.LoggersDescriptor;
import org.springframework.boot.actuate.logging.LoggersEndpoint.SingleLoggerLevelsDescriptor;
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.logging.LoggerConfiguration;
import org.springframework.boot.logging.LoggerGroups;
@ -65,35 +66,33 @@ class LoggersEndpointTests {
}
@Test
@SuppressWarnings("unchecked")
void loggersShouldReturnLoggerConfigurationsWithNoLoggerGroups() {
given(this.loggingSystem.getLoggerConfigurations())
.willReturn(Collections.singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)));
given(this.loggingSystem.getSupportedLogLevels()).willReturn(EnumSet.allOf(LogLevel.class));
Map<String, Object> result = new LoggersEndpoint(this.loggingSystem, new LoggerGroups()).loggers();
Map<String, LoggerLevels> loggers = (Map<String, LoggerLevels>) result.get("loggers");
Set<LogLevel> levels = (Set<LogLevel>) result.get("levels");
SingleLoggerLevels rootLevels = (SingleLoggerLevels) loggers.get("ROOT");
LoggersDescriptor result = new LoggersEndpoint(this.loggingSystem, new LoggerGroups()).loggers();
Map<String, LoggerLevelsDescriptor> loggers = result.getLoggers();
Set<LogLevel> levels = result.getLevels();
SingleLoggerLevelsDescriptor rootLevels = (SingleLoggerLevelsDescriptor) loggers.get("ROOT");
assertThat(rootLevels.getConfiguredLevel()).isNull();
assertThat(rootLevels.getEffectiveLevel()).isEqualTo("DEBUG");
assertThat(levels).containsExactly(LogLevel.OFF, LogLevel.FATAL, LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO,
LogLevel.DEBUG, LogLevel.TRACE);
Map<String, LoggerGroups> groups = (Map<String, LoggerGroups>) result.get("groups");
Map<String, GroupLoggerLevelsDescriptor> groups = result.getGroups();
assertThat(groups).isEmpty();
}
@Test
@SuppressWarnings("unchecked")
void loggersShouldReturnLoggerConfigurationsWithLoggerGroups() {
given(this.loggingSystem.getLoggerConfigurations())
.willReturn(Collections.singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)));
given(this.loggingSystem.getSupportedLogLevels()).willReturn(EnumSet.allOf(LogLevel.class));
Map<String, Object> result = new LoggersEndpoint(this.loggingSystem, this.loggerGroups).loggers();
Map<String, GroupLoggerLevels> loggerGroups = (Map<String, GroupLoggerLevels>) result.get("groups");
GroupLoggerLevels groupLevel = loggerGroups.get("test");
Map<String, LoggerLevels> loggers = (Map<String, LoggerLevels>) result.get("loggers");
Set<LogLevel> levels = (Set<LogLevel>) result.get("levels");
SingleLoggerLevels rootLevels = (SingleLoggerLevels) loggers.get("ROOT");
LoggersDescriptor result = new LoggersEndpoint(this.loggingSystem, this.loggerGroups).loggers();
Map<String, GroupLoggerLevelsDescriptor> loggerGroups = result.getGroups();
GroupLoggerLevelsDescriptor groupLevel = loggerGroups.get("test");
Map<String, LoggerLevelsDescriptor> loggers = result.getLoggers();
Set<LogLevel> levels = result.getLevels();
SingleLoggerLevelsDescriptor rootLevels = (SingleLoggerLevelsDescriptor) loggers.get("ROOT");
assertThat(rootLevels.getConfiguredLevel()).isNull();
assertThat(rootLevels.getEffectiveLevel()).isEqualTo("DEBUG");
assertThat(levels).containsExactly(LogLevel.OFF, LogLevel.FATAL, LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO,
@ -107,16 +106,16 @@ class LoggersEndpointTests {
void loggerLevelsWhenNameSpecifiedShouldReturnLevels() {
given(this.loggingSystem.getLoggerConfiguration("ROOT"))
.willReturn(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG));
SingleLoggerLevels levels = (SingleLoggerLevels) new LoggersEndpoint(this.loggingSystem, this.loggerGroups)
.loggerLevels("ROOT");
SingleLoggerLevelsDescriptor levels = (SingleLoggerLevelsDescriptor) new LoggersEndpoint(this.loggingSystem,
this.loggerGroups).loggerLevels("ROOT");
assertThat(levels.getConfiguredLevel()).isNull();
assertThat(levels.getEffectiveLevel()).isEqualTo("DEBUG");
}
@Test
void groupNameSpecifiedShouldReturnConfiguredLevelAndMembers() {
GroupLoggerLevels levels = (GroupLoggerLevels) new LoggersEndpoint(this.loggingSystem, this.loggerGroups)
.loggerLevels("test");
GroupLoggerLevelsDescriptor levels = (GroupLoggerLevelsDescriptor) new LoggersEndpoint(this.loggingSystem,
this.loggerGroups).loggerLevels("test");
assertThat(levels.getConfiguredLevel()).isEqualTo("DEBUG");
assertThat(levels.getMembers()).isEqualTo(Collections.singletonList("test.member"));
}
@ -150,14 +149,14 @@ class LoggersEndpointTests {
RuntimeHints runtimeHints = new RuntimeHints();
new ReflectiveRuntimeHintsRegistrar().registerRuntimeHints(runtimeHints, LoggersEndpoint.class);
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
assertThat(reflection.onType(LoggerLevels.class)).accepts(runtimeHints);
assertThat(reflection.onMethod(LoggerLevels.class, "getConfiguredLevel")).accepts(runtimeHints);
assertThat(reflection.onType(SingleLoggerLevels.class)).accepts(runtimeHints);
assertThat(reflection.onMethod(SingleLoggerLevels.class, "getEffectiveLevel")).accepts(runtimeHints);
assertThat(reflection.onMethod(SingleLoggerLevels.class, "getConfiguredLevel")).accepts(runtimeHints);
assertThat(reflection.onType(GroupLoggerLevels.class)).accepts(runtimeHints);
assertThat(reflection.onMethod(GroupLoggerLevels.class, "getMembers")).accepts(runtimeHints);
assertThat(reflection.onMethod(GroupLoggerLevels.class, "getConfiguredLevel")).accepts(runtimeHints);
assertThat(reflection.onType(LoggerLevelsDescriptor.class)).accepts(runtimeHints);
assertThat(reflection.onMethod(LoggerLevelsDescriptor.class, "getConfiguredLevel")).accepts(runtimeHints);
assertThat(reflection.onType(SingleLoggerLevelsDescriptor.class)).accepts(runtimeHints);
assertThat(reflection.onMethod(SingleLoggerLevelsDescriptor.class, "getEffectiveLevel")).accepts(runtimeHints);
assertThat(reflection.onMethod(SingleLoggerLevelsDescriptor.class, "getConfiguredLevel")).accepts(runtimeHints);
assertThat(reflection.onType(GroupLoggerLevelsDescriptor.class)).accepts(runtimeHints);
assertThat(reflection.onMethod(GroupLoggerLevelsDescriptor.class, "getMembers")).accepts(runtimeHints);
assertThat(reflection.onMethod(GroupLoggerLevelsDescriptor.class, "getConfiguredLevel")).accepts(runtimeHints);
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@ -48,7 +48,7 @@ class MetricsEndpointTests {
@Test
void listNamesHandlesEmptyListOfMeters() {
MetricsEndpoint.ListNamesResponse result = this.endpoint.listNames();
MetricsEndpoint.MetricNamesDescriptor result = this.endpoint.listNames();
assertThat(result.getNames()).isEmpty();
}
@ -61,7 +61,7 @@ class MetricsEndpointTests {
this.registry.counter("com.example.delta");
this.registry.counter("com.example.echo");
this.registry.counter("com.example.bravo");
MetricsEndpoint.ListNamesResponse result = this.endpoint.listNames();
MetricsEndpoint.MetricNamesDescriptor result = this.endpoint.listNames();
assertThat(result.getNames()).containsExactly("com.example.alpha", "com.example.bravo", "com.example.charlie",
"com.example.delta", "com.example.echo");
}
@ -84,7 +84,7 @@ class MetricsEndpointTests {
this.registry.counter("cache", "result", "hit", "host", "1").increment(2);
this.registry.counter("cache", "result", "miss", "host", "1").increment(2);
this.registry.counter("cache", "result", "hit", "host", "2").increment(2);
MetricsEndpoint.MetricResponse response = this.endpoint.metric("cache", Collections.emptyList());
MetricsEndpoint.MetricDescriptor response = this.endpoint.metric("cache", Collections.emptyList());
assertThat(response.getName()).isEqualTo("cache");
assertThat(availableTagKeys(response)).containsExactly("result", "host");
assertThat(getCount(response)).hasValue(6.0);
@ -106,7 +106,7 @@ class MetricsEndpointTests {
secondLevel.counter("cache", "result", "miss", "host", "1").increment(2);
secondLevel.counter("cache", "result", "hit", "host", "2").increment(2);
MetricsEndpoint endpoint = new MetricsEndpoint(composite);
MetricsEndpoint.MetricResponse response = endpoint.metric("cache", Collections.emptyList());
MetricsEndpoint.MetricDescriptor response = endpoint.metric("cache", Collections.emptyList());
assertThat(response.getName()).isEqualTo("cache");
assertThat(availableTagKeys(response)).containsExactly("result", "host");
assertThat(getCount(response)).hasValue(6.0);
@ -123,7 +123,7 @@ class MetricsEndpointTests {
composite.add(firstLevel);
firstLevel.add(secondLevel);
MetricsEndpoint endpoint = new MetricsEndpoint(composite);
MetricsEndpoint.MetricResponse response = endpoint.metric("invalid.metric.name", Collections.emptyList());
MetricsEndpoint.MetricDescriptor response = endpoint.metric("invalid.metric.name", Collections.emptyList());
assertThat(response).isNull();
}
@ -131,7 +131,7 @@ class MetricsEndpointTests {
void metricTagValuesAreDeduplicated() {
this.registry.counter("cache", "host", "1", "region", "east", "result", "hit");
this.registry.counter("cache", "host", "1", "region", "east", "result", "miss");
MetricsEndpoint.MetricResponse response = this.endpoint.metric("cache", Collections.singletonList("host:1"));
MetricsEndpoint.MetricDescriptor response = this.endpoint.metric("cache", Collections.singletonList("host:1"));
assertThat(response.getAvailableTags().stream().filter((t) -> t.getTag().equals("region"))
.flatMap((t) -> t.getValues().stream())).containsExactly("east");
}
@ -139,7 +139,7 @@ class MetricsEndpointTests {
@Test
void metricWithSpaceInTagValue() {
this.registry.counter("counter", "key", "a space").increment(2);
MetricsEndpoint.MetricResponse response = this.endpoint.metric("counter",
MetricsEndpoint.MetricDescriptor response = this.endpoint.metric("counter",
Collections.singletonList("key:a space"));
assertThat(response.getName()).isEqualTo("counter");
assertThat(availableTagKeys(response)).isEmpty();
@ -168,7 +168,7 @@ class MetricsEndpointTests {
@Test
void nonExistentMetric() {
MetricsEndpoint.MetricResponse response = this.endpoint.metric("does.not.exist", Collections.emptyList());
MetricsEndpoint.MetricDescriptor response = this.endpoint.metric("does.not.exist", Collections.emptyList());
assertThat(response).isNull();
}
@ -196,12 +196,12 @@ class MetricsEndpointTests {
.hasValueSatisfying((sample) -> assertThat(sample.getValue()).isEqualTo(value));
}
private Optional<Double> getCount(MetricsEndpoint.MetricResponse response) {
private Optional<Double> getCount(MetricsEndpoint.MetricDescriptor response) {
return response.getMeasurements().stream().filter((sample) -> sample.getStatistic().equals(Statistic.COUNT))
.findAny().map(MetricsEndpoint.Sample::getValue);
}
private Stream<String> availableTagKeys(MetricsEndpoint.MetricResponse response) {
private Stream<String> availableTagKeys(MetricsEndpoint.MetricDescriptor response) {
return response.getAvailableTags().stream().map(MetricsEndpoint.AvailableTag::getTag);
}

@ -62,11 +62,11 @@ import org.quartz.TriggerKey;
import org.quartz.impl.matchers.GroupMatcher;
import org.quartz.spi.OperableTrigger;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobGroupSummary;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobSummary;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzReport;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetailsDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobGroupSummaryDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobSummaryDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummaryDescriptor;
import org.springframework.scheduling.quartz.DelegatingJob;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@ -113,7 +113,7 @@ class QuartzEndpointTests {
void quartzReport() throws SchedulerException {
given(this.scheduler.getJobGroupNames()).willReturn(Arrays.asList("jobSamples", "DEFAULT"));
given(this.scheduler.getTriggerGroupNames()).willReturn(Collections.singletonList("triggerSamples"));
QuartzReport quartzReport = this.endpoint.quartzReport();
QuartzDescriptor quartzReport = this.endpoint.quartzReport();
assertThat(quartzReport.getJobs().getGroups()).containsOnly("jobSamples", "DEFAULT");
assertThat(quartzReport.getTriggers().getGroups()).containsOnly("triggerSamples");
then(this.scheduler).should().getJobGroupNames();
@ -125,7 +125,7 @@ class QuartzEndpointTests {
void quartzReportWithNoJob() throws SchedulerException {
given(this.scheduler.getJobGroupNames()).willReturn(Collections.emptyList());
given(this.scheduler.getTriggerGroupNames()).willReturn(Arrays.asList("triggerSamples", "DEFAULT"));
QuartzReport quartzReport = this.endpoint.quartzReport();
QuartzDescriptor quartzReport = this.endpoint.quartzReport();
assertThat(quartzReport.getJobs().getGroups()).isEmpty();
assertThat(quartzReport.getTriggers().getGroups()).containsOnly("triggerSamples", "DEFAULT");
}
@ -134,7 +134,7 @@ class QuartzEndpointTests {
void quartzReportWithNoTrigger() throws SchedulerException {
given(this.scheduler.getJobGroupNames()).willReturn(Collections.singletonList("jobSamples"));
given(this.scheduler.getTriggerGroupNames()).willReturn(Collections.emptyList());
QuartzReport quartzReport = this.endpoint.quartzReport();
QuartzDescriptor quartzReport = this.endpoint.quartzReport();
assertThat(quartzReport.getJobs().getGroups()).containsOnly("jobSamples");
assertThat(quartzReport.getTriggers().getGroups()).isEmpty();
}
@ -179,7 +179,7 @@ class QuartzEndpointTests {
@Test
void quartzJobGroupSummaryWithInvalidGroup() throws SchedulerException {
given(this.scheduler.getJobGroupNames()).willReturn(Collections.singletonList("DEFAULT"));
QuartzJobGroupSummary summary = this.endpoint.quartzJobGroupSummary("unknown");
QuartzJobGroupSummaryDescriptor summary = this.endpoint.quartzJobGroupSummary("unknown");
assertThat(summary).isNull();
}
@ -187,7 +187,7 @@ class QuartzEndpointTests {
void quartzJobGroupSummaryWithEmptyGroup() throws SchedulerException {
given(this.scheduler.getJobGroupNames()).willReturn(Collections.singletonList("samples"));
given(this.scheduler.getJobKeys(GroupMatcher.jobGroupEquals("samples"))).willReturn(Collections.emptySet());
QuartzJobGroupSummary summary = this.endpoint.quartzJobGroupSummary("samples");
QuartzJobGroupSummaryDescriptor summary = this.endpoint.quartzJobGroupSummary("samples");
assertThat(summary).isNotNull();
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.getJobs()).isEmpty();
@ -196,10 +196,10 @@ class QuartzEndpointTests {
@Test
void quartzJobGroupSummaryWithJobs() throws SchedulerException {
mockJobs(jobOne, jobTwo);
QuartzJobGroupSummary summary = this.endpoint.quartzJobGroupSummary("DEFAULT");
QuartzJobGroupSummaryDescriptor summary = this.endpoint.quartzJobGroupSummary("DEFAULT");
assertThat(summary).isNotNull();
assertThat(summary.getGroup()).isEqualTo("DEFAULT");
Map<String, QuartzJobSummary> jobSummaries = summary.getJobs();
Map<String, QuartzJobSummaryDescriptor> jobSummaries = summary.getJobs();
assertThat(jobSummaries).containsOnlyKeys("jobOne", "jobTwo");
assertThat(jobSummaries.get("jobOne").getClassName()).isEqualTo(Job.class.getName());
assertThat(jobSummaries.get("jobTwo").getClassName()).isEqualTo(DelegatingJob.class.getName());
@ -208,7 +208,7 @@ class QuartzEndpointTests {
@Test
void quartzTriggerGroupSummaryWithInvalidGroup() throws SchedulerException {
given(this.scheduler.getTriggerGroupNames()).willReturn(Collections.singletonList("DEFAULT"));
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("unknown");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("unknown");
assertThat(summary).isNull();
}
@ -217,7 +217,7 @@ class QuartzEndpointTests {
given(this.scheduler.getTriggerGroupNames()).willReturn(Collections.singletonList("samples"));
given(this.scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals("samples")))
.willReturn(Collections.emptySet());
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
assertThat(summary).isNotNull();
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.isPaused()).isFalse();
@ -233,7 +233,7 @@ class QuartzEndpointTests {
CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("3am-every-day", "samples")
.withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0)).build();
mockTriggers(cronTrigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.isPaused()).isFalse();
assertThat(summary.getTriggers().getCron()).containsOnlyKeys("3am-every-day");
@ -253,7 +253,7 @@ class QuartzEndpointTests {
((OperableTrigger) cronTrigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) cronTrigger).setNextFireTime(nextFireTime);
mockTriggers(cronTrigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
Map<String, Object> triggers = summary.getTriggers().getCron();
assertThat(triggers).containsOnlyKeys("3am-every-day");
assertThat(triggers).extractingByKey("3am-every-day", nestedMap()).containsOnly(
@ -266,7 +266,7 @@ class QuartzEndpointTests {
SimpleTrigger simpleTrigger = TriggerBuilder.newTrigger().withIdentity("every-hour", "samples")
.withSchedule(SimpleScheduleBuilder.repeatHourlyForever(1)).build();
mockTriggers(simpleTrigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.isPaused()).isFalse();
assertThat(summary.getTriggers().getCron()).isEmpty();
@ -285,7 +285,7 @@ class QuartzEndpointTests {
((OperableTrigger) simpleTrigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) simpleTrigger).setNextFireTime(nextFireTime);
mockTriggers(simpleTrigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
Map<String, Object> triggers = summary.getTriggers().getSimple();
assertThat(triggers).containsOnlyKeys("every-hour");
assertThat(triggers).extractingByKey("every-hour", nestedMap()).containsOnly(
@ -300,7 +300,7 @@ class QuartzEndpointTests {
.startingDailyAt(TimeOfDay.hourAndMinuteOfDay(9, 0)).withInterval(1, IntervalUnit.HOUR))
.build();
mockTriggers(trigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.isPaused()).isFalse();
assertThat(summary.getTriggers().getCron()).isEmpty();
@ -324,7 +324,7 @@ class QuartzEndpointTests {
((OperableTrigger) trigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) trigger).setNextFireTime(nextFireTime);
mockTriggers(trigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
Map<String, Object> triggers = summary.getTriggers().getDailyTimeInterval();
assertThat(triggers).containsOnlyKeys("every-hour-tue-thu");
assertThat(triggers).extractingByKey("every-hour-tue-thu", nestedMap()).containsOnly(
@ -340,7 +340,7 @@ class QuartzEndpointTests {
.withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInWeeks(1))
.build();
mockTriggers(trigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.isPaused()).isFalse();
assertThat(summary.getTriggers().getCron()).isEmpty();
@ -362,7 +362,7 @@ class QuartzEndpointTests {
((OperableTrigger) trigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) trigger).setNextFireTime(nextFireTime);
mockTriggers(trigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
Map<String, Object> triggers = summary.getTriggers().getCalendarInterval();
assertThat(triggers).containsOnlyKeys("once-a-week");
assertThat(triggers).extractingByKey("once-a-week", nestedMap()).containsOnly(
@ -375,7 +375,7 @@ class QuartzEndpointTests {
Trigger trigger = mock(Trigger.class);
given(trigger.getKey()).willReturn(TriggerKey.triggerKey("custom", "samples"));
mockTriggers(trigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.isPaused()).isFalse();
assertThat(summary.getTriggers().getCron()).isEmpty();
@ -395,7 +395,7 @@ class QuartzEndpointTests {
given(trigger.getNextFireTime()).willReturn(nextFireTime);
given(trigger.getPriority()).willReturn(9);
mockTriggers(trigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
QuartzTriggerGroupSummaryDescriptor summary = this.endpoint.quartzTriggerGroupSummary("samples");
Map<String, Object> triggers = summary.getTriggers().getCustom();
assertThat(triggers).containsOnlyKeys("custom");
assertThat(triggers).extractingByKey("custom", nestedMap()).containsOnly(
@ -587,7 +587,7 @@ class QuartzEndpointTests {
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").withDescription("A sample job")
.storeDurably().requestRecovery(false).build();
mockJobs(job);
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello", true);
QuartzJobDetailsDescriptor jobDetails = this.endpoint.quartzJob("samples", "hello", true);
assertThat(jobDetails.getGroup()).isEqualTo("samples");
assertThat(jobDetails.getName()).isEqualTo("hello");
assertThat(jobDetails.getDescription()).isEqualTo("A sample job");
@ -612,7 +612,7 @@ class QuartzEndpointTests {
mockTriggers(trigger);
given(this.scheduler.getTriggersOfJob(JobKey.jobKey("hello", "samples")))
.willAnswer((invocation) -> Collections.singletonList(trigger));
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello", true);
QuartzJobDetailsDescriptor jobDetails = this.endpoint.quartzJob("samples", "hello", true);
assertThat(jobDetails.getTriggers()).hasSize(1);
Map<String, Object> triggerDetails = jobDetails.getTriggers().get(0);
assertThat(triggerDetails).containsOnly(entry("group", "samples"), entry("name", "3am-every-day"),
@ -634,7 +634,7 @@ class QuartzEndpointTests {
mockTriggers(triggerOne, triggerTwo);
given(this.scheduler.getTriggersOfJob(JobKey.jobKey("hello", "samples")))
.willAnswer((invocation) -> Arrays.asList(triggerOne, triggerTwo));
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello", true);
QuartzJobDetailsDescriptor jobDetails = this.endpoint.quartzJob("samples", "hello", true);
assertThat(jobDetails.getTriggers()).hasSize(2);
assertThat(jobDetails.getTriggers().get(0)).containsEntry("name", "two");
assertThat(jobDetails.getTriggers().get(1)).containsEntry("name", "one");
@ -654,7 +654,7 @@ class QuartzEndpointTests {
mockTriggers(triggerOne, triggerTwo);
given(this.scheduler.getTriggersOfJob(JobKey.jobKey("hello", "samples")))
.willAnswer((invocation) -> Arrays.asList(triggerOne, triggerTwo));
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello", true);
QuartzJobDetailsDescriptor jobDetails = this.endpoint.quartzJob("samples", "hello", true);
assertThat(jobDetails.getTriggers()).hasSize(2);
assertThat(jobDetails.getTriggers().get(0)).containsEntry("name", "two");
assertThat(jobDetails.getTriggers().get(1)).containsEntry("name", "one");
@ -665,7 +665,7 @@ class QuartzEndpointTests {
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").usingJobData("user", "user")
.usingJobData("password", "secret").usingJobData("url", "https://user:secret@example.com").build();
mockJobs(job);
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello", true);
QuartzJobDetailsDescriptor jobDetails = this.endpoint.quartzJob("samples", "hello", true);
assertThat(jobDetails.getData()).containsOnly(entry("user", "user"), entry("password", "secret"),
entry("url", "https://user:secret@example.com"));
}
@ -675,7 +675,7 @@ class QuartzEndpointTests {
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").usingJobData("user", "user")
.usingJobData("password", "secret").usingJobData("url", "https://user:secret@example.com").build();
mockJobs(job);
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello", false);
QuartzJobDetailsDescriptor jobDetails = this.endpoint.quartzJob("samples", "hello", false);
assertThat(jobDetails.getData()).containsOnly(entry("user", "******"), entry("password", "******"),
entry("url", "******"));
}

@ -28,10 +28,10 @@ import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.actuate.endpoint.SecurityContext;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzGroups;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobGroupSummary;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzGroupsDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetailsDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobGroupSummaryDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummaryDescriptor;
import org.springframework.boot.actuate.quartz.QuartzEndpointWebExtension.QuartzEndpointWebExtensionRuntimeHints;
import static org.assertj.core.api.Assertions.assertThat;
@ -100,8 +100,8 @@ class QuartzEndpointWebExtensionTests {
void shouldRegisterHints() {
RuntimeHints runtimeHints = new RuntimeHints();
new QuartzEndpointWebExtensionRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
Set<Class<?>> bindingTypes = Set.of(QuartzGroups.class, QuartzJobDetails.class, QuartzJobGroupSummary.class,
QuartzTriggerGroupSummary.class);
Set<Class<?>> bindingTypes = Set.of(QuartzGroupsDescriptor.class, QuartzJobDetailsDescriptor.class,
QuartzJobGroupSummaryDescriptor.class, QuartzTriggerGroupSummaryDescriptor.class);
for (Class<?> bindingType : bindingTypes) {
assertThat(RuntimeHintsPredicates.reflection().onType(bindingType)
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))

@ -27,12 +27,12 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.CronTaskDescription;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.CustomTriggerTaskDescription;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.FixedDelayTaskDescription;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.FixedRateTaskDescription;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.CronTaskDescriptor;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.CustomTriggerTaskDescriptor;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.FixedDelayTaskDescriptor;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.FixedRateTaskDescriptor;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.ScheduledTasksDescriptor;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.ScheduledTasksEndpointRuntimeHints;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.ScheduledTasksReport;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -65,7 +65,7 @@ class ScheduledTasksEndpointTests {
assertThat(tasks.getFixedRate()).isEmpty();
assertThat(tasks.getCustom()).isEmpty();
assertThat(tasks.getCron()).hasSize(1);
CronTaskDescription description = (CronTaskDescription) tasks.getCron().get(0);
CronTaskDescriptor description = (CronTaskDescriptor) tasks.getCron().get(0);
assertThat(description.getExpression()).isEqualTo("0 0 0/3 1/1 * ?");
assertThat(description.getRunnable().getTarget()).isEqualTo(CronScheduledMethod.class.getName() + ".cron");
});
@ -78,7 +78,7 @@ class ScheduledTasksEndpointTests {
assertThat(tasks.getFixedDelay()).isEmpty();
assertThat(tasks.getCustom()).isEmpty();
assertThat(tasks.getCron()).hasSize(1);
CronTaskDescription description = (CronTaskDescription) tasks.getCron().get(0);
CronTaskDescriptor description = (CronTaskDescriptor) tasks.getCron().get(0);
assertThat(description.getExpression()).isEqualTo("0 0 0/6 1/1 * ?");
assertThat(description.getRunnable().getTarget()).isEqualTo(CronTriggerRunnable.class.getName());
});
@ -91,7 +91,7 @@ class ScheduledTasksEndpointTests {
assertThat(tasks.getFixedRate()).isEmpty();
assertThat(tasks.getCustom()).isEmpty();
assertThat(tasks.getFixedDelay()).hasSize(1);
FixedDelayTaskDescription description = (FixedDelayTaskDescription) tasks.getFixedDelay().get(0);
FixedDelayTaskDescriptor description = (FixedDelayTaskDescriptor) tasks.getFixedDelay().get(0);
assertThat(description.getInitialDelay()).isEqualTo(2);
assertThat(description.getInterval()).isEqualTo(1);
assertThat(description.getRunnable().getTarget())
@ -106,7 +106,7 @@ class ScheduledTasksEndpointTests {
assertThat(tasks.getFixedRate()).isEmpty();
assertThat(tasks.getCustom()).isEmpty();
assertThat(tasks.getFixedDelay()).hasSize(1);
FixedDelayTaskDescription description = (FixedDelayTaskDescription) tasks.getFixedDelay().get(0);
FixedDelayTaskDescriptor description = (FixedDelayTaskDescriptor) tasks.getFixedDelay().get(0);
assertThat(description.getInitialDelay()).isEqualTo(2000);
assertThat(description.getInterval()).isEqualTo(1000);
assertThat(description.getRunnable().getTarget()).isEqualTo(FixedDelayTriggerRunnable.class.getName());
@ -120,7 +120,7 @@ class ScheduledTasksEndpointTests {
assertThat(tasks.getFixedDelay()).isEmpty();
assertThat(tasks.getCustom()).isEmpty();
assertThat(tasks.getFixedRate()).hasSize(1);
FixedRateTaskDescription description = (FixedRateTaskDescription) tasks.getFixedRate().get(0);
FixedRateTaskDescriptor description = (FixedRateTaskDescriptor) tasks.getFixedRate().get(0);
assertThat(description.getInitialDelay()).isEqualTo(4);
assertThat(description.getInterval()).isEqualTo(3);
assertThat(description.getRunnable().getTarget())
@ -135,7 +135,7 @@ class ScheduledTasksEndpointTests {
assertThat(tasks.getFixedDelay()).isEmpty();
assertThat(tasks.getCustom()).isEmpty();
assertThat(tasks.getFixedRate()).hasSize(1);
FixedRateTaskDescription description = (FixedRateTaskDescription) tasks.getFixedRate().get(0);
FixedRateTaskDescriptor description = (FixedRateTaskDescriptor) tasks.getFixedRate().get(0);
assertThat(description.getInitialDelay()).isEqualTo(3000);
assertThat(description.getInterval()).isEqualTo(2000);
assertThat(description.getRunnable().getTarget()).isEqualTo(FixedRateTriggerRunnable.class.getName());
@ -149,7 +149,7 @@ class ScheduledTasksEndpointTests {
assertThat(tasks.getFixedDelay()).isEmpty();
assertThat(tasks.getFixedRate()).isEmpty();
assertThat(tasks.getCustom()).hasSize(1);
CustomTriggerTaskDescription description = (CustomTriggerTaskDescription) tasks.getCustom().get(0);
CustomTriggerTaskDescriptor description = (CustomTriggerTaskDescriptor) tasks.getCustom().get(0);
assertThat(description.getRunnable().getTarget()).isEqualTo(CustomTriggerRunnable.class.getName());
assertThat(description.getTrigger()).isEqualTo(CustomTriggerTask.trigger.toString());
});
@ -159,8 +159,8 @@ class ScheduledTasksEndpointTests {
void shouldRegisterHints() {
RuntimeHints runtimeHints = new RuntimeHints();
new ScheduledTasksEndpointRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
Set<Class<?>> bindingTypes = Set.of(FixedRateTaskDescription.class, FixedDelayTaskDescription.class,
CronTaskDescription.class, CustomTriggerTaskDescription.class);
Set<Class<?>> bindingTypes = Set.of(FixedRateTaskDescriptor.class, FixedDelayTaskDescriptor.class,
CronTaskDescriptor.class, CustomTriggerTaskDescriptor.class);
for (Class<?> bindingType : bindingTypes) {
assertThat(RuntimeHintsPredicates.reflection().onType(bindingType)
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
@ -168,7 +168,7 @@ class ScheduledTasksEndpointTests {
}
}
private void run(Class<?> configuration, Consumer<ScheduledTasksReport> consumer) {
private void run(Class<?> configuration, Consumer<ScheduledTasksDescriptor> consumer) {
this.contextRunner.withUserConfiguration(configuration)
.run((context) -> consumer.accept(context.getBean(ScheduledTasksEndpoint.class).scheduledTasks()));
}

@ -26,8 +26,8 @@ import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.TypeReference;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.actuate.startup.StartupEndpoint.StartupDescriptor;
import org.springframework.boot.actuate.startup.StartupEndpoint.StartupEndpointRuntimeHints;
import org.springframework.boot.actuate.startup.StartupEndpoint.StartupResponse;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
@ -49,7 +49,7 @@ class StartupEndpointTests {
void startupEventsAreFound() {
BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup(256);
testStartupEndpoint(applicationStartup, (startupEndpoint) -> {
StartupResponse startup = startupEndpoint.startup();
StartupDescriptor startup = startupEndpoint.startup();
assertThat(startup.getSpringBootVersion()).isEqualTo(SpringBootVersion.getVersion());
assertThat(startup.getTimeline().getStartTime())
.isEqualTo(applicationStartup.getBufferedTimeline().getStartTime());
@ -60,7 +60,7 @@ class StartupEndpointTests {
void bufferWithGetIsNotDrained() {
BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup(256);
testStartupEndpoint(applicationStartup, (startupEndpoint) -> {
StartupResponse startup = startupEndpoint.startupSnapshot();
StartupDescriptor startup = startupEndpoint.startupSnapshot();
assertThat(startup.getTimeline().getEvents()).isNotEmpty();
assertThat(applicationStartup.getBufferedTimeline().getEvents()).isNotEmpty();
});
@ -70,7 +70,7 @@ class StartupEndpointTests {
void bufferWithPostIsDrained() {
BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup(256);
testStartupEndpoint(applicationStartup, (startupEndpoint) -> {
StartupResponse startup = startupEndpoint.startup();
StartupDescriptor startup = startupEndpoint.startup();
assertThat(startup.getTimeline().getEvents()).isNotEmpty();
assertThat(applicationStartup.getBufferedTimeline().getEvents()).isEmpty();
});

@ -28,8 +28,8 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRegistration;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ApplicationMappings;
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings;
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ApplicationMappingsDescriptor;
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappingsDescriptor;
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlerMappingDescription;
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider;
import org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletMappingDescription;
@ -79,7 +79,7 @@ class MappingsEndpointTests {
Supplier<ConfigurableWebApplicationContext> contextSupplier = prepareContextSupplier();
new WebApplicationContextRunner(contextSupplier)
.withUserConfiguration(EndpointConfiguration.class, ServletWebConfiguration.class).run((context) -> {
ContextMappings contextMappings = contextMappings(context);
ContextMappingsDescriptor contextMappings = contextMappings(context);
assertThat(contextMappings.getParentId()).isNull();
assertThat(contextMappings.getMappings()).containsOnlyKeys("dispatcherServlets", "servletFilters",
"servlets");
@ -101,7 +101,7 @@ class MappingsEndpointTests {
Supplier<ConfigurableWebApplicationContext> contextSupplier = prepareContextSupplier();
new WebApplicationContextRunner(contextSupplier).withUserConfiguration(EndpointConfiguration.class,
ServletWebConfiguration.class, PathPatternParserConfiguration.class).run((context) -> {
ContextMappings contextMappings = contextMappings(context);
ContextMappingsDescriptor contextMappings = contextMappings(context);
assertThat(contextMappings.getParentId()).isNull();
assertThat(contextMappings.getMappings()).containsOnlyKeys("dispatcherServlets", "servletFilters",
"servlets");
@ -123,7 +123,7 @@ class MappingsEndpointTests {
Supplier<ConfigurableWebApplicationContext> contextSupplier = prepareContextSupplier();
new WebApplicationContextRunner(contextSupplier).withUserConfiguration(EndpointConfiguration.class,
ServletWebConfiguration.class, CustomDispatcherServletConfiguration.class).run((context) -> {
ContextMappings contextMappings = contextMappings(context);
ContextMappingsDescriptor contextMappings = contextMappings(context);
Map<String, List<DispatcherServletMappingDescription>> dispatcherServlets = mappings(
contextMappings, "dispatcherServlets");
assertThat(dispatcherServlets).containsOnlyKeys("dispatcherServlet",
@ -156,7 +156,7 @@ class MappingsEndpointTests {
void reactiveWebMappings() {
new ReactiveWebApplicationContextRunner()
.withUserConfiguration(EndpointConfiguration.class, ReactiveWebConfiguration.class).run((context) -> {
ContextMappings contextMappings = contextMappings(context);
ContextMappingsDescriptor contextMappings = contextMappings(context);
assertThat(contextMappings.getParentId()).isNull();
assertThat(contextMappings.getMappings()).containsOnlyKeys("dispatcherHandlers");
Map<String, List<DispatcherHandlerMappingDescription>> dispatcherHandlers = mappings(
@ -167,14 +167,14 @@ class MappingsEndpointTests {
});
}
private ContextMappings contextMappings(ApplicationContext context) {
ApplicationMappings applicationMappings = context.getBean(MappingsEndpoint.class).mappings();
private ContextMappingsDescriptor contextMappings(ApplicationContext context) {
ApplicationMappingsDescriptor applicationMappings = context.getBean(MappingsEndpoint.class).mappings();
assertThat(applicationMappings.getContexts()).containsOnlyKeys(context.getId());
return applicationMappings.getContexts().get(context.getId());
}
@SuppressWarnings("unchecked")
private <T> T mappings(ContextMappings contextMappings, String key) {
private <T> T mappings(ContextMappingsDescriptor contextMappings, String key) {
return (T) contextMappings.getMappings().get(key);
}

Loading…
Cancel
Save