+++ /dev/null
-package net.pterodactylus.sone.web.ajax;
-
-import static java.lang.System.currentTimeMillis;
-import static net.pterodactylus.sone.web.ajax.GetTimesAjaxPage.getTime;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.when;
-
-import net.pterodactylus.sone.web.WebInterface;
-import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage.Time;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-
-/**
- * Unit test for {@link GetTimesAjaxPage}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class GetTimesAjaxPageTest {
-
- private final WebInterface webInterface = Mockito.mock(WebInterface.class, RETURNS_DEEP_STUBS);
-
- @Test
- public void timestampInTheFutureIsTranslatedCorrectly() {
- when(webInterface.getL10n().getString("View.Time.InTheFuture")).thenReturn("in the future");
- Time time = getTime(webInterface, currentTimeMillis() + 100);
- assertThat(time.getText(), is("in the future"));
- }
-
- @Test
- public void timestampAFewSecondsAgoIsTranslatedCorrectly() {
- when(webInterface.getL10n().getString("View.Time.AFewSecondsAgo")).thenReturn("a few seconds ago");
- Time time = getTime(webInterface, currentTimeMillis() - 1000);
- assertThat(time.getText(), is("a few seconds ago"));
- }
-
-}
--- /dev/null
+package net.pterodactylus.sone.web.ajax
+
+import net.pterodactylus.sone.test.deepMock
+import net.pterodactylus.sone.test.whenever
+import net.pterodactylus.sone.web.WebInterface
+import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.equalTo
+import org.junit.Test
+import java.lang.System.currentTimeMillis
+
+/**
+ * Unit test for [GetTimesAjaxPage].
+ */
+class GetTimesAjaxPageTest {
+
+ private val webInterface = deepMock<WebInterface>()
+
+ @Test
+ fun timestampInTheFutureIsTranslatedCorrectly() {
+ whenever(webInterface.l10n.getString("View.Time.InTheFuture")).thenReturn("in the future")
+ val time = GetTimesAjaxPage.getTime(webInterface, currentTimeMillis() + 1000)
+ assertThat(time.text, equalTo("in the future"))
+ }
+
+ @Test
+ fun timestampAFewSecondsAgoIsTranslatedCorrectly() {
+ whenever(webInterface.l10n.getString("View.Time.AFewSecondsAgo")).thenReturn("a few seconds ago")
+ val time = GetTimesAjaxPage.getTime(webInterface, currentTimeMillis() - 1000)
+ assertThat(time.text, equalTo("a few seconds ago"))
+ }
+
+}
import org.mockito.Mockito
inline fun <reified T : Any> mock(): T = Mockito.mock<T>(T::class.java)!!
+inline fun <reified T : Any> deepMock(): T = Mockito.mock<T>(T::class.java, Mockito.RETURNS_DEEP_STUBS)!!
inline fun <reified T : Any> capture(): ArgumentCaptor<T> = ArgumentCaptor.forClass(T::class.java)
inline fun <reified T : Any> bind(implementation: T): Module =