20
20
import java .util .HashMap ;
21
21
import java .util .Map ;
22
22
23
- public class ErrorDocument {
24
- private String errorUri = null ;
25
- private static final Map <String , Integer > ERROR_CODES = new HashMap <>();
26
- private String summary = null ;
27
- private String verboseDescription = null ;
28
- private int status ;
23
+ public final class ErrorDocument {
24
+ private final String errorUri ;
25
+ // package private to be accessible in tests
26
+ static final Map <String , Integer > ERROR_CODES = new HashMap <>();
27
+ private final String dateUpdated = DateTimeFormatter .ISO_INSTANT .format (ZonedDateTime .now ().truncatedTo (ChronoUnit .SECONDS ));
28
+ private final String summary ;
29
+ private final String verboseDescription ;
30
+ private final int status ;
29
31
30
32
static {
31
33
// set up the error codes mapping
@@ -72,6 +74,11 @@ public int getStatus() {
72
74
return HttpServletResponse .SC_BAD_REQUEST ; // bad request
73
75
}
74
76
}
77
+
78
+ // test use only
79
+ String getDateUpdated () {
80
+ return dateUpdated ;
81
+ }
75
82
76
83
public void writeTo (final Writer out , final SwordConfiguration config ) throws SwordServerException {
77
84
@@ -96,7 +103,7 @@ public void writeTo(final Writer out, final SwordConfiguration config) throws Sw
96
103
97
104
// <sword:error><updated>
98
105
Element updated = doc .createElementNS (UriRegistry .ATOM_NAMESPACE , "updated" );
99
- updated .setTextContent (DateTimeFormatter . ISO_INSTANT . format ( ZonedDateTime . now (). truncatedTo ( ChronoUnit . SECONDS )) );
106
+ updated .setTextContent (this . dateUpdated );
100
107
swordError .appendChild (updated );
101
108
102
109
// <sword:error><generator>
0 commit comments