From 1d2516a59b39f876174f40d70acdc1daf654244f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Tue, 21 Aug 2018 01:56:36 +0200 Subject: [PATCH] Convert date in notes --- src/main/kotlin/io/github/wulkanowy/api/notes/Note.kt | 4 +++- .../kotlin/io/github/wulkanowy/api/notes/NotesResponse.kt | 6 +++++- src/test/kotlin/io/github/wulkanowy/api/VulcanTest.kt | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/io/github/wulkanowy/api/notes/Note.kt b/src/main/kotlin/io/github/wulkanowy/api/notes/Note.kt index 1b338371..2d6ed3c1 100644 --- a/src/main/kotlin/io/github/wulkanowy/api/notes/Note.kt +++ b/src/main/kotlin/io/github/wulkanowy/api/notes/Note.kt @@ -1,9 +1,11 @@ package io.github.wulkanowy.api.notes import pl.droidsonroids.jspoon.annotation.Selector +import java.util.* class Note { - lateinit var date: String + + lateinit var date: Date @Selector(".wartosc", index = 0) lateinit var teacher: String diff --git a/src/main/kotlin/io/github/wulkanowy/api/notes/NotesResponse.kt b/src/main/kotlin/io/github/wulkanowy/api/notes/NotesResponse.kt index ca48c404..c1929456 100644 --- a/src/main/kotlin/io/github/wulkanowy/api/notes/NotesResponse.kt +++ b/src/main/kotlin/io/github/wulkanowy/api/notes/NotesResponse.kt @@ -1,12 +1,16 @@ package io.github.wulkanowy.api.notes +import io.github.wulkanowy.api.DATE_FORMAT +import pl.droidsonroids.jspoon.annotation.Format import pl.droidsonroids.jspoon.annotation.Selector +import java.util.* class NotesResponse { @Selector(".mainContainer article") var notes: List = listOf() + @Format(DATE_FORMAT) @Selector(".mainContainer h2") - var dates: List = listOf() + var dates: List = listOf() } diff --git a/src/test/kotlin/io/github/wulkanowy/api/VulcanTest.kt b/src/test/kotlin/io/github/wulkanowy/api/VulcanTest.kt index 5044ff1a..af11f8f6 100644 --- a/src/test/kotlin/io/github/wulkanowy/api/VulcanTest.kt +++ b/src/test/kotlin/io/github/wulkanowy/api/VulcanTest.kt @@ -96,6 +96,7 @@ class VulcanTest { val values = notesObserver.values()[0] + assertEquals(getDate(2018, 3, 26), values[0].date) assertEquals("Janusz Tracz", values[0].teacher) assertEquals("Udział w konkursie szkolnym +20 pkt", values[0].category) assertEquals("+ 20p za udział w Konkursie Języka Angielskiego", values[0].content)