package io.schinzel.basicutils;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import static org.exparity.hamcrest.date.LocalDateTimeMatchers.within;
import static org.junit.Assert.*;
import org.junit.Test;

/**
 *
 * @author schinzel
 */
public class MiscUtilTest extends MiscUtil {

    @Test
    public void testSnooze() {
        int snoozeTime = 100;
        //Test the snooze 10 times
        for (int i = 0; i < 10; i++) {
            LocalDateTime start = LocalDateTime.now();
            MiscUtil.snooze(snoozeTime);
            //Check that the snooze does not differ more than 20% of the request snooze time.
            assertThat(LocalDateTime.now(),
                    within(20, ChronoUnit.MILLIS, start.plus(snoozeTime, ChronoUnit.MILLIS)));
        }
    }

}

@@ -365,16 +365,24 @@
 oozeTime
+InMillis
  = 100;%0A
@@ -548,16 +548,24 @@
 oozeTime
+InMillis
 );%0A     
@@ -627,9 +627,11 @@
 n 20
-%25
+ ms
  of 
@@ -641,16 +641,18 @@
  request
+ed
  snooze 
@@ -772,16 +772,24 @@
 oozeTime
+InMillis
 , Chrono
@@ -821,10 +821,442 @@
 %0A    %7D%0A%0A
+%0A    @Test%0A    public void testSnoozeSeconds() %7B%0A        int snoozeTimeInSeconds = 1;%0A        LocalDateTime start = LocalDateTime.now();%0A        MiscUtil.snoozeSeconds(snoozeTimeInSeconds);%0A        //Check that the snooze does not differ more than 20 ms of the requested snooze time.%0A        assertThat(LocalDateTime.now(),%0A                within(20, ChronoUnit.MILLIS, start.plus(snoozeTimeInSeconds, ChronoUnit.SECONDS)));%0A    %7D%0A%0A
 %7D%0A

Test added