Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ object AttributeCorrectionStatus extends Enumeration {

object EntityCorrectionStatus extends Enumeration {
type EntityCorrectionStatusType = Value
val CurrentGone, Correct, CorrectModified, Correctable, CorrectableModified, Corrected, Mixed, MixedModified,
Intersect, IntersectModified, Different, DifferentModified, NothingInCommon, NothingInCommonModified, NotAList,
NotAListModified, TypeDifferent, TypeDifferentModified = Value
val CurrentGone, Correct, CorrectModified, Correctable, CorrectableModified, Corrected, Mixed, MixedButNotCorrectable,
MixedModified, Intersect, IntersectModified, Different, DifferentModified, NothingInCommon, NothingInCommonModified,
NotAList, NotAListModified, TypeDifferent, TypeDifferentModified = Value
}

trait QuicksilverMigrationMonitorSupport extends LazyLogging {
Expand Down Expand Up @@ -134,10 +134,15 @@ trait QuicksilverMigrationMonitorSupport extends LazyLogging {
): EntityCorrectionStatusType = {
val attrStatuses = attributeStatuses.values.toSet

// when no attributes exist, use Correct; there is nothing that could be corrected
if (attrStatuses.isEmpty) {
EntityCorrectionStatus.Correct

// if any attribute was corrected, mark the entity as Corrected
} else if (attrStatuses.contains(AttributeCorrectionStatus.Corrected)) {
EntityCorrectionStatus.Corrected

// handle cases where all attributes have the same status
} else if (attrStatuses == Set(AttributeCorrectionStatus.Correct)) {
EntityCorrectionStatus.Correct
} else if (attrStatuses == Set(AttributeCorrectionStatus.Reordered)) {
Expand All @@ -154,8 +159,20 @@ trait QuicksilverMigrationMonitorSupport extends LazyLogging {
EntityCorrectionStatus.NotAList
} else if (attrStatuses == Set(AttributeCorrectionStatus.TypeDifferent)) {
EntityCorrectionStatus.TypeDifferent
} else {

// single-status sets were handled above. Now handle cases where attributes
// have multiple cases.
//
// if any attribute is correctable (e.g. "Reordered"), mark the entity as Mixed.
// Mixed entities will get processed by the correction monitor.
} else if (attrStatuses.contains(AttributeCorrectionStatus.Reordered)) {
EntityCorrectionStatus.Mixed

// We have multiple attribute statuses, but none of them is "Reordered".
// Mark the entity as MixedButNotCorrectable, which will not be processed by
// the correction monitor.
} else {
EntityCorrectionStatus.MixedButNotCorrectable
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,21 @@ class QuicksilverMigrationMonitorSupportSpec
}
}

it should s"return Mixed when attributes have multiple statuses" in {
it should s"return MixedButNotCorrectable when attributes have multiple statuses but none are Reordered" in {
val statusMap = Map(
AttributeName.withDefaultNS("foo") -> AttributeCorrectionStatus.Correct,
AttributeName.withLibraryNS("bar") -> AttributeCorrectionStatus.Different
)
val actual = calculateEntityStatus(statusMap)
actual shouldBe EntityCorrectionStatus.MixedButNotCorrectable
}

it should s"return Mixed when attributes have multiple statuses and some are Reordered" in {
val statusMap = Map(
AttributeName.withDefaultNS("foo") -> AttributeCorrectionStatus.Correct,
AttributeName.withLibraryNS("bar") -> AttributeCorrectionStatus.Reordered
)
val actual = calculateEntityStatus(statusMap)
actual shouldBe EntityCorrectionStatus.Mixed
}
}
Loading