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
3d2fbdf3
Commit
3d2fbdf3
authored
Oct 26, 2018
by
dreis2211
Committed by
Phillip Webb
Oct 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish mocks with default answer
Closes gh-14971
parent
c393f626
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
24 deletions
+13
-24
ArrayBinderTests.java
...mework/boot/context/properties/bind/ArrayBinderTests.java
+2
-5
BinderTests.java
...ngframework/boot/context/properties/bind/BinderTests.java
+2
-5
MapBinderTests.java
...ramework/boot/context/properties/bind/MapBinderTests.java
+2
-5
AliasedConfigurationPropertySourceTests.java
...rties/source/AliasedConfigurationPropertySourceTests.java
+4
-5
FilteredConfigurationPropertiesSourceTests.java
...es/source/FilteredConfigurationPropertiesSourceTests.java
+3
-4
No files found.
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/ArrayBinderTests.java
View file @
3d2fbdf3
...
@@ -38,7 +38,6 @@ import static org.mockito.ArgumentMatchers.eq;
...
@@ -38,7 +38,6 @@ import static org.mockito.ArgumentMatchers.eq;
import
static
org
.
mockito
.
ArgumentMatchers
.
isA
;
import
static
org
.
mockito
.
ArgumentMatchers
.
isA
;
import
static
org
.
mockito
.
Mockito
.
inOrder
;
import
static
org
.
mockito
.
Mockito
.
inOrder
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
withSettings
;
/**
/**
* Tests for {@link ArrayBinder}.
* Tests for {@link ArrayBinder}.
...
@@ -76,8 +75,7 @@ public class ArrayBinderTests {
...
@@ -76,8 +75,7 @@ public class ArrayBinderTests {
@Test
@Test
public
void
bindToCollectionShouldTriggerOnSuccess
()
{
public
void
bindToCollectionShouldTriggerOnSuccess
()
{
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo[0]"
,
"1"
,
"line1"
));
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo[0]"
,
"1"
,
"line1"
));
BindHandler
handler
=
mock
(
BindHandler
.
class
,
BindHandler
handler
=
mock
(
BindHandler
.
class
,
Answers
.
CALLS_REAL_METHODS
);
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
));
this
.
binder
.
bind
(
"foo"
,
INTEGER_LIST
,
handler
);
this
.
binder
.
bind
(
"foo"
,
INTEGER_LIST
,
handler
);
InOrder
inOrder
=
inOrder
(
handler
);
InOrder
inOrder
=
inOrder
(
handler
);
inOrder
.
verify
(
handler
).
onSuccess
(
eq
(
ConfigurationPropertyName
.
of
(
"foo[0]"
)),
inOrder
.
verify
(
handler
).
onSuccess
(
eq
(
ConfigurationPropertyName
.
of
(
"foo[0]"
)),
...
@@ -211,8 +209,7 @@ public class ArrayBinderTests {
...
@@ -211,8 +209,7 @@ public class ArrayBinderTests {
@Test
@Test
public
void
bindToArrayShouldTriggerOnSuccess
()
{
public
void
bindToArrayShouldTriggerOnSuccess
()
{
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo[0]"
,
"1"
,
"line1"
));
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo[0]"
,
"1"
,
"line1"
));
BindHandler
handler
=
mock
(
BindHandler
.
class
,
BindHandler
handler
=
mock
(
BindHandler
.
class
,
Answers
.
CALLS_REAL_METHODS
);
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
));
Bindable
<
Integer
[]>
target
=
INTEGER_ARRAY
;
Bindable
<
Integer
[]>
target
=
INTEGER_ARRAY
;
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
InOrder
inOrder
=
inOrder
(
handler
);
InOrder
inOrder
=
inOrder
(
handler
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java
View file @
3d2fbdf3
...
@@ -56,7 +56,6 @@ import static org.mockito.ArgumentMatchers.eq;
...
@@ -56,7 +56,6 @@ import static org.mockito.ArgumentMatchers.eq;
import
static
org
.
mockito
.
ArgumentMatchers
.
isA
;
import
static
org
.
mockito
.
ArgumentMatchers
.
isA
;
import
static
org
.
mockito
.
Mockito
.
inOrder
;
import
static
org
.
mockito
.
Mockito
.
inOrder
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
withSettings
;
/**
/**
* Tests for {@link Binder}.
* Tests for {@link Binder}.
...
@@ -170,8 +169,7 @@ public class BinderTests {
...
@@ -170,8 +169,7 @@ public class BinderTests {
@Test
@Test
public
void
bindToValueShouldTriggerOnSuccess
()
{
public
void
bindToValueShouldTriggerOnSuccess
()
{
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo"
,
"1"
,
"line1"
));
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo"
,
"1"
,
"line1"
));
BindHandler
handler
=
mock
(
BindHandler
.
class
,
BindHandler
handler
=
mock
(
BindHandler
.
class
,
Answers
.
CALLS_REAL_METHODS
);
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
));
Bindable
<
Integer
>
target
=
Bindable
.
of
(
Integer
.
class
);
Bindable
<
Integer
>
target
=
Bindable
.
of
(
Integer
.
class
);
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
InOrder
ordered
=
inOrder
(
handler
);
InOrder
ordered
=
inOrder
(
handler
);
...
@@ -210,8 +208,7 @@ public class BinderTests {
...
@@ -210,8 +208,7 @@ public class BinderTests {
public
void
bindToJavaBeanShouldTriggerOnSuccess
()
{
public
void
bindToJavaBeanShouldTriggerOnSuccess
()
{
this
.
sources
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo.value"
,
"bar"
,
"line1"
));
.
add
(
new
MockConfigurationPropertySource
(
"foo.value"
,
"bar"
,
"line1"
));
BindHandler
handler
=
mock
(
BindHandler
.
class
,
BindHandler
handler
=
mock
(
BindHandler
.
class
,
Answers
.
CALLS_REAL_METHODS
);
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
));
Bindable
<
JavaBean
>
target
=
Bindable
.
of
(
JavaBean
.
class
);
Bindable
<
JavaBean
>
target
=
Bindable
.
of
(
JavaBean
.
class
);
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
InOrder
inOrder
=
inOrder
(
handler
);
InOrder
inOrder
=
inOrder
(
handler
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java
View file @
3d2fbdf3
...
@@ -52,7 +52,6 @@ import static org.mockito.ArgumentMatchers.eq;
...
@@ -52,7 +52,6 @@ import static org.mockito.ArgumentMatchers.eq;
import
static
org
.
mockito
.
ArgumentMatchers
.
isA
;
import
static
org
.
mockito
.
ArgumentMatchers
.
isA
;
import
static
org
.
mockito
.
Mockito
.
inOrder
;
import
static
org
.
mockito
.
Mockito
.
inOrder
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
withSettings
;
/**
/**
* Tests for {@link MapBinder}.
* Tests for {@link MapBinder}.
...
@@ -349,8 +348,7 @@ public class MapBinderTests {
...
@@ -349,8 +348,7 @@ public class MapBinderTests {
@Test
@Test
public
void
bindToMapShouldTriggerOnSuccess
()
{
public
void
bindToMapShouldTriggerOnSuccess
()
{
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo.bar"
,
"1"
,
"line1"
));
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo.bar"
,
"1"
,
"line1"
));
BindHandler
handler
=
mock
(
BindHandler
.
class
,
BindHandler
handler
=
mock
(
BindHandler
.
class
,
Answers
.
CALLS_REAL_METHODS
);
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
));
Bindable
<
Map
<
String
,
Integer
>>
target
=
STRING_INTEGER_MAP
;
Bindable
<
Map
<
String
,
Integer
>>
target
=
STRING_INTEGER_MAP
;
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
InOrder
ordered
=
inOrder
(
handler
);
InOrder
ordered
=
inOrder
(
handler
);
...
@@ -364,8 +362,7 @@ public class MapBinderTests {
...
@@ -364,8 +362,7 @@ public class MapBinderTests {
public
void
bindToMapStringArrayShouldTriggerOnSuccess
()
{
public
void
bindToMapStringArrayShouldTriggerOnSuccess
()
{
this
.
sources
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo.bar"
,
"a,b,c"
,
"line1"
));
.
add
(
new
MockConfigurationPropertySource
(
"foo.bar"
,
"a,b,c"
,
"line1"
));
BindHandler
handler
=
mock
(
BindHandler
.
class
,
BindHandler
handler
=
mock
(
BindHandler
.
class
,
Answers
.
CALLS_REAL_METHODS
);
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
));
Bindable
<
Map
<
String
,
String
[]>>
target
=
STRING_ARRAY_MAP
;
Bindable
<
Map
<
String
,
String
[]>>
target
=
STRING_ARRAY_MAP
;
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
this
.
binder
.
bind
(
"foo"
,
target
,
handler
);
InOrder
ordered
=
inOrder
(
handler
);
InOrder
ordered
=
inOrder
(
handler
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java
View file @
3d2fbdf3
...
@@ -24,7 +24,6 @@ import org.mockito.Answers;
...
@@ -24,7 +24,6 @@ import org.mockito.Answers;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
withSettings
;
/**
/**
* Tests for {@link AliasedConfigurationPropertySource}.
* Tests for {@link AliasedConfigurationPropertySource}.
...
@@ -59,7 +58,7 @@ public class AliasedConfigurationPropertySourceTests {
...
@@ -59,7 +58,7 @@ public class AliasedConfigurationPropertySourceTests {
public
void
containsDescendantOfWhenSourceReturnsUnknownShouldReturnUnknown
()
{
public
void
containsDescendantOfWhenSourceReturnsUnknownShouldReturnUnknown
()
{
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
)
);
Answers
.
CALLS_REAL_METHODS
);
given
(
source
.
containsDescendantOf
(
name
))
given
(
source
.
containsDescendantOf
(
name
))
.
willReturn
(
ConfigurationPropertyState
.
UNKNOWN
);
.
willReturn
(
ConfigurationPropertyState
.
UNKNOWN
);
ConfigurationPropertySource
aliased
=
source
ConfigurationPropertySource
aliased
=
source
...
@@ -72,7 +71,7 @@ public class AliasedConfigurationPropertySourceTests {
...
@@ -72,7 +71,7 @@ public class AliasedConfigurationPropertySourceTests {
public
void
containsDescendantOfWhenSourceReturnsPresentShouldReturnPresent
()
{
public
void
containsDescendantOfWhenSourceReturnsPresentShouldReturnPresent
()
{
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
)
);
Answers
.
CALLS_REAL_METHODS
);
given
(
source
.
containsDescendantOf
(
name
))
given
(
source
.
containsDescendantOf
(
name
))
.
willReturn
(
ConfigurationPropertyState
.
PRESENT
);
.
willReturn
(
ConfigurationPropertyState
.
PRESENT
);
given
(
source
.
containsDescendantOf
(
ConfigurationPropertyName
.
of
(
"bar"
)))
given
(
source
.
containsDescendantOf
(
ConfigurationPropertyName
.
of
(
"bar"
)))
...
@@ -87,7 +86,7 @@ public class AliasedConfigurationPropertySourceTests {
...
@@ -87,7 +86,7 @@ public class AliasedConfigurationPropertySourceTests {
public
void
containsDescendantOfWhenAllAreAbsentShouldReturnAbsent
()
{
public
void
containsDescendantOfWhenAllAreAbsentShouldReturnAbsent
()
{
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
)
);
Answers
.
CALLS_REAL_METHODS
);
given
(
source
.
containsDescendantOf
(
name
))
given
(
source
.
containsDescendantOf
(
name
))
.
willReturn
(
ConfigurationPropertyState
.
ABSENT
);
.
willReturn
(
ConfigurationPropertyState
.
ABSENT
);
given
(
source
.
containsDescendantOf
(
ConfigurationPropertyName
.
of
(
"bar"
)))
given
(
source
.
containsDescendantOf
(
ConfigurationPropertyName
.
of
(
"bar"
)))
...
@@ -102,7 +101,7 @@ public class AliasedConfigurationPropertySourceTests {
...
@@ -102,7 +101,7 @@ public class AliasedConfigurationPropertySourceTests {
public
void
containsDescendantOfWhenAnyIsPresentShouldReturnPresent
()
{
public
void
containsDescendantOfWhenAnyIsPresentShouldReturnPresent
()
{
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
)
);
Answers
.
CALLS_REAL_METHODS
);
given
(
source
.
containsDescendantOf
(
name
))
given
(
source
.
containsDescendantOf
(
name
))
.
willReturn
(
ConfigurationPropertyState
.
ABSENT
);
.
willReturn
(
ConfigurationPropertyState
.
ABSENT
);
given
(
source
.
containsDescendantOf
(
ConfigurationPropertyName
.
of
(
"bar"
)))
given
(
source
.
containsDescendantOf
(
ConfigurationPropertyName
.
of
(
"bar"
)))
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSourceTests.java
View file @
3d2fbdf3
...
@@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalArgumentException
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalArgumentException
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
withSettings
;
/**
/**
* Test for {@link FilteredIterableConfigurationPropertiesSource}.
* Test for {@link FilteredIterableConfigurationPropertiesSource}.
...
@@ -67,7 +66,7 @@ public class FilteredConfigurationPropertiesSourceTests {
...
@@ -67,7 +66,7 @@ public class FilteredConfigurationPropertiesSourceTests {
public
void
containsDescendantOfWhenSourceReturnsEmptyShouldReturnEmpty
()
{
public
void
containsDescendantOfWhenSourceReturnsEmptyShouldReturnEmpty
()
{
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
)
);
Answers
.
CALLS_REAL_METHODS
);
given
(
source
.
containsDescendantOf
(
name
))
given
(
source
.
containsDescendantOf
(
name
))
.
willReturn
(
ConfigurationPropertyState
.
UNKNOWN
);
.
willReturn
(
ConfigurationPropertyState
.
UNKNOWN
);
ConfigurationPropertySource
filtered
=
source
.
filter
((
n
)
->
true
);
ConfigurationPropertySource
filtered
=
source
.
filter
((
n
)
->
true
);
...
@@ -79,7 +78,7 @@ public class FilteredConfigurationPropertiesSourceTests {
...
@@ -79,7 +78,7 @@ public class FilteredConfigurationPropertiesSourceTests {
public
void
containsDescendantOfWhenSourceReturnsFalseShouldReturnFalse
()
{
public
void
containsDescendantOfWhenSourceReturnsFalseShouldReturnFalse
()
{
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
)
);
Answers
.
CALLS_REAL_METHODS
);
given
(
source
.
containsDescendantOf
(
name
))
given
(
source
.
containsDescendantOf
(
name
))
.
willReturn
(
ConfigurationPropertyState
.
ABSENT
);
.
willReturn
(
ConfigurationPropertyState
.
ABSENT
);
ConfigurationPropertySource
filtered
=
source
.
filter
((
n
)
->
true
);
ConfigurationPropertySource
filtered
=
source
.
filter
((
n
)
->
true
);
...
@@ -91,7 +90,7 @@ public class FilteredConfigurationPropertiesSourceTests {
...
@@ -91,7 +90,7 @@ public class FilteredConfigurationPropertiesSourceTests {
public
void
containsDescendantOfWhenSourceReturnsTrueShouldReturnEmpty
()
{
public
void
containsDescendantOfWhenSourceReturnsTrueShouldReturnEmpty
()
{
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertyName
name
=
ConfigurationPropertyName
.
of
(
"foo"
);
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
ConfigurationPropertySource
source
=
mock
(
ConfigurationPropertySource
.
class
,
withSettings
().
defaultAnswer
(
Answers
.
CALLS_REAL_METHODS
)
);
Answers
.
CALLS_REAL_METHODS
);
given
(
source
.
containsDescendantOf
(
name
))
given
(
source
.
containsDescendantOf
(
name
))
.
willReturn
(
ConfigurationPropertyState
.
PRESENT
);
.
willReturn
(
ConfigurationPropertyState
.
PRESENT
);
ConfigurationPropertySource
filtered
=
source
.
filter
((
n
)
->
true
);
ConfigurationPropertySource
filtered
=
source
.
filter
((
n
)
->
true
);
...
...
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