Skip to content

Commit

Permalink
#1693 VersionedSummaryV2 support fix - tests & impl
Browse files Browse the repository at this point in the history
  • Loading branch information
dk1844 committed May 17, 2022
1 parent 7e889e9 commit 1cb15ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

package za.co.absa.enceladus.model.test.factories

import java.time.ZonedDateTime
import za.co.absa.enceladus.model.Dataset
import za.co.absa.enceladus.model.conformanceRule._
import za.co.absa.enceladus.model.menas.MenasReference
import za.co.absa.enceladus.model.versionedModel.VersionedSummaryV2
import za.co.absa.enceladus.model.versionedModel.VersionedSummary

import java.time.ZonedDateTime

object DatasetFactory extends EntityFactory[Dataset] {

Expand Down Expand Up @@ -126,8 +127,8 @@ object DatasetFactory extends EntityFactory[Dataset] {
MenasReference(collection, name, version)
}

def toSummaryV2(dataset: Dataset): VersionedSummaryV2 = {
VersionedSummaryV2(dataset.name, dataset.version)
def toSummary(dataset: Dataset): VersionedSummary = {
VersionedSummary(dataset.name, dataset.version, Set(dataset.disabled))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ abstract class VersionedMongoRepository[C <: VersionedModel](mongoDb: MongoDatab
sort(Sorts.ascending("_id"))
)
collection.aggregate[VersionedSummaryV2](pipeline).toFuture()
.map(_.map(summaryV2 => VersionedSummary(summaryV2._id, summaryV2.latestVersion, Set(true)))) // because of the notDisabled filter
.map(_.map(summaryV2 => VersionedSummary(summaryV2._id, summaryV2.latestVersion, Set(false)))) // because of the notDisabled filter
}

def getLatestVersions(missingProperty: Option[String]): Future[Seq[C]] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers
datasetFixture.add(dataset2, dataset3, dataset4, dataset5)
val actual = await(datasetMongoRepository.getLatestVersionsSummarySearch(Some("dataset2")))

val expected = Seq(dataset3).map(DatasetFactory.toSummaryV2)
val expected = Seq(dataset3).map(DatasetFactory.toSummary)
assert(actual == expected)
}
"search query is a partial match" in {
Expand All @@ -512,7 +512,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers
datasetFixture.add(dataset2, dataset3, dataset4, dataset5)
val actual = await(datasetMongoRepository.getLatestVersionsSummarySearch(Some("tas")))

val expected = Seq(dataset3, dataset4).map(DatasetFactory.toSummaryV2)
val expected = Seq(dataset3, dataset4).map(DatasetFactory.toSummary)
assert(actual == expected)
}

Expand Down Expand Up @@ -548,7 +548,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers
datasetFixture.add(dataset1ver1, dataset1ver2, dataset2ver1, abc1)
val actual = await(datasetMongoRepository.getLatestVersionsSummarySearch(Some("")))

val expected = Seq(abc1, dataset1ver2, dataset2ver1).map(DatasetFactory.toSummaryV2)
val expected = Seq(abc1, dataset1ver2, dataset2ver1).map(DatasetFactory.toSummary)
assert(actual == expected)
}
}
Expand All @@ -565,7 +565,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers

val actual = await(datasetMongoRepository.getLatestVersionsSummarySearch(None))

val expected = Seq(dataset1ver2, dataset2ver2).map(DatasetFactory.toSummaryV2)
val expected = Seq(dataset1ver2, dataset2ver2).map(DatasetFactory.toSummary)
assert(actual == expected)
}
}
Expand Down

0 comments on commit 1cb15ce

Please sign in to comment.