scalafmt applied

master
mgifos 7 years ago
parent 22837ebc36
commit 30f8479ff6
  1. 6
      src/main/scala/com.github.mgifos.workouts/model/Target.scala
  2. 2
      src/test/scala/com/github/mgifos/workouts/WeekPlanSpec.scala
  3. 2
      src/test/scala/com/github/mgifos/workouts/model/DurationSpec.scala
  4. 16
      src/test/scala/com/github/mgifos/workouts/model/StepSpec.scala
  5. 48
      src/test/scala/com/github/mgifos/workouts/model/TargetSpec.scala

@ -104,9 +104,9 @@ object Target {
def parse(x: String)(implicit msys: MeasurementSystems.MeasurementSystem): Target = x.trim match { def parse(x: String)(implicit msys: MeasurementSystems.MeasurementSystem): Target = x.trim match {
case CadenceCustomRx(from, to) => CadenceCustomTarget(from.toInt, to.toInt) case CadenceCustomRx(from, to) => CadenceCustomTarget(from.toInt, to.toInt)
case HrZoneRx(zone) => HrZoneTarget(zone.toInt) case HrZoneRx(zone) => HrZoneTarget(zone.toInt)
case HrCustomRx(from, to) => HrCustomTarget(from.toInt, to.toInt) case HrCustomRx(from, to) => HrCustomTarget(from.toInt, to.toInt)
case PowerCustomRx(from, to) => PowerCustomTarget(from.toInt, to.toInt) case PowerCustomRx(from, to) => PowerCustomTarget(from.toInt, to.toInt)
case SpeedRangeRx(from, _, to, _, uom) => case SpeedRangeRx(from, _, to, _, uom) =>
val du = Option(uom).fold(msys.distance)(DistanceUnits.withSpeedUOM) val du = Option(uom).fold(msys.distance)(DistanceUnits.withSpeedUOM)
SpeedTarget(Speed(du, from), Speed(du, to)) SpeedTarget(Speed(du, from), Speed(du, to))

@ -1,7 +1,7 @@
package com.github.mgifos.workouts package com.github.mgifos.workouts
import com.github.mgifos.workouts.model._ import com.github.mgifos.workouts.model._
import org.scalatest.{ FlatSpec, Matchers } import org.scalatest.{FlatSpec, Matchers}
class WeekPlanSpec extends FlatSpec with Matchers { class WeekPlanSpec extends FlatSpec with Matchers {

@ -1,6 +1,6 @@
package com.github.mgifos.workouts.model package com.github.mgifos.workouts.model
import org.scalatest.{ FlatSpec, Matchers } import org.scalatest.{FlatSpec, Matchers}
import com.github.mgifos.workouts.model.DistanceUnits._ import com.github.mgifos.workouts.model.DistanceUnits._
class DurationSpec extends FlatSpec with Matchers { class DurationSpec extends FlatSpec with Matchers {

@ -1,7 +1,7 @@
package com.github.mgifos.workouts.model package com.github.mgifos.workouts.model
import com.github.mgifos.workouts.model.DistanceUnits._ import com.github.mgifos.workouts.model.DistanceUnits._
import org.scalatest.{ FlatSpec, Matchers } import org.scalatest.{FlatSpec, Matchers}
class StepSpec extends FlatSpec with Matchers { class StepSpec extends FlatSpec with Matchers {
@ -13,13 +13,15 @@ class StepSpec extends FlatSpec with Matchers {
a[IllegalArgumentException] should be thrownBy Step.parse("- warmup: 5km\n - run: 10km\n - recover: 100m") a[IllegalArgumentException] should be thrownBy Step.parse("- warmup: 5km\n - run: 10km\n - recover: 100m")
Step.parse("- warmup: 5km") should be(WarmupStep(DistanceDuration(5, km))) Step.parse("- warmup: 5km") should be(WarmupStep(DistanceDuration(5, km)))
Step.parse("- run: 2km @ 5:00-4:50") should be(IntervalStep(DistanceDuration(2, km), Some(PaceTarget(Pace(msys.distance, "5:00"), Pace(msys.distance, "4:50"))))) Step.parse("- run: 2km @ 5:00-4:50") should be(
Step.parse("- bike: 2km @ 20-30 kph") should be(IntervalStep(DistanceDuration(2, km), Some(SpeedTarget(Speed(msys.distance, "20"), Speed(msys.distance, "30"))))) IntervalStep(DistanceDuration(2, km), Some(PaceTarget(Pace(msys.distance, "5:00"), Pace(msys.distance, "4:50")))))
Step.parse("- go: 20km @ 9:00-11:00") should be(IntervalStep(DistanceDuration(20, km), Some(PaceTarget(Pace(msys.distance, "9:00"), Pace(msys.distance, "11:00"))))) Step.parse("- bike: 2km @ 20-30 kph") should be(
IntervalStep(DistanceDuration(2, km), Some(SpeedTarget(Speed(msys.distance, "20"), Speed(msys.distance, "30")))))
Step.parse("- go: 20km @ 9:00-11:00") should be(
IntervalStep(DistanceDuration(20, km), Some(PaceTarget(Pace(msys.distance, "9:00"), Pace(msys.distance, "11:00")))))
Step.parse("- recover: 500m @z2") should be(RecoverStep(DistanceDuration(500, m), Some(HrZoneTarget(2)))) Step.parse("- recover: 500m @z2") should be(RecoverStep(DistanceDuration(500, m), Some(HrZoneTarget(2))))
Step.parse("- cooldown: 05:00") should be(CooldownStep(TimeDuration(minutes = 5))) Step.parse("- cooldown: 05:00") should be(CooldownStep(TimeDuration(minutes = 5)))
Step.parse("- repeat: 3\n - run: 10km\n - recover: 100m") should be(RepeatStep(3, List( Step.parse("- repeat: 3\n - run: 10km\n - recover: 100m") should be(
IntervalStep(DistanceDuration(10, km)), RepeatStep(3, List(IntervalStep(DistanceDuration(10, km)), RecoverStep(DistanceDuration(100, m)))))
RecoverStep(DistanceDuration(100, m)))))
} }
} }

@ -1,8 +1,8 @@
package com.github.mgifos.workouts.model package com.github.mgifos.workouts.model
import org.scalatest.{ FlatSpec, Matchers } import org.scalatest.{FlatSpec, Matchers}
import com.github.mgifos.workouts.model.DistanceUnits._ import com.github.mgifos.workouts.model.DistanceUnits._
import play.api.libs.json.{ JsNull, Json } import play.api.libs.json.{JsNull, Json}
class TargetSpec extends FlatSpec with Matchers { class TargetSpec extends FlatSpec with Matchers {
@ -35,36 +35,36 @@ class TargetSpec extends FlatSpec with Matchers {
"Target" should "handle custom HR specification correctly" in { "Target" should "handle custom HR specification correctly" in {
val hrcTarget = Target.parse("130-150 bpm").asInstanceOf[HrCustomTarget] val hrcTarget = Target.parse("130-150 bpm").asInstanceOf[HrCustomTarget]
hrcTarget should be(HrCustomTarget(130, 150)) hrcTarget should be(HrCustomTarget(130, 150))
hrcTarget.json should be(Json.obj( hrcTarget.json should be(
"targetType" -> Json.obj( Json.obj(
"workoutTargetTypeId" -> 4, "targetType" -> Json.obj("workoutTargetTypeId" -> 4, "workoutTargetTypeKey" -> "heart.rate.zone"),
"workoutTargetTypeKey" -> "heart.rate.zone"), "targetValueOne" -> 130,
"targetValueOne" -> 130, "targetValueTwo" -> 150,
"targetValueTwo" -> 150, "zoneNumber" -> JsNull
"zoneNumber" -> JsNull)) ))
} }
"Target" should "handle custom POWER specification correctly" in { "Target" should "handle custom POWER specification correctly" in {
val powTarget = Target.parse("230-250 W").asInstanceOf[PowerCustomTarget] val powTarget = Target.parse("230-250 W").asInstanceOf[PowerCustomTarget]
powTarget should be(PowerCustomTarget(230, 250)) powTarget should be(PowerCustomTarget(230, 250))
powTarget.json should be(Json.obj( powTarget.json should be(
"targetType" -> Json.obj( Json.obj(
"workoutTargetTypeId" -> 2, "targetType" -> Json.obj("workoutTargetTypeId" -> 2, "workoutTargetTypeKey" -> "power.zone"),
"workoutTargetTypeKey" -> "power.zone"), "targetValueOne" -> 230,
"targetValueOne" -> 230, "targetValueTwo" -> 250,
"targetValueTwo" -> 250, "zoneNumber" -> JsNull
"zoneNumber" -> JsNull)) ))
} }
"Target" should "handle custom CADENCE specification correctly" in { "Target" should "handle custom CADENCE specification correctly" in {
val cadenceTarget = Target.parse("80-90 rpm").asInstanceOf[CadenceCustomTarget] val cadenceTarget = Target.parse("80-90 rpm").asInstanceOf[CadenceCustomTarget]
cadenceTarget should be(CadenceCustomTarget(80, 90)) cadenceTarget should be(CadenceCustomTarget(80, 90))
cadenceTarget.json should be(Json.obj( cadenceTarget.json should be(
"targetType" -> Json.obj( Json.obj(
"workoutTargetTypeId" -> 3, "targetType" -> Json.obj("workoutTargetTypeId" -> 3, "workoutTargetTypeKey" -> "cadence.zone"),
"workoutTargetTypeKey" -> "cadence.zone"), "targetValueOne" -> 80,
"targetValueOne" -> 80, "targetValueTwo" -> 90,
"targetValueTwo" -> 90, "zoneNumber" -> JsNull
"zoneNumber" -> JsNull)) ))
} }
} }

Loading…
Cancel
Save