package beaform.utilities;

import static org.junit.Assert.assertTrue;

import org.junit.After;
import org.junit.Test;

public class SystemTimeTest {

	@After
	public void destroy() {
		SystemTime.reset();
	}

	@Test
	public void testDefaultTimeSource() {
		SystemTime.reset();
		final long start = System.currentTimeMillis();
		final long tested = SystemTime.getAsLong();
		final long end = System.currentTimeMillis();

		assertTrue("The tested value is not between the given arguments", isBetween(start, end, tested));
	}

	private boolean isBetween(long boundary1, long boundary2, long tested) {
		long upper, lower;

		if (boundary1 <= boundary2) {
			lower = boundary1;
			upper = boundary2;
		}
		else {
			lower = boundary2;
			upper = boundary1;
		}

		return (lower <= tested) && (tested <= upper);
	}

}

@@ -58,19 +58,88 @@
 t.assert
-Tru
+Equals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.Dat
 e;%0A%0Aimpo
@@ -242,24 +242,24 @@
 destroy() %7B%0A
-
 %09%09SystemTime
@@ -272,16 +272,422 @@
 ();%0A%09%7D%0A%0A
+%09@Test%0A%09public void testWithEpoch() %7B%0A%09%09SystemTime.setTimeSource(() -%3E 0);%0A%09%09long systemTimeInMillis = SystemTime.getAsLong();%0A%09%09assertEquals(%22The expected time should be 0%22, 0, systemTimeInMillis);%0A%09%7D%0A%0A%09@Test%0A%09public void testWithEpochAsDate() %7B%0A%09%09SystemTime.setTimeSource(() -%3E 0);%0A%09%09Date systemTime = SystemTime.getAsDate();%0A%09%09assertEquals(%22The expected time should be 0%22, 0, systemTime.getTime());%0A%09%7D%0A%0A
 %09@Test%0A%09

Add more tests for the SystemTime class