Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs
===================================================================
diff -u -r73dab689d69a691763c42186ea4f3d89e2f8d5b4 -r3d7888387a3e55cf683d32526afd221980f64917
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs (.../MigrationTo181IntegrationTest.cs) (revision 73dab689d69a691763c42186ea4f3d89e2f8d5b4)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs (.../MigrationTo181IntegrationTest.cs) (revision 3d7888387a3e55cf683d32526afd221980f64917)
@@ -726,7 +726,7 @@
reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedDuneLocationCalculationOutputValidationQuery(NormativeNormType.SignalingNorm));
reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedDuneLocationCalculationOutputValidationQuery(NormativeNormType.LowerLimitNorm));
-
+
reader.AssertReturnedDataIsValid(DuneErosionFailureMechanismValidationQueryGenerator.GetNewDuneLocationCalculationOutputValidationQuery(
DuneErosionFailureMechanismValidationQueryGenerator.CalculationType.CalculationsForMechanismSpecificFactorizedSignalingNorm));
reader.AssertReturnedDataIsValid(DuneErosionFailureMechanismValidationQueryGenerator.GetNewDuneLocationCalculationOutputValidationQuery(
@@ -766,6 +766,196 @@
reader.AssertReturnedDataIsValid(validateMetaEntity);
}
+ #region Dune Locations
+
+ ///
+ /// Class to generate queries which can be used if the dune locations are correctly migrated.
+ ///
+ private class DuneErosionFailureMechanismValidationQueryGenerator
+ {
+ ///
+ /// Enum to indicate the hydraulic location calculation type.
+ ///
+ public enum CalculationType
+ {
+ ///
+ /// Represents the calculations for the mechanism specific factorized signaling norm.
+ ///
+ CalculationsForMechanismSpecificFactorizedSignalingNorm = 1,
+
+ ///
+ /// Represents the calculations for the mechanism specific signaling norm.
+ ///
+ CalculationsForMechanismSpecificSignalingNorm = 2,
+
+ ///
+ /// Represents the calculations for the mechanism specific lower limit norm.
+ ///
+ CalculationsForMechanismSpecificLowerLimitNorm = 3,
+
+ ///
+ /// Represents the calculations for the lower limit norm.
+ ///
+ CalculationsForLowerLimitNorm = 4,
+
+ ///
+ /// Represents the calculations for the factorized lower limit norm.
+ ///
+ CalculationsForLowerFactorizedLimitNorm = 5
+ }
+
+ private readonly string sourceFilePath;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The file path of the original database.
+ /// Thrown when
+ /// is null or empty.
+ public DuneErosionFailureMechanismValidationQueryGenerator(string sourceFilePath)
+ {
+ if (string.IsNullOrWhiteSpace(sourceFilePath))
+ {
+ throw new ArgumentException(@"Sourcefile path cannot be null or empty",
+ nameof(sourceFilePath));
+ }
+
+ this.sourceFilePath = sourceFilePath;
+ }
+
+ ///
+ /// Generates a query to validate the number of created dune location calculations per failure mechanism.
+ ///
+ /// The type of calculation that should be validated.
+ /// The query to validate the number of dune location calculations per calculation type.
+ public string GetDuneLocationCalculationsCountValidationQuery(CalculationType calculationType)
+ {
+ return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
+ "SELECT " +
+ "COUNT() = 0 " +
+ "FROM " +
+ "( " +
+ "SELECT " +
+ "[DuneErosionFailureMechanismMetaEntityId], " +
+ "COUNT() AS NewCount, " +
+ "OldCount " +
+ GetDuneLocationCalculationsQuery(calculationType) +
+ "LEFT JOIN " +
+ "( " +
+ "SELECT " +
+ "[DuneErosionFailureMechanismMetaEntityId], " +
+ "COUNT() as OldCount " +
+ "FROM [SourceProject].DuneErosionFailureMechanismMetaEntity " +
+ "JOIN [SourceProject].DuneLocationEntity USING(FailureMechanismEntityId) " +
+ "GROUP BY DuneErosionFailureMechanismMetaEntityId " +
+ ") USING(DuneErosionFailureMechanismMetaEntityId) " +
+ "GROUP BY DuneErosionFailureMechanismMetaEntityId " +
+ "UNION " +
+ "SELECT " +
+ "[DuneErosionFailureMechanismMetaEntityId], " +
+ "NewCount, " +
+ "COUNT() AS OldCount " +
+ "FROM [SourceProject].DuneErosionFailureMechanismMetaEntity " +
+ "JOIN [SourceProject].DuneLocationEntity USING(FailureMechanismEntityId) " +
+ "LEFT JOIN " +
+ "( " +
+ "SELECT " +
+ "[DuneErosionFailureMechanismMetaEntityId], " +
+ "COUNT() as NewCount " +
+ GetDuneLocationCalculationsQuery(calculationType) +
+ "GROUP BY DuneErosionFailureMechanismMetaEntityId " +
+ ") USING(DuneErosionFailureMechanismMetaEntityId) " +
+ "GROUP BY DuneErosionFailureMechanismMetaEntityId " +
+ ") " +
+ "WHERE NewCount IS NOT OldCount; " +
+ "DETACH DATABASE SOURCEPROJECT;";
+ }
+
+ ///
+ /// Generates a query to validate the new dune location outputs that are not based on migrated data.
+ ///
+ /// The type of calculation on which the output should be validated.
+ /// The query to validate the dune location output.
+ public static string GetNewDuneLocationCalculationOutputValidationQuery(CalculationType calculationType)
+ {
+ return "SELECT COUNT() = 0 " +
+ GetDuneLocationCalculationsQuery(calculationType) +
+ "JOIN DuneLocationCalculationOutputEntity USING(DuneLocationCalculationEntityId);";
+ }
+
+ ///
+ /// Generates a query to validate if the dune location outputs are migrated correctly to the
+ /// corresponding calculation entities.
+ ///
+ /// The norm type to generate the query for.
+ /// A query to validate the dune location outputs.
+ /// Thrown when
+ /// is an invalid value of .
+ /// Thrown when is an unsupported value,
+ /// but is unsupported.
+ public string GetMigratedDuneLocationCalculationOutputValidationQuery(NormativeNormType normType)
+ {
+ return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
+ "SELECT COUNT() = ( " +
+ "SELECT COUNT() " +
+ "FROM [SOURCEPROJECT].DuneLocationOutputEntity " +
+ "JOIN [SOURCEPROJECT].DuneLocationEntity USING(DuneLocationEntityId) " +
+ "JOIN [SOURCEPROJECT].FailureMechanismEntity USING(FailureMechanismEntityId) " +
+ "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING(AssessmentSectionEntityId) " +
+ $"WHERE NormativeNormType = {(int) normType} " +
+ ") " +
+ GetDuneLocationCalculationsQuery(ConvertToCalculationType(normType)) +
+ "JOIN DuneLocationCalculationOutputEntity NEW USING(DuneLocationCalculationEntityId) " +
+ "JOIN [SOURCEPROJECT].DuneLocationOutputEntity OLD ON OLD.DuneLocationOutputEntityId = NEW.DuneLocationCalculationOutputEntityId " +
+ "WHERE NEW.WaterLevel IS OLD.WaterLevel " +
+ "AND NEW.WaveHeight IS OLD.WaveHeight " +
+ "AND NEW.WavePeriod IS OLD.WavePeriod " +
+ "AND NEW.TargetProbability IS OLD.TargetProbability " +
+ "AND NEW.TargetReliability IS OLD.TargetReliability " +
+ "AND NEW.CalculatedProbability IS OLD.CalculatedProbability " +
+ "AND NEW.CalculatedReliability IS OLD.CalculatedReliability " +
+ "AND NEW.CalculationConvergence = OLD.CalculationConvergence; " +
+ "DETACH DATABASE SOURCEPROJECT;";
+ }
+
+ private static string GetDuneLocationCalculationsQuery(CalculationType calculationType)
+ {
+ return "FROM DuneErosionFailureMechanismMetaEntity fme " +
+ "JOIN DuneLocationCalculationCollectionEntity ON " +
+ $"DuneLocationCalculationCollectionEntityId = fme.DuneLocationCalculationCollectionEntity{(int) calculationType}Id " +
+ "JOIN DuneLocationCalculationEntity USING(DuneLocationCalculationCollectionEntityId) ";
+ }
+
+ ///
+ /// Converts the to the corresponding calculation from .
+ ///
+ /// The norm type to convert.
+ /// Returns the converted .
+ /// Thrown when
+ /// is an invalid value of .
+ /// Thrown when is a valid value,
+ /// but is unsupported.
+ private static CalculationType ConvertToCalculationType(NormativeNormType normType)
+ {
+ if (!Enum.IsDefined(typeof(NormativeNormType), normType))
+ {
+ throw new InvalidEnumArgumentException(nameof(normType), (int) normType, typeof(NormativeNormType));
+ }
+
+ switch (normType)
+ {
+ case NormativeNormType.LowerLimitNorm:
+ return CalculationType.CalculationsForMechanismSpecificLowerLimitNorm;
+ case NormativeNormType.SignalingNorm:
+ return CalculationType.CalculationsForMechanismSpecificSignalingNorm;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ }
+
+ #endregion
+
#region Failure Mechanism Section Result Entities
private static void AssertHeightStructuresSectionResultEntity(MigratedDatabaseReader reader, string sourceFilePath)
@@ -1916,180 +2106,6 @@
#endregion
- #region Dune Locations
-
- ///
- /// Class to generate queries which can be used if the dune locations are correctly migrated.
- ///
- private class DuneErosionFailureMechanismValidationQueryGenerator
- {
- ///
- /// Enum to indicate the hydraulic location calculation type.
- ///
- public enum CalculationType
- {
- ///
- /// Represents the calculations for the mechanism specific factorized signaling norm.
- ///
- CalculationsForMechanismSpecificFactorizedSignalingNorm = 1,
-
- ///
- /// Represents the calculations for the mechanism specific signaling norm.
- ///
- CalculationsForMechanismSpecificSignalingNorm = 2,
-
- ///
- /// Represents the calculations for the mechanism specific lower limit norm.
- ///
- CalculationsForMechanismSpecificLowerLimitNorm = 3,
-
- ///
- /// Represents the calculations for the lower limit norm.
- ///
- CalculationsForLowerLimitNorm = 4,
-
- ///
- /// Represents the calculations for the factorized lower limit norm.
- ///
- CalculationsForLowerFactorizedLimitNorm = 5
- }
-
- private readonly string sourceFilePath;
-
- ///
- /// Creates a new instance of .
- ///
- /// The file path of the original database.
- /// Thrown when
- /// is null or empty.
- public DuneErosionFailureMechanismValidationQueryGenerator(string sourceFilePath)
- {
- if (string.IsNullOrWhiteSpace(sourceFilePath))
- {
- throw new ArgumentException(@"Sourcefile path cannot be null or empty",
- nameof(sourceFilePath));
- }
-
- this.sourceFilePath = sourceFilePath;
- }
-
- ///
- /// Generates a query to validate the number of created dune location calculations per failure mechanism.
- ///
- /// The type of calculation that should be validated.
- /// The query to validate the number of dune location calculations per calculation type.
- public string GetDuneLocationCalculationsCountValidationQuery(CalculationType calculationType)
- {
- return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
- "SELECT " +
- "COUNT() = 0 " +
- "FROM " +
- "( " +
- "SELECT " +
- "[DuneErosionFailureMechanismMetaEntityId], " +
- "COUNT() as NewCount, " +
- "OldCount " +
- GetDuneLocationCalculationsQuery(calculationType) +
- "LEFT JOIN " +
- "( " +
- "SELECT " +
- "[DuneErosionFailureMechanismMetaEntityId], " +
- "COUNT() as OldCount " +
- "FROM [SourceProject].DuneErosionFailureMechanismMetaEntity " +
- "JOIN [SourceProject].DuneLocationEntity USING(FailureMechanismEntityId) " +
- "GROUP BY DuneErosionFailureMechanismMetaEntityId " +
- ") USING(DuneErosionFailureMechanismMetaEntityId) " +
- "GROUP BY DuneErosionFailureMechanismMetaEntityId " +
- ") " +
- "WHERE OldCount IS NOT NewCount; " +
- "DETACH DATABASE SOURCEPROJECT;";
- }
-
- ///
- /// Generates a query to validate the new dune location outputs that are not based on migrated data.
- ///
- /// The type of calculation on which the output should be validated.
- /// The query to validate the dune location output.
- public static string GetNewDuneLocationCalculationOutputValidationQuery(CalculationType calculationType)
- {
- return "SELECT COUNT() = 0 " +
- GetDuneLocationCalculationsQuery(calculationType) +
- "JOIN DuneLocationCalculationOutputEntity USING(DuneLocationCalculationEntityId);";
- }
-
- ///
- /// Generates a query to validate if the dune location outputs are migrated correctly to the
- /// corresponding calculation entities.
- ///
- /// The norm type to generate the query for.
- /// A query to validate the dune location outputs.
- /// Thrown when
- /// is an invalid value of .
- /// Thrown when is an unsupported value,
- /// but is unsupported.
- public string GetMigratedDuneLocationCalculationOutputValidationQuery(NormativeNormType normType)
- {
- return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
- "SELECT COUNT() = ( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].DuneLocationOutputEntity " +
- "JOIN [SOURCEPROJECT].DuneLocationEntity USING(DuneLocationEntityId) " +
- "JOIN [SOURCEPROJECT].FailureMechanismEntity USING(FailureMechanismEntityId) " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING(AssessmentSectionEntityId) " +
- $"WHERE NormativeNormType = {(int)normType} " +
- ") " +
- GetDuneLocationCalculationsQuery(ConvertToCalculationType(normType)) +
- "JOIN DuneLocationCalculationOutputEntity NEW USING(DuneLocationCalculationEntityId) " +
- "JOIN [SOURCEPROJECT].DuneLocationOutputEntity OLD ON OLD.DuneLocationOutputEntityId = NEW.DuneLocationCalculationOutputEntityId " +
- "WHERE NEW.WaterLevel IS OLD.WaterLevel " +
- "AND NEW.WaveHeight IS OLD.WaveHeight " +
- "AND NEW.WavePeriod IS OLD.WavePeriod " +
- "AND NEW.TargetProbability IS OLD.TargetProbability " +
- "AND NEW.TargetReliability IS OLD.TargetReliability " +
- "AND NEW.CalculatedProbability IS OLD.CalculatedProbability " +
- "AND NEW.CalculatedReliability IS OLD.CalculatedReliability " +
- "AND NEW.CalculationConvergence = OLD.CalculationConvergence; " +
- "DETACH DATABASE SOURCEPROJECT;";
- }
-
- private static string GetDuneLocationCalculationsQuery(CalculationType calculationType)
- {
- return "FROM DuneErosionFailureMechanismMetaEntity fme " +
- "JOIN DuneLocationCalculationCollectionEntity ON " +
- $"DuneLocationCalculationCollectionEntityId = fme.DuneLocationCalculationCollectionEntity{(int) calculationType}Id " +
- "JOIN DuneLocationCalculationEntity USING(DuneLocationCalculationCollectionEntityId) ";
- }
-
- ///
- /// Converts the to the corresponding calculation from .
- ///
- /// The norm type to convert.
- /// Returns the converted .
- /// Thrown when
- /// is an invalid value of .
- /// Thrown when is a valid value,
- /// but is unsupported.
- private static CalculationType ConvertToCalculationType(NormativeNormType normType)
- {
- if (!Enum.IsDefined(typeof(NormativeNormType), normType))
- {
- throw new InvalidEnumArgumentException(nameof(normType), (int)normType, typeof(NormativeNormType));
- }
-
- switch (normType)
- {
- case NormativeNormType.LowerLimitNorm:
- return CalculationType.CalculationsForMechanismSpecificLowerLimitNorm;
- case NormativeNormType.SignalingNorm:
- return CalculationType.CalculationsForMechanismSpecificSignalingNorm;
- default:
- throw new NotSupportedException();
- }
- }
- }
-
- #endregion
-
#region Migrated Wave Condition Calculations
private static void AssertWaveConditionsCalculations(MigratedDatabaseReader reader, string sourceFilePath)