Skip to content

Commit

Permalink
Better name for Statistics model
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelkiessling committed Jan 12, 2016
1 parent 8bf9305 commit d5deb30
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions api/app/components/CassandraRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package components

import com.datastax.driver.core.Session
import com.journeymonitor.analyze.common.{CassandraClient, CassandraConnectionUri}
import models.Statistics
import models.StatisticsModel
import play.api.inject.ApplicationLifecycle
import play.api.{Configuration, Environment, Mode}
import repositories.{Repository, StatisticsRepository}
Expand Down Expand Up @@ -33,7 +33,7 @@ trait CassandraRepositoryComponents {
session
}

lazy val statisticsRepository: Repository[Statistics, String] = {
lazy val statisticsRepository: Repository[StatisticsModel, String] = {
new StatisticsRepository(cassandraSession)
}
}
7 changes: 4 additions & 3 deletions api/app/controllers/Statistics.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package controllers

import models.StatisticsModel
import play.api.libs.functional.syntax._
import play.api.libs.json._
import play.api.mvc._
import repositories.Repository

class Statistics(statisticsRepository: Repository[models.Statistics, String]) extends Controller {
class Statistics(statisticsRepository: Repository[StatisticsModel, String]) extends Controller {

implicit val StatisticsWrites: Writes[models.Statistics] = (
implicit val StatisticsWrites: Writes[StatisticsModel] = (
(JsPath \ "testresultId").write[String] and
(JsPath \ "numberOf200").write[Int]
)(unlift(models.Statistics.unapply))
)(unlift(StatisticsModel.unapply))

def show(testcaseId: String) = Action {
val statistics = statisticsRepository.getOneById(testcaseId)
Expand Down
3 changes: 0 additions & 3 deletions api/app/models/Statistics.scala

This file was deleted.

3 changes: 3 additions & 0 deletions api/app/models/StatisticsModel.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package models

case class StatisticsModel(testresultId: String, numberOf200: Int) extends Model
8 changes: 4 additions & 4 deletions api/app/repositories/StatisticsRepository.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package repositories

import com.datastax.driver.core.{Row, Session}
import models.Statistics
import models.StatisticsModel

class StatisticsRepository(session: Session)
extends CassandraRepository[Statistics, String](session, "statistics", "testcase_id") {
override def rowToModel(row: Row): Statistics = {
Statistics(row.getString("testresult_id"), row.getInt("number_of_200"))
extends CassandraRepository[StatisticsModel, String](session, "statistics", "testcase_id") {
override def rowToModel(row: Row): StatisticsModel = {
StatisticsModel(row.getString("testresult_id"), row.getInt("number_of_200"))
}
}
8 changes: 4 additions & 4 deletions api/test/ApplicationSpec.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.io.File

import models.Statistics
import models.StatisticsModel
import org.scalatestplus.play._
import play.api
import play.api.ApplicationLoader.Context
Expand All @@ -9,9 +9,9 @@ import play.api.test._
import play.api.{ApplicationLoader, Environment, Mode}
import repositories.Repository

class MockStatisticsRepository extends Repository[Statistics, String] {
override def getOneById(id: String): Statistics = {
Statistics("mocked-testresult-" + id, 123)
class MockStatisticsRepository extends Repository[StatisticsModel, String] {
override def getOneById(id: String): StatisticsModel = {
StatisticsModel("mocked-testresult-" + id, 123)
}
}

Expand Down

0 comments on commit d5deb30

Please sign in to comment.