mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge pull request #38510 from quaff
* gh-38510: Polish "Treat null as CloudPlatform.NONE" Treat null as CloudPlatform.NONE Closes gh-38510
This commit is contained in:
commit
77b533b5f3
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -32,6 +32,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Madhura Bhave
|
* @author Madhura Bhave
|
||||||
|
* @author Yanming Zhou
|
||||||
*/
|
*/
|
||||||
class ConfigDataProperties {
|
class ConfigDataProperties {
|
||||||
|
|
||||||
@ -118,8 +119,8 @@ class ConfigDataProperties {
|
|||||||
if (activationContext == null) {
|
if (activationContext == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean activate = true;
|
CloudPlatform cloudPlatform = activationContext.getCloudPlatform();
|
||||||
activate = activate && isActive(activationContext.getCloudPlatform());
|
boolean activate = isActive((cloudPlatform != null) ? cloudPlatform : CloudPlatform.NONE);
|
||||||
activate = activate && isActive(activationContext.getProfiles());
|
activate = activate && isActive(activationContext.getProfiles());
|
||||||
return activate;
|
return activate;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Madhura Bhave
|
* @author Madhura Bhave
|
||||||
|
* @author Yanming Zhou
|
||||||
*/
|
*/
|
||||||
class ConfigDataPropertiesTests {
|
class ConfigDataPropertiesTests {
|
||||||
|
|
||||||
@ -98,6 +99,13 @@ class ConfigDataPropertiesTests {
|
|||||||
assertThat(properties.isActive(context)).isFalse();
|
assertThat(properties.isActive(context)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void isActiveWhenNoneCloudPlatformAgainstNullCloudPlatform() {
|
||||||
|
ConfigDataProperties properties = new ConfigDataProperties(NO_IMPORTS, new Activate(CloudPlatform.NONE, null));
|
||||||
|
ConfigDataActivationContext context = new ConfigDataActivationContext(NULL_CLOUD_PLATFORM, NULL_PROFILES);
|
||||||
|
assertThat(properties.isActive(context)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isActiveWhenNullProfilesAgainstNullProfiles() {
|
void isActiveWhenNullProfilesAgainstNullProfiles() {
|
||||||
ConfigDataProperties properties = new ConfigDataProperties(NO_IMPORTS, new Activate(null, null));
|
ConfigDataProperties properties = new ConfigDataProperties(NO_IMPORTS, new Activate(null, null));
|
||||||
|
Loading…
Reference in New Issue
Block a user