@@ -109,7 +109,7 @@ void startedFormat() {
109109 new StartupInfoLogger (getClass (), this .environment ).logStarted (this .log , new TestStartup (1345L , "Started" ));
110110 then (this .log ).should ()
111111 .info (assertArg ((message ) -> assertThat (message .toString ()).matches ("Started " + getClass ().getSimpleName ()
112- + " in \\ d+\\ .\\ d{1,3} seconds \\ (process running for 1.345\\ )" )));
112+ + " in \\ d+\\ .\\ d{1,3} seconds \\ (process running for 1\\ .345 seconds \\ )" )));
113113 }
114114
115115 @ Test
@@ -130,17 +130,69 @@ void restoredFormat() {
130130 .matches ("Restored " + getClass ().getSimpleName () + " in \\ d+\\ .\\ d{1,3} seconds" )));
131131 }
132132
133+ @ Test
134+ void startedFormatWithMinutes () {
135+ given (this .log .isInfoEnabled ()).willReturn (true );
136+ new StartupInfoLogger (getClass (), this .environment ).logStarted (this .log ,
137+ new TestStartup (90000L , "Started" , 90000L ));
138+ then (this .log ).should ()
139+ .info (assertArg (
140+ (message ) -> assertThat (message .toString ()).isEqualTo ("Started " + getClass ().getSimpleName ()
141+ + " in 1 minute 30 seconds (process running for 1 minute 30 seconds)" )));
142+ }
143+
144+ @ Test
145+ void startedFormatWithHours () {
146+ given (this .log .isInfoEnabled ()).willReturn (true );
147+ new StartupInfoLogger (getClass (), this .environment ).logStarted (this .log ,
148+ new TestStartup (4500000L , "Started" , 4500000L ));
149+ then (this .log ).should ()
150+ .info (assertArg ((message ) -> assertThat (message .toString ()).isEqualTo ("Started "
151+ + getClass ().getSimpleName () + " in 1 hour 15 minutes (process running for 1 hour 15 minutes)" )));
152+ }
153+
154+ @ Test
155+ void startedFormatWithSingularUnits () {
156+ given (this .log .isInfoEnabled ()).willReturn (true );
157+ new StartupInfoLogger (getClass (), this .environment ).logStarted (this .log ,
158+ new TestStartup (61000L , "Started" , 61000L ));
159+ then (this .log ).should ()
160+ .info (assertArg ((message ) -> assertThat (message .toString ()).isEqualTo ("Started "
161+ + getClass ().getSimpleName () + " in 1 minute 1 second (process running for 1 minute 1 second)" )));
162+ }
163+
164+ @ Test
165+ void startedFormatWithZeroSeconds () {
166+ given (this .log .isInfoEnabled ()).willReturn (true );
167+ new StartupInfoLogger (getClass (), this .environment ).logStarted (this .log ,
168+ new TestStartup (300000L , "Started" , 300000L ));
169+ then (this .log ).should ()
170+ .info (assertArg (
171+ (message ) -> assertThat (message .toString ()).isEqualTo ("Started " + getClass ().getSimpleName ()
172+ + " in 5 minutes 0 seconds (process running for 5 minutes 0 seconds)" )));
173+ }
174+
133175 static class TestStartup extends Startup {
134176
135- private final long startTime = System . currentTimeMillis () ;
177+ private long startTime ;
136178
137179 private final @ Nullable Long uptime ;
138180
139181 private final String action ;
140182
141183 TestStartup (@ Nullable Long uptime , String action ) {
184+ this (uptime , action , null );
185+ }
186+
187+ TestStartup (@ Nullable Long uptime , String action , @ Nullable Long timeTaken ) {
142188 this .uptime = uptime ;
143189 this .action = action ;
190+ if (timeTaken != null ) {
191+ this .startTime = System .currentTimeMillis () - timeTaken ;
192+ }
193+ else {
194+ this .startTime = System .currentTimeMillis ();
195+ }
144196 started ();
145197 }
146198
0 commit comments