Convert JukeboxStatus domain entity to kotlin.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-02-22 21:36:58 +01:00
parent 3dd7e531b9
commit 21b3fcc77c
4 changed files with 17 additions and 80 deletions

View File

@ -1,72 +0,0 @@
/*
This file is part of Subsonic.
Subsonic 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.
Subsonic 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 Subsonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2009 (C) Sindre Mehus
*/
package org.moire.ultrasonic.domain;
/**
* @author Sindre Mehus
* @version $Id$
*/
public class JukeboxStatus
{
private Integer positionSeconds;
private Integer currentPlayingIndex;
private Float gain;
private boolean playing;
public Integer getPositionSeconds()
{
return positionSeconds;
}
public void setPositionSeconds(Integer positionSeconds)
{
this.positionSeconds = positionSeconds;
}
public Integer getCurrentPlayingIndex()
{
return currentPlayingIndex;
}
public void setCurrentIndex(Integer currentPlayingIndex)
{
this.currentPlayingIndex = currentPlayingIndex;
}
public boolean isPlaying()
{
return playing;
}
public void setPlaying(boolean playing)
{
this.playing = playing;
}
public Float getGain()
{
return gain;
}
public void setGain(float gain)
{
this.gain = gain;
}
}

View File

@ -4,9 +4,9 @@ package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.JukeboxStatus as ApiJukeboxStatus
fun ApiJukeboxStatus.toDomainEntity(): JukeboxStatus = JukeboxStatus().apply {
positionSeconds = this@toDomainEntity.position
setCurrentIndex(this@toDomainEntity.currentIndex)
isPlaying = this@toDomainEntity.playing
fun ApiJukeboxStatus.toDomainEntity(): JukeboxStatus = JukeboxStatus(
positionSeconds = this@toDomainEntity.position,
currentPlayingIndex = this@toDomainEntity.currentIndex,
isPlaying = this@toDomainEntity.playing,
gain = this@toDomainEntity.gain
}
)

View File

@ -0,0 +1,8 @@
package org.moire.ultrasonic.domain
data class JukeboxStatus(
var positionSeconds: Int? = null,
var currentPlayingIndex: Int? = null,
var gain: Float? = null,
var isPlaying: Boolean = false
)

View File

@ -3,6 +3,7 @@
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
import org.junit.Test
import org.moire.ultrasonic.api.subsonic.models.JukeboxStatus
@ -17,10 +18,10 @@ class APIJukeboxConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
currentPlayingIndex `should equal to` entity.currentIndex
gain `should equal to` entity.gain
currentPlayingIndex `should equal` entity.currentIndex
gain `should equal` entity.gain
isPlaying `should equal to` entity.playing
positionSeconds `should equal to` entity.position
positionSeconds `should equal` entity.position
}
}
}