diff --git a/warp-core/src/generated/scala/com/workday/warp/persistence/model/Tables.scala b/warp-core/src/generated/scala/com/workday/warp/persistence/model/Tables.scala index ad96fd67..4dfb19e7 100644 --- a/warp-core/src/generated/scala/com/workday/warp/persistence/model/Tables.scala +++ b/warp-core/src/generated/scala/com/workday/warp/persistence/model/Tables.scala @@ -83,22 +83,12 @@ trait Tables { implicit object TestDefinitionRowTypeClassObject extends TestDefinitionRowLikeType[TestDefinitionRow] { def idTestDefinition(row: TestDefinitionRow): Int = row.idTestDefinition def methodSignature(row: TestDefinitionRow): String = row.methodSignature - def active(row: TestDefinitionRow): Boolean = row.active - def productName(row: TestDefinitionRow): String = row.productName - def subProductName(row: TestDefinitionRow): String = row.subProductName - def className(row: TestDefinitionRow): String = row.className - def methodName(row: TestDefinitionRow): String = row.methodName def documentation(row: TestDefinitionRow): Option[String] = row.documentation } implicit object TestDefinitionRowWrapperTypeClassObject extends TestDefinitionRowLikeType[TestDefinitionRowWrapper] { def idTestDefinition(row: TestDefinitionRowWrapper): Int = row.idTestDefinition def methodSignature(row: TestDefinitionRowWrapper): String = row.methodSignature - def active(row: TestDefinitionRowWrapper): Boolean = row.active - def productName(row: TestDefinitionRowWrapper): String = row.productName - def subProductName(row: TestDefinitionRowWrapper): String = row.subProductName - def className(row: TestDefinitionRowWrapper): String = row.className - def methodName(row: TestDefinitionRowWrapper): String = row.methodName def documentation(row: TestDefinitionRowWrapper): Option[String] = row.documentation } implicit object TestDefinitionMetaTagRowTypeClassObject extends TestDefinitionMetaTagRowLikeType[TestDefinitionMetaTagRow] { @@ -357,49 +347,32 @@ trait Tables { /** Entity class storing rows of table TestDefinition * @param idTestDefinition Database column idTestDefinition SqlType(INT), AutoInc, PrimaryKey * @param methodSignature Database column methodSignature SqlType(VARCHAR), Length(255,true) - * @param active Database column active SqlType(BIT) - * @param productName Database column productName SqlType(VARCHAR), Length(255,true) - * @param subProductName Database column subProductName SqlType(VARCHAR), Length(255,true) - * @param className Database column className SqlType(VARCHAR), Length(255,true) - * @param methodName Database column methodName SqlType(VARCHAR), Length(255,true) * @param documentation Database column documentation SqlType(TEXT), Default(None) */ - class TestDefinitionRowWrapper(val idTestDefinition: Int, val methodSignature: String, val active: Boolean, val productName: String, val subProductName: String, val className: String, val methodName: String, val documentation: Option[String] = None) extends TestDefinitionRowLike - case class TestDefinitionRow(override val idTestDefinition: Int, override val methodSignature: String, override val active: Boolean, override val productName: String, override val subProductName: String, override val className: String, override val methodName: String, override val documentation: Option[String] = None) extends TestDefinitionRowWrapper(idTestDefinition, methodSignature, active, productName, subProductName, className, methodName, documentation) - implicit def TestDefinitionRowWrapper2TestDefinitionRow(x: TestDefinitionRowWrapper): TestDefinitionRow = TestDefinitionRow(x.idTestDefinition, x.methodSignature, x.active, x.productName, x.subProductName, x.className, x.methodName, x.documentation) - implicit def TestDefinitionRow2TestDefinitionRowWrapper(x: TestDefinitionRow): TestDefinitionRowWrapper = new TestDefinitionRowWrapper(x.idTestDefinition, x.methodSignature, x.active, x.productName, x.subProductName, x.className, x.methodName, x.documentation) - implicit def TestDefinitionRowFromTypeClass[T: TestDefinitionRowLikeType](x: T): TestDefinitionRow = TestDefinitionRow(implicitly[TestDefinitionRowLikeType[T]].idTestDefinition(x), implicitly[TestDefinitionRowLikeType[T]].methodSignature(x), implicitly[TestDefinitionRowLikeType[T]].active(x), implicitly[TestDefinitionRowLikeType[T]].productName(x), implicitly[TestDefinitionRowLikeType[T]].subProductName(x), implicitly[TestDefinitionRowLikeType[T]].className(x), implicitly[TestDefinitionRowLikeType[T]].methodName(x), implicitly[TestDefinitionRowLikeType[T]].documentation(x)) + class TestDefinitionRowWrapper(val idTestDefinition: Int, val methodSignature: String, val documentation: Option[String] = None) extends TestDefinitionRowLike + case class TestDefinitionRow(override val idTestDefinition: Int, override val methodSignature: String, override val documentation: Option[String] = None) extends TestDefinitionRowWrapper(idTestDefinition, methodSignature, documentation) + implicit def TestDefinitionRowWrapper2TestDefinitionRow(x: TestDefinitionRowWrapper): TestDefinitionRow = TestDefinitionRow(x.idTestDefinition, x.methodSignature, x.documentation) + implicit def TestDefinitionRow2TestDefinitionRowWrapper(x: TestDefinitionRow): TestDefinitionRowWrapper = new TestDefinitionRowWrapper(x.idTestDefinition, x.methodSignature, x.documentation) + implicit def TestDefinitionRowFromTypeClass[T: TestDefinitionRowLikeType](x: T): TestDefinitionRow = TestDefinitionRow(implicitly[TestDefinitionRowLikeType[T]].idTestDefinition(x), implicitly[TestDefinitionRowLikeType[T]].methodSignature(x), implicitly[TestDefinitionRowLikeType[T]].documentation(x)) /** GetResult implicit for fetching TestDefinitionRow objects using plain SQL queries */ - implicit def GetResultTestDefinitionRow(implicit e0: GR[Int], e1: GR[String], e2: GR[Boolean], e3: GR[Option[String]]): GR[TestDefinitionRow] = GR{ + implicit def GetResultTestDefinitionRow(implicit e0: GR[Int], e1: GR[String], e2: GR[Option[String]]): GR[TestDefinitionRow] = GR{ prs => import prs._ - TestDefinitionRow.tupled((<<[Int], <<[String], <<[Boolean], <<[String], <<[String], <<[String], <<[String], <(TestDefinitionRow.tupled, TestDefinitionRow.unapply) + def * = (idTestDefinition, methodSignature, documentation).<>(TestDefinitionRow.tupled, TestDefinitionRow.unapply) /** Maps whole row to an option. Useful for outer joins. */ - def ? = ((Rep.Some(idTestDefinition), Rep.Some(methodSignature), Rep.Some(active), Rep.Some(productName), Rep.Some(subProductName), Rep.Some(className), Rep.Some(methodName), documentation)).shaped.<>({r=>import r._; _1.map(_=> TestDefinitionRow.tupled((_1.get, _2.get, _3.get, _4.get, _5.get, _6.get, _7.get, _8)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) + def ? = ((Rep.Some(idTestDefinition), Rep.Some(methodSignature), documentation)).shaped.<>({r=>import r._; _1.map(_=> TestDefinitionRow.tupled((_1.get, _2.get, _3)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) /** Database column idTestDefinition SqlType(INT), AutoInc, PrimaryKey */ val idTestDefinition: Rep[Int] = column[Int]("idTestDefinition", O.AutoInc, O.PrimaryKey) /** Database column methodSignature SqlType(VARCHAR), Length(255,true) */ val methodSignature: Rep[String] = column[String]("methodSignature", O.Length(255,varying=true)) - /** Database column active SqlType(BIT) */ - val active: Rep[Boolean] = column[Boolean]("active") - /** Database column productName SqlType(VARCHAR), Length(255,true) */ - val productName: Rep[String] = column[String]("productName", O.Length(255,varying=true)) - /** Database column subProductName SqlType(VARCHAR), Length(255,true) */ - val subProductName: Rep[String] = column[String]("subProductName", O.Length(255,varying=true)) - /** Database column className SqlType(VARCHAR), Length(255,true) */ - val className: Rep[String] = column[String]("className", O.Length(255,varying=true)) - /** Database column methodName SqlType(VARCHAR), Length(255,true) */ - val methodName: Rep[String] = column[String]("methodName", O.Length(255,varying=true)) /** Database column documentation SqlType(TEXT), Default(None) */ val documentation: Rep[Option[String]] = column[Option[String]]("documentation", O.Default(None)) /** Uniqueness Index over (methodSignature) (database name methodSignature) */ val index1 = index("methodSignature", methodSignature, unique=true) - /** Index over (productName,subProductName,className,methodName) (database name reportingDescription) */ - val index2 = index("reportingDescription", (productName, subProductName, className, methodName)) } /** Collection-like TableQuery object for table TestDefinition */ lazy val TestDefinition = new TableQuery(tag => new TestDefinition(tag)) diff --git a/warp-core/src/generated/scala/com/workday/warp/persistence/model/TablesLike.scala b/warp-core/src/generated/scala/com/workday/warp/persistence/model/TablesLike.scala index eb2527ef..b5e93890 100644 --- a/warp-core/src/generated/scala/com/workday/warp/persistence/model/TablesLike.scala +++ b/warp-core/src/generated/scala/com/workday/warp/persistence/model/TablesLike.scala @@ -5,7 +5,7 @@ import slick.lifted.Rep import annotation.implicitNotFound trait TablesLike { - val CORE_TABLES: Map[String, String] = Map(("BuildRow","BuildRowWrapper(idBuild,major,minor,patch,firstTested,lastTested)"),("MeasurementRow","MeasurementRowWrapper(idTestExecution,idMeasurementName,result)"),("MeasurementNameRow","MeasurementNameRowWrapper(idMeasurementName,name)"),("SpikeFilterSettingsRow","SpikeFilterSettingsRowWrapper(idTestDefinition,spikeFilterEnabled,responseTimeRequirement,alertOnNth)"),("TagNameRow","TagNameRowWrapper(idTagName,name,nameType,isUserGenerated)"),("TestDefinitionRow","TestDefinitionRowWrapper(idTestDefinition,methodSignature,active,productName,subProductName,className,methodName,documentation)"),("TestDefinitionMetaTagRow","TestDefinitionMetaTagRowWrapper(idTestDefinitionTag,idTagName,value)"),("TestDefinitionTagRow","TestDefinitionTagRowWrapper(idTestDefinitionTag,idTestDefinition,idTagName,value)"),("TestExecutionRow","TestExecutionRowWrapper(idTestExecution,idTestDefinition,idBuild,passed,responseTime,responseTimeRequirement,startTime,endTime)"),("TestExecutionMetaTagRow","TestExecutionMetaTagRowWrapper(idTestExecutionTag,idTagName,value)"),("TestExecutionTagRow","TestExecutionTagRowWrapper(idTestExecutionTag,idTestExecution,idTagName,value)")) + val CORE_TABLES: Map[String, String] = Map(("BuildRow","BuildRowWrapper(idBuild,major,minor,patch,firstTested,lastTested)"),("MeasurementRow","MeasurementRowWrapper(idTestExecution,idMeasurementName,result)"),("MeasurementNameRow","MeasurementNameRowWrapper(idMeasurementName,name)"),("SpikeFilterSettingsRow","SpikeFilterSettingsRowWrapper(idTestDefinition,spikeFilterEnabled,responseTimeRequirement,alertOnNth)"),("TagNameRow","TagNameRowWrapper(idTagName,name,nameType,isUserGenerated)"),("TestDefinitionRow","TestDefinitionRowWrapper(idTestDefinition,methodSignature,documentation)"),("TestDefinitionMetaTagRow","TestDefinitionMetaTagRowWrapper(idTestDefinitionTag,idTagName,value)"),("TestDefinitionTagRow","TestDefinitionTagRowWrapper(idTestDefinitionTag,idTestDefinition,idTagName,value)"),("TestExecutionRow","TestExecutionRowWrapper(idTestExecution,idTestDefinition,idBuild,passed,responseTime,responseTimeRequirement,startTime,endTime)"),("TestExecutionMetaTagRow","TestExecutionMetaTagRowWrapper(idTestExecutionTag,idTagName,value)"),("TestExecutionTagRow","TestExecutionTagRowWrapper(idTestExecutionTag,idTestExecution,idTagName,value)")) /** Supertrait for entity classes storing rows of table BuildLike * * idBuild: Database column idBuild SqlType(INT), AutoInc, PrimaryKey @@ -146,20 +146,10 @@ trait TablesLike { * * idTestDefinition: Database column idTestDefinition SqlType(INT), AutoInc, PrimaryKey * methodSignature: Database column methodSignature SqlType(VARCHAR), Length(255,true) - * active: Database column active SqlType(BIT) - * productName: Database column productName SqlType(VARCHAR), Length(255,true) - * subProductName: Database column subProductName SqlType(VARCHAR), Length(255,true) - * className: Database column className SqlType(VARCHAR), Length(255,true) - * methodName: Database column methodName SqlType(VARCHAR), Length(255,true) * documentation: Database column documentation SqlType(TEXT), Default(None) */ trait TestDefinitionRowLike { val idTestDefinition: Int val methodSignature: String - val active: Boolean - val productName: String - val subProductName: String - val className: String - val methodName: String val documentation: Option[String] } /** Type Class for TestDefinitionRowLike **/ @@ -167,22 +157,12 @@ trait TablesLike { trait TestDefinitionRowLikeType[T] { def idTestDefinition(row: T): Int def methodSignature(row: T): String - def active(row: T): Boolean - def productName(row: T): String - def subProductName(row: T): String - def className(row: T): String - def methodName(row: T): String def documentation(row: T): Option[String] } /** Supertrait for Table descriptions of table TestDefinitionLike */ trait TestDefinitionLike { val idTestDefinition: Rep[Int] val methodSignature: Rep[String] - val active: Rep[Boolean] - val productName: Rep[String] - val subProductName: Rep[String] - val className: Rep[String] - val methodName: Rep[String] val documentation: Rep[Option[String]] } @@ -366,11 +346,6 @@ trait TablesLike { implicit object TestDefinitionRowLikeTypeClassObject extends TestDefinitionRowLikeType[TestDefinitionRowLike] { def idTestDefinition(row: TestDefinitionRowLike): Int = row.idTestDefinition def methodSignature(row: TestDefinitionRowLike): String = row.methodSignature - def active(row: TestDefinitionRowLike): Boolean = row.active - def productName(row: TestDefinitionRowLike): String = row.productName - def subProductName(row: TestDefinitionRowLike): String = row.subProductName - def className(row: TestDefinitionRowLike): String = row.className - def methodName(row: TestDefinitionRowLike): String = row.methodName def documentation(row: TestDefinitionRowLike): Option[String] = row.documentation } implicit object TestDefinitionMetaTagRowLikeTypeClassObject extends TestDefinitionMetaTagRowLikeType[TestDefinitionMetaTagRowLike] { diff --git a/warp-core/src/main/resources/db/migration/V4__Drop_Unhelpful_Columns.sql b/warp-core/src/main/resources/db/migration/V4__Drop_Unhelpful_Columns.sql new file mode 100644 index 00000000..6fd46fb2 --- /dev/null +++ b/warp-core/src/main/resources/db/migration/V4__Drop_Unhelpful_Columns.sql @@ -0,0 +1,6 @@ +DROP INDEX `reportingDescription` on TestDefinition; +ALTER TABLE TestDefinition DROP COLUMN `active`; +ALTER TABLE TestDefinition DROP COLUMN productName; +ALTER TABLE TestDefinition DROP COLUMN subProductName; +ALTER TABLE TestDefinition DROP COLUMN methodName; +ALTER TABLE TestDefinition DROP COLUMN className; diff --git a/warp-core/src/main/scala/com/workday/warp/persistence/CorePersistenceAware.scala b/warp-core/src/main/scala/com/workday/warp/persistence/CorePersistenceAware.scala index 39593926..371f6621 100644 --- a/warp-core/src/main/scala/com/workday/warp/persistence/CorePersistenceAware.scala +++ b/warp-core/src/main/scala/com/workday/warp/persistence/CorePersistenceAware.scala @@ -63,15 +63,9 @@ trait CorePersistenceAware extends PersistenceAware with WarpLogging { // make sure we have something that fits the schema column size val trimmedSignature: String = testId.id take CorePersistenceConstants.SIGNATURE_LENGTH val find: Query[TestDefinition, TestDefinitionRow, Seq] = TestDefinition filter { _.methodSignature === trimmedSignature } - val signature: MethodSignature = MethodSignature(trimmedSignature) val row: TestDefinitionRow = TestDefinitionRow( Tables.nullId, trimmedSignature, - active = true, - signature.product, - signature.subproduct, - signature.className, - signature.method, documentation ) val create: DBIO[TestDefinitionRowWrapper] = this.writeTestDefinitionQuery(row) diff --git a/warp-core/src/main/scala/com/workday/warp/persistence/MethodSignature.scala b/warp-core/src/main/scala/com/workday/warp/persistence/MethodSignature.scala deleted file mode 100644 index 37529d6c..00000000 --- a/warp-core/src/main/scala/com/workday/warp/persistence/MethodSignature.scala +++ /dev/null @@ -1,30 +0,0 @@ -package com.workday.warp.persistence - -/** - * Holds individual components of a method signature. - * - * Created by tomas.mccandless on 1/30/17. - */ -case class MethodSignature(product: String, subproduct: String, className: String, method: String) - - -object MethodSignature { - - /** - * Deconstructs `signature` into a [[MethodSignature]] of product, subproduct, class, and method. - * - * @param signature fully qualified method signature. - * @return a [[MethodSignature]] containing product, subproduct, class, method. - */ - @throws[RuntimeException]("when signature does not have at least 4 components") - def apply(signature: String): MethodSignature = { - // Break the fully qualified name of the test up into individual tokens that can be reported on. - val tokens: Array[String] = signature split "\\." - - if (tokens.length < 4) { - throw new RuntimeException(s"invalid warp test name: [${tokens mkString ", "}] (must have length >= 4)") - } - - tokens takeRight 4 match { case Array(product, subproduct, clazz, method) => MethodSignature(product, subproduct, clazz, method) } - } -} diff --git a/warp-core/src/test/scala/com/workday/warp/persistence/MethodSignatureSpec.scala b/warp-core/src/test/scala/com/workday/warp/persistence/MethodSignatureSpec.scala deleted file mode 100644 index 80895d0c..00000000 --- a/warp-core/src/test/scala/com/workday/warp/persistence/MethodSignatureSpec.scala +++ /dev/null @@ -1,24 +0,0 @@ -package com.workday.warp.persistence - -import com.workday.warp.junit.{UnitTest, WarpJUnitSpec} - -import scala.util.Try - -/** - * Created by tomas.mccandless on 1/30/17. - */ -class MethodSignatureSpec extends WarpJUnitSpec { - - private val signature: String = "com.workday.warp.product.subproduct.Class.method" - - /** Checks that we can deconstruct a fully qualified method signature. */ - @UnitTest - def methodSignature(): Unit = { - val expected: MethodSignature = MethodSignature("product", "subproduct", "Class", "method") - MethodSignature(this.signature) should be (expected) - MethodSignature(this.signature split "\\." drop 3 mkString ".") should be (expected) - - // we require at least 4 components - Try(MethodSignature("some.invalid.thing")) should die - } -}