53 lines
1.9 KiB
Kotlin
53 lines
1.9 KiB
Kotlin
/**
|
|
* ProjectLaogai
|
|
*
|
|
* Copyright 2019-2020 <seil0@mosad.xyz>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
* MA 02110-1301, USA.
|
|
*
|
|
*/
|
|
|
|
package org.mosad.seil0.projectlaogai
|
|
|
|
import com.google.gson.GsonBuilder
|
|
import com.google.gson.reflect.TypeToken
|
|
import org.junit.Assert
|
|
import org.junit.Test
|
|
import org.mosad.seil0.projectlaogai.controller.GradesController
|
|
import org.mosad.seil0.projectlaogai.util.GradeSubject
|
|
import java.io.File
|
|
import java.io.FileReader
|
|
|
|
class GradesControllerTest {
|
|
|
|
@Test
|
|
fun diffGrades_isCorrect() {
|
|
val origFile = File(GradesControllerTest::class.java.getResource("/grades_orig.json")?.path!!)
|
|
val diffFile = File(GradesControllerTest::class.java.getResource("/grades_diff.json")?.path!!)
|
|
|
|
val mapA: HashMap<String, ArrayList<GradeSubject>> = FileReader(origFile).use {
|
|
GsonBuilder().create().fromJson(it, object : TypeToken<HashMap<String, ArrayList<GradeSubject>>>() {}.type)
|
|
}
|
|
|
|
val mapB: HashMap<String, ArrayList<GradeSubject>> = FileReader(diffFile).use {
|
|
GsonBuilder().create().fromJson(it, object : TypeToken<HashMap<String, ArrayList<GradeSubject>>>() {}.type)
|
|
}
|
|
|
|
val ret = GradesController().diffGrades(mapA, mapB)
|
|
|
|
Assert.assertEquals(1, ret)
|
|
}
|
|
} |