Add missing fields to License entity.

Add email and licenseExpires fields. Make all fields have default value,
this allows to make license field in LicenseResponse non-null.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-07-25 22:23:47 +02:00
parent 1caeaa9fe6
commit 0d3c0f0334
4 changed files with 19 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import okhttp3.mockwebserver.MockResponse
import okio.Okio
import org.amshove.kluent.`should be`
import org.amshove.kluent.`should contain`
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
import org.amshove.kluent.`should not be`
import org.amshove.kluent.`should not contain`
@ -110,7 +111,10 @@ class SubsonicAPIClientTest {
assertResponseSuccessful(response)
with(response.body()) {
assertBaseResponseOk()
license `should equal` License(true, parseDate("2016-11-23T20:17:15.206Z"))
license `should equal` License(valid = true,
trialExpires = parseDate("2016-11-23T20:17:15.206Z"),
email = "someone@example.net",
licenseExpires = parseDate("8994-08-17T07:12:55.807Z"))
}
}
@ -118,7 +122,11 @@ class SubsonicAPIClientTest {
fun `Should parse get license error response`() {
val response = checkErrorCallParsed { client.api.getLicense().execute() }
response.license `should be` null
response.license `should not be` null
with(response.license) {
email `should equal to` ""
valid `should equal to` false
}
}
@Test

View File

@ -4,6 +4,8 @@
"version" : "1.13.0",
"license" : {
"valid" : true,
"email" : "someone@example.net",
"licenseExpires" : "8994-08-17T07:12:55.807Z",
"trialExpires" : "2016-11-23T20:17:15.206Z"
}
}

View File

@ -1,5 +1,9 @@
package org.moire.ultrasonic.api.subsonic.models
import java.util.*
import java.util.Calendar
data class License(val valid: Boolean, val trialExpires: Calendar)
data class License(
val valid: Boolean = false,
val email: String = "",
val trialExpires: Calendar = Calendar.getInstance(),
val licenseExpires: Calendar = Calendar.getInstance())

View File

@ -3,9 +3,8 @@ package org.moire.ultrasonic.api.subsonic.response
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.License
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
class LicenseResponse(val license: License?,
class LicenseResponse(val license: License = License(),
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?):