Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-44052] Document & fix intended behaviour (#3043)
* [JENKINS-44052] Document & fix intended behaviour The unit was actually ignored... * Add tests for getTimeInSeconds
- Loading branch information
1 parent
fbaa059
commit ff36adf
Showing
4 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package jenkins.util; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.*; | ||
|
||
import static jenkins.util.TimeDuration.*; | ||
|
||
|
||
public class TimeDurationTest { | ||
|
||
@Test | ||
public void fromString() throws Exception { | ||
assertEquals(1, TimeDuration.fromString("1").getTimeInMillis()); | ||
|
||
assertEquals(1000, TimeDuration.fromString("1sec").getTimeInMillis()); | ||
assertEquals(1000, TimeDuration.fromString("1secs").getTimeInMillis()); | ||
assertEquals(1000, TimeDuration.fromString("1 secs ").getTimeInMillis()); | ||
assertEquals(1000, TimeDuration.fromString(" 1 secs ").getTimeInMillis()); | ||
assertEquals(1, TimeDuration.fromString(" 1 secs ").getTimeInSeconds()); | ||
|
||
assertEquals(21000, TimeDuration.fromString(" 21 secs ").getTimeInMillis()); | ||
assertEquals(21, TimeDuration.fromString(" 21 secs ").getTimeInSeconds()); | ||
} | ||
|
||
} |