import net.pterodactylus.sone.test.whenever
import net.pterodactylus.sone.text.TimeText
import net.pterodactylus.sone.text.TimeTextConverter
import net.pterodactylus.sone.test.whenever
import net.pterodactylus.sone.text.TimeText
import net.pterodactylus.sone.text.TimeTextConverter
import net.pterodactylus.util.notify.Notification
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.allOf
import net.pterodactylus.util.notify.Notification
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.allOf
- override var page: JsonPage = GetStatusAjaxPage(webInterface, timeTextConverter, l10nFilter)
+ override var page: JsonPage = GetStatusAjaxPage(webInterface, elementLoader, timeTextConverter, l10nFilter, TimeZone.getTimeZone("UTC"))
- fun `page returns correct path`() {
- assertThat(page.path, equalTo("getStatus.ajax"))
- }
-
- @Test
- fun `page does not require form password`() {
- assertThat(page.needsFormPassword(), equalTo(false))
- }
-
- @Test
- fun `page does not require login`() {
- assertThat(page.requiresLogin(), equalTo(false))
- }
-
- @Test
fun `page returns correct attribute “loggedIn” if sone is logged in`() {
assertThat(json.get("loggedIn").asText(), equalTo("true"))
}
fun `page returns correct attribute “loggedIn” if sone is logged in`() {
assertThat(json.get("loggedIn").asText(), equalTo("true"))
}
@Test
fun `page returns a sones object with the current sone if not other sones parameter is given`() {
assertThat(json.get("sones").elements().asSequence().map { it.toMap() }.toList(), containsInAnyOrder(
@Test
fun `page returns a sones object with the current sone if not other sones parameter is given`() {
assertThat(json.get("sones").elements().asSequence().map { it.toMap() }.toList(), containsInAnyOrder(
- mapOf<String, String?>("id" to "soneId", "name" to "Sone_Id", "local" to "true", "status" to "idle", "modified" to "false", "locked" to "false", "lastUpdatedUnknown" to "false", "lastUpdated" to "Jan 1, 1970, 01:00:01", "lastUpdatedText" to "1000")
+ mapOf<String, String?>("id" to "soneId", "name" to "Sone_Id", "local" to "true", "status" to "idle", "modified" to "false", "locked" to "false", "lastUpdatedUnknown" to "false", "lastUpdated" to "Jan 1, 1970, 00:00:01", "lastUpdatedText" to "1000")
addSone(deepMock<Sone>().mock("sone3", "Sone 3", true, 3000, inserting))
addRequestParameter("soneIds", "sone1,sone2,sone3")
assertThat(json.get("sones").elements().asSequence().map { it.toMap() }.toList(), containsInAnyOrder(
addSone(deepMock<Sone>().mock("sone3", "Sone 3", true, 3000, inserting))
addRequestParameter("soneIds", "sone1,sone2,sone3")
assertThat(json.get("sones").elements().asSequence().map { it.toMap() }.toList(), containsInAnyOrder(
- mapOf<String, String?>("id" to "soneId", "name" to "Sone_Id", "local" to "true", "status" to "idle", "modified" to "false", "locked" to "false", "lastUpdatedUnknown" to "false", "lastUpdated" to "Jan 1, 1970, 01:00:01", "lastUpdatedText" to "1000"),
- mapOf("id" to "sone1", "name" to "Sone 1", "local" to "false", "status" to "downloading", "modified" to "false", "locked" to "false", "lastUpdatedUnknown" to "false", "lastUpdated" to "Jan 1, 1970, 01:00:02", "lastUpdatedText" to "2000"),
- mapOf("id" to "sone3", "name" to "Sone 3", "local" to "true", "status" to "inserting", "modified" to "false", "locked" to "false", "lastUpdatedUnknown" to "false", "lastUpdated" to "Jan 1, 1970, 01:00:03", "lastUpdatedText" to "3000")
+ mapOf<String, String?>("id" to "soneId", "name" to "Sone_Id", "local" to "true", "status" to "idle", "modified" to "false", "locked" to "false", "lastUpdatedUnknown" to "false", "lastUpdated" to "Jan 1, 1970, 00:00:01", "lastUpdatedText" to "1000"),
+ mapOf("id" to "sone1", "name" to "Sone 1", "local" to "false", "status" to "downloading", "modified" to "false", "locked" to "false", "lastUpdatedUnknown" to "false", "lastUpdated" to "Jan 1, 1970, 00:00:02", "lastUpdatedText" to "2000"),
+ mapOf("id" to "sone3", "name" to "Sone 3", "local" to "true", "status" to "inserting", "modified" to "false", "locked" to "false", "lastUpdatedUnknown" to "false", "lastUpdated" to "Jan 1, 1970, 00:00:03", "lastUpdatedText" to "3000")
mock<Notification>().apply { whenever(this.createdTime).thenReturn(2000) },
mock<Notification>().apply { whenever(this.createdTime).thenReturn(1000) }
)
mock<Notification>().apply { whenever(this.createdTime).thenReturn(2000) },
mock<Notification>().apply { whenever(this.createdTime).thenReturn(1000) }
)
+ @Test
+ fun `page returns information about loaded elements`() {
+ addLinkedElement("KSK@test.png", loading = false, failed = false)
+ addLinkedElement("KSK@test.html", loading = true, failed = false)
+ addLinkedElement("KSK@test.jpeg", loading = false, failed = true)
+ addRequestParameter("elements", jsonArray("KSK@test.png", "KSK@test.html", "KSK@test.jpeg").toString())
+ assertThat(json.get("linkedElements").elements().asSequence().map { it.toMap() }.toList(), containsInAnyOrder(
+ mapOf<String, String?>("link" to "KSK@test.png", "loading" to "false", "failed" to "false"),
+ mapOf("link" to "KSK@test.html", "loading" to "true", "failed" to "false"),
+ mapOf("link" to "KSK@test.jpeg", "loading" to "false", "failed" to "true")
+ ))
+ }
+