Skip to content

Commit

Permalink
#1693 NamedLatestVersion generalized into a multipurpose `NamedVers…
Browse files Browse the repository at this point in the history
…ion`. Small updates, thanks @benedeki
  • Loading branch information
dk1844 committed May 9, 2022
1 parent eac77dd commit db1227b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

package za.co.absa.enceladus.model.versionedModel

case class NamedLatestVersion(name: String, version: Int)
case class NamedVersion(name: String, version: Int)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package za.co.absa.enceladus.model.versionedModel

case class VersionedSummary(_id: String, latestVersion: Int) {
def toNamedLatestVersion: NamedLatestVersion = NamedLatestVersion(_id, latestVersion)
def toNamedVersion: NamedVersion = NamedVersion(_id, latestVersion)
}


Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import scala.concurrent.Future
import scala.util.{Failure, Success, Try}

object VersionedModelControllerV3 {
val LatestVersionKey = "latest"
final val LatestVersionKey = "latest"
}

abstract class VersionedModelControllerV3[C <: VersionedModel with Product
Expand All @@ -51,16 +51,16 @@ abstract class VersionedModelControllerV3[C <: VersionedModel with Product
// todo maybe offset/limit?
@GetMapping(Array(""))
@ResponseStatus(HttpStatus.OK)
def getList(@RequestParam searchQuery: Optional[String]): CompletableFuture[Seq[NamedLatestVersion]] = {
def getList(@RequestParam searchQuery: Optional[String]): CompletableFuture[Seq[NamedVersion]] = {
versionedModelService.getLatestVersionsSummarySearch(searchQuery.toScalaOption)
.map(_.map(_.toNamedLatestVersion))
.map(_.map(_.toNamedVersion))
}

@GetMapping(Array("/{name}"))
@ResponseStatus(HttpStatus.OK)
def getVersionSummaryForEntity(@PathVariable name: String): CompletableFuture[NamedLatestVersion] = {
def getVersionSummaryForEntity(@PathVariable name: String): CompletableFuture[NamedVersion] = {
versionedModelService.getLatestVersionSummary(name) map {
case Some(entity) => entity.toNamedLatestVersion
case Some(entity) => entity.toNamedVersion
case None => throw notFound()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import za.co.absa.enceladus.model.dataFrameFilter._
import za.co.absa.enceladus.model.properties.essentiality.Essentiality
import za.co.absa.enceladus.model.properties.propertyType.EnumPropertyType
import za.co.absa.enceladus.model.test.factories.{DatasetFactory, MappingTableFactory, PropertyDefinitionFactory, SchemaFactory}
import za.co.absa.enceladus.model.versionedModel.NamedLatestVersion
import za.co.absa.enceladus.model.versionedModel.NamedVersion
import za.co.absa.enceladus.model.{Dataset, UsedIn, Validation}
import za.co.absa.enceladus.rest_api.exceptions.EntityDisabledException
import za.co.absa.enceladus.rest_api.integration.controllers.{BaseRestApiTestV3, toExpected}
Expand Down Expand Up @@ -136,9 +136,9 @@ class DatasetControllerV3IntegrationSuite extends BaseRestApiTestV3 with BeforeA
parent = Some(DatasetFactory.toParent(datasetV1)))
datasetFixture.add(datasetV1, datasetV2)

val response = sendGet[NamedLatestVersion](s"$apiUrl/datasetA")
val response = sendGet[NamedVersion](s"$apiUrl/datasetA")
assertOk(response)
assert(response.getBody == NamedLatestVersion("datasetA", 2))
assert(response.getBody == NamedVersion("datasetA", 2))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import za.co.absa.enceladus.model.menas.MenasReference
import za.co.absa.enceladus.model.properties.PropertyDefinition
import za.co.absa.enceladus.model.properties.propertyType.{EnumPropertyType, StringPropertyType}
import za.co.absa.enceladus.model.test.factories.{DatasetFactory, PropertyDefinitionFactory}
import za.co.absa.enceladus.model.versionedModel.NamedLatestVersion
import za.co.absa.enceladus.model.versionedModel.NamedVersion
import za.co.absa.enceladus.rest_api.integration.controllers.{BaseRestApiTestV3, toExpected}
import za.co.absa.enceladus.rest_api.integration.fixtures._
import za.co.absa.enceladus.rest_api.models.rest.DisabledPayload
Expand Down Expand Up @@ -142,9 +142,9 @@ class PropertyDefinitionControllerV3IntegrationSuite extends BaseRestApiTestV3 w
version = 2, parent = Some(PropertyDefinitionFactory.toParent(pdV1)))
propertyDefinitionFixture.add(pdV1, pdV2)

val response = sendGet[NamedLatestVersion](s"$apiUrl/pdA")
val response = sendGet[NamedVersion](s"$apiUrl/pdA")
assertOk(response)
assert(response.getBody == NamedLatestVersion("pdA", 2))
assert(response.getBody == NamedVersion("pdA", 2))
}
}

Expand Down

0 comments on commit db1227b

Please sign in to comment.