diff --git a/api/src/main/kotlin/io/github/wulkanowy/api/grades/GradesMapper.kt b/api/src/main/kotlin/io/github/wulkanowy/api/grades/GradesMapper.kt index a2e453e..191a386 100644 --- a/api/src/main/kotlin/io/github/wulkanowy/api/grades/GradesMapper.kt +++ b/api/src/main/kotlin/io/github/wulkanowy/api/grades/GradesMapper.kt @@ -10,6 +10,7 @@ fun GradesResponse.mapGradesList(): List { val values = getGradeValueWithModifier(grade.entry) grade.apply { subject = gradesSubject.name + entry = entry.removeSurrounding("(", ")") comment = entry.substringBefore(" (").run { if (length > 4) entry else entry.substringBeforeLast(")").substringAfter(" (") diff --git a/api/src/test/kotlin/io/github/wulkanowy/api/grades/GradesTest.kt b/api/src/test/kotlin/io/github/wulkanowy/api/grades/GradesTest.kt index 9b75942..45c47df 100644 --- a/api/src/test/kotlin/io/github/wulkanowy/api/grades/GradesTest.kt +++ b/api/src/test/kotlin/io/github/wulkanowy/api/grades/GradesTest.kt @@ -21,7 +21,7 @@ class GradesTest : BaseLocalTest() { @Test fun getAllTest() { assertEquals(10, snp.size) // 2 items are skipped - assertEquals(10, student.size) + assertEquals(11, student.size) assertEquals(3, studentPoints.size) } @@ -225,6 +225,24 @@ class GradesTest : BaseLocalTest() { } } + @Test + fun getGrade_onlyCommentEntry() { + with(student[10]) { + assertEquals("Fizyka", subject) + assertEquals("BK,3", entry) + assertEquals(0, value) + assertEquals(.0, modifier, .0) + assertEquals("", comment) + assertEquals("000000", color) + assertEquals("d1", symbol) + assertEquals("Sprawozdanie - wyznaczanie przyspieczenia.", description) + assertEquals("3,00", weight) + assertEquals(0.0, weightValue, .0) + assertEquals(getDate(2017, 11, 23), date) + assertEquals("Anonimus Max", teacher) + } + } + @Test fun getGrade_pointsEntry() { with(studentPoints[0]) { diff --git a/api/src/test/resources/io/github/wulkanowy/api/grades/Oceny.json b/api/src/test/resources/io/github/wulkanowy/api/grades/Oceny.json index 310105d..24bea7f 100644 --- a/api/src/test/resources/io/github/wulkanowy/api/grades/Oceny.json +++ b/api/src/test/resources/io/github/wulkanowy/api/grades/Oceny.json @@ -37,6 +37,15 @@ "KodKolumny": "O", "DataOceny": "05.12.2018", "KolorOceny": 7261447 + }, + { + "Nauczyciel": "Anonimus Max", + "Wpis": "(BK,3)", + "Waga": 3, + "NazwaKolumny": "Sprawozdanie - wyznaczanie przyspieczenia.", + "KodKolumny": "d1", + "DataOceny": "23.11.2017", + "KolorOceny": 0 } ], "ProponowanaOcenaRoczna": "3",