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