Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
0cd83007
Commit
0cd83007
authored
Jul 16, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x'
Closes gh-22357
parents
85d1f539
70282316
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
ConditionMessage.java
...mework/boot/autoconfigure/condition/ConditionMessage.java
+5
-1
ConditionMessageTests.java
...k/boot/autoconfigure/condition/ConditionMessageTests.java
+17
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java
View file @
0cd83007
...
@@ -381,7 +381,8 @@ public final class ConditionMessage {
...
@@ -381,7 +381,8 @@ public final class ConditionMessage {
Assert
.
notNull
(
style
,
"Style must not be null"
);
Assert
.
notNull
(
style
,
"Style must not be null"
);
StringBuilder
message
=
new
StringBuilder
(
this
.
reason
);
StringBuilder
message
=
new
StringBuilder
(
this
.
reason
);
items
=
style
.
applyTo
(
items
);
items
=
style
.
applyTo
(
items
);
if
((
this
.
condition
==
null
||
items
.
size
()
<=
1
)
&&
StringUtils
.
hasLength
(
this
.
singular
))
{
if
((
this
.
condition
==
null
||
items
==
null
||
items
.
size
()
<=
1
)
&&
StringUtils
.
hasLength
(
this
.
singular
))
{
message
.
append
(
" "
).
append
(
this
.
singular
);
message
.
append
(
" "
).
append
(
this
.
singular
);
}
}
else
if
(
StringUtils
.
hasLength
(
this
.
plural
))
{
else
if
(
StringUtils
.
hasLength
(
this
.
plural
))
{
...
@@ -420,6 +421,9 @@ public final class ConditionMessage {
...
@@ -420,6 +421,9 @@ public final class ConditionMessage {
};
};
public
Collection
<?>
applyTo
(
Collection
<?>
items
)
{
public
Collection
<?>
applyTo
(
Collection
<?>
items
)
{
if
(
items
==
null
)
{
return
null
;
}
List
<
Object
>
result
=
new
ArrayList
<>(
items
.
size
());
List
<
Object
>
result
=
new
ArrayList
<>(
items
.
size
());
for
(
Object
item
:
items
)
{
for
(
Object
item
:
items
)
{
result
.
add
(
applyToItem
(
item
));
result
.
add
(
applyToItem
(
item
));
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionMessageTests.java
View file @
0cd83007
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
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.
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
condition
;
package
org
.
springframework
.
boot
.
autoconfigure
.
condition
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -188,4 +189,19 @@ class ConditionMessageTests {
...
@@ -188,4 +189,19 @@ class ConditionMessageTests {
assertThat
(
message
.
toString
()).
isEqualTo
(
"@Test JMX is available"
);
assertThat
(
message
.
toString
()).
isEqualTo
(
"@Test JMX is available"
);
}
}
@Test
void
itemsTolerateNullInput
()
{
Collection
<?>
items
=
null
;
ConditionMessage
message
=
ConditionMessage
.
forCondition
(
Test
.
class
).
didNotFind
(
"item"
).
items
(
items
);
assertThat
(
message
.
toString
()).
isEqualTo
(
"@Test did not find item"
);
}
@Test
void
quotedItemsTolerateNullInput
()
{
Collection
<?>
items
=
null
;
ConditionMessage
message
=
ConditionMessage
.
forCondition
(
Test
.
class
).
didNotFind
(
"item"
).
items
(
Style
.
QUOTE
,
items
);
assertThat
(
message
.
toString
()).
isEqualTo
(
"@Test did not find item"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment