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
4eda29a4
Commit
4eda29a4
authored
Dec 12, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
30e6b1d1
788fd777
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
AuditEvent.java
...va/org/springframework/boot/actuate/audit/AuditEvent.java
+3
-3
AuditEventTests.java
...g/springframework/boot/actuate/audit/AuditEventTests.java
+7
-7
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java
View file @
4eda29a4
...
...
@@ -85,10 +85,9 @@ public class AuditEvent implements Serializable {
public
AuditEvent
(
Date
timestamp
,
String
principal
,
String
type
,
Map
<
String
,
Object
>
data
)
{
Assert
.
notNull
(
timestamp
,
"Timestamp must not be null"
);
Assert
.
notNull
(
principal
,
"Principal must not be null"
);
Assert
.
notNull
(
type
,
"Type must not be null"
);
this
.
timestamp
=
timestamp
;
this
.
principal
=
principal
;
this
.
principal
=
principal
!=
null
?
principal
:
""
;
this
.
type
=
type
;
this
.
data
=
Collections
.
unmodifiableMap
(
data
);
}
...
...
@@ -117,7 +116,8 @@ public class AuditEvent implements Serializable {
}
/**
* Returns the user principal responsible for the event.
* Returns the user principal responsible for the event or an empty String if the
* principal is not available.
* @return the principal
*/
public
String
getPrincipal
()
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/AuditEventTests.java
View file @
4eda29a4
...
...
@@ -56,18 +56,18 @@ public class AuditEventTests {
}
@Test
public
void
nullTimestamp
()
throws
Exception
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Timestamp must not be null"
);
new
AuditEvent
(
null
,
"phil"
,
"UNKNOWN"
,
public
void
nullPrincipalIsMappedToEmptyString
()
{
AuditEvent
auditEvent
=
new
AuditEvent
(
null
,
"UNKNOWN"
,
Collections
.
singletonMap
(
"a"
,
(
Object
)
"b"
));
assertThat
(
auditEvent
.
getPrincipal
()).
isEmpty
();
}
@Test
public
void
null
Principal
()
throws
Exception
{
public
void
null
Timestamp
()
throws
Exception
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Principal must not be null"
);
new
AuditEvent
(
null
,
"UNKNOWN"
,
Collections
.
singletonMap
(
"a"
,
(
Object
)
"b"
));
this
.
thrown
.
expectMessage
(
"Timestamp must not be null"
);
new
AuditEvent
(
null
,
"phil"
,
"UNKNOWN"
,
Collections
.
singletonMap
(
"a"
,
(
Object
)
"b"
));
}
@Test
...
...
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