Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs
===================================================================
diff -u -rfbe227cf3a6743302f63c1bd3281feda0273192c -r258a217558998746b487965a9c75b1e71b1283aa
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs (.../MigrationTo181IntegrationTest.cs) (revision fbe227cf3a6743302f63c1bd3281feda0273192c)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs (.../MigrationTo181IntegrationTest.cs) (revision 258a217558998746b487965a9c75b1e71b1283aa)
@@ -357,23 +357,6 @@
"DETACH DATABASE SOURCEPROJECT;";
reader.AssertReturnedDataIsValid(validateNrOfHydraulicBoundaryCalculationOutputEntities);
- AssertMigratedHydraulicLocationCalculations(reader, sourceFilePath);
- }
-
- private static void AssertNewHydraulicLocationCalculations(MigratedDatabaseReader reader, string sourceFilePath, int entityCalculationNumber)
- {
- string validateNewHydraulicCalculations =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
- "SELECT COUNT() = (SELECT COUNT() FROM [SOURCEPROJECT].HydraulicLocationEntity) " +
- "FROM HydraulicLocationEntity AS NEW " +
- $"JOIN HydraulicLocationCalculationEntity hlce ON NEW.HydraulicLocationCalculationEntity{entityCalculationNumber}Id = hlce.HydraulicLocationCalculationEntityId " +
- "WHERE hlce.ShouldIllustrationPointsBeCalculated = 0;" +
- "DETACH DATABASE SOURCEPROJECT;";
- reader.AssertReturnedDataIsValid(validateNewHydraulicCalculations);
- }
-
- private static void AssertMigratedHydraulicLocationCalculations(MigratedDatabaseReader reader, string sourceFilePath)
- {
AssertDesignWaterLevelCalculations(reader, sourceFilePath);
AssertWaveHeightCalculations(reader, sourceFilePath);
@@ -394,154 +377,227 @@
reader.AssertReturnedDataIsValid(validateOutputNewCalculations);
string validateDesignWaterLevelCalculationsWithSignalingNormOutput =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT;" +
- "SELECT COUNT() = " +
- "( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].HydraulicLocationOutputEntity " +
- "JOIN [SOURCEPROJECT].HydraulicLocationEntity USING (HydraulicLocationEntityId) " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE NormativeNormType = 2 AND HydraulicLocationOutputType = 1 " +
- ") " +
- "FROM HydraulicLocationEntity NEWHL " +
- "JOIN HydraulicLocationCalculationEntity calc ON calc.HydraulicLocationCalculationEntityId = NEWHL.HydraulicLocationCalculationEntity2Id " +
- "JOIN HydraulicLocationOutputEntity NEW USING(HydraulicLocationCalculationEntityId) " +
- "JOIN [SOURCEPROJECT].HydraulicLocationOutputEntity OLD ON NEW.HydraulicLocationOutputEntityId = OLD.HydraulicLocationEntityOutputId " +
- "WHERE OLD.HydraulicLocationEntityId = NEWHL.HydraulicLocationEntityId;" +
- "DETACH DATABASE SOURCEPROJECT;";
+ HydraulicLocationValidationQueryGenerator.GetOutputValidationQuery(
+ sourceFilePath,
+ HydraulicLocationValidationQueryGenerator.NormativeNormType.SignalingNorm,
+ HydraulicLocationValidationQueryGenerator.HydraulicLocationOutputType.DesignWaterLevel,
+ 2);
reader.AssertReturnedDataIsValid(validateDesignWaterLevelCalculationsWithSignalingNormOutput);
string validateDesignWaterLevelCalculationsWithLowerLimitNormOutput =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT;" +
- "SELECT COUNT() = " +
- "( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].HydraulicLocationOutputEntity " +
- "JOIN [SOURCEPROJECT].HydraulicLocationEntity USING (HydraulicLocationEntityId) " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE NormativeNormType = 1 AND HydraulicLocationOutputType = 1 " +
- ") " +
- "FROM HydraulicLocationEntity NEWHL " +
- "JOIN HydraulicLocationCalculationEntity calc ON calc.HydraulicLocationCalculationEntityId = NEWHL.HydraulicLocationCalculationEntity3Id " +
- "JOIN HydraulicLocationOutputEntity NEW USING(HydraulicLocationCalculationEntityId) " +
- "JOIN [SOURCEPROJECT].HydraulicLocationOutputEntity OLD ON NEW.HydraulicLocationOutputEntityId = OLD.HydraulicLocationEntityOutputId " +
- "WHERE OLD.HydraulicLocationEntityId = NEWHL.HydraulicLocationEntityId;" +
- "DETACH DATABASE SOURCEPROJECT;";
+ HydraulicLocationValidationQueryGenerator.GetOutputValidationQuery(
+ sourceFilePath,
+ HydraulicLocationValidationQueryGenerator.NormativeNormType.LowerLimitNorm,
+ HydraulicLocationValidationQueryGenerator.HydraulicLocationOutputType.DesignWaterLevel,
+ 3);
reader.AssertReturnedDataIsValid(validateDesignWaterLevelCalculationsWithLowerLimitNormOutput);
string validateWaveHeightCalculationsWithSignalingNormOutput =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT;" +
- "SELECT COUNT() = " +
- "( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].HydraulicLocationOutputEntity " +
- "JOIN [SOURCEPROJECT].HydraulicLocationEntity USING (HydraulicLocationEntityId) " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE NormativeNormType = 2 AND HydraulicLocationOutputType = 2 " +
- ") " +
- "FROM HydraulicLocationEntity NEWHL " +
- "JOIN HydraulicLocationCalculationEntity calc ON calc.HydraulicLocationCalculationEntityId = NEWHL.HydraulicLocationCalculationEntity6Id " +
- "JOIN HydraulicLocationOutputEntity NEW USING(HydraulicLocationCalculationEntityId) " +
- "JOIN [SOURCEPROJECT].HydraulicLocationOutputEntity OLD ON NEW.HydraulicLocationOutputEntityId = OLD.HydraulicLocationEntityOutputId " +
- "WHERE OLD.HydraulicLocationEntityId = NEWHL.HydraulicLocationEntityId;" +
- "DETACH DATABASE SOURCEPROJECT;";
+ HydraulicLocationValidationQueryGenerator.GetOutputValidationQuery(
+ sourceFilePath,
+ HydraulicLocationValidationQueryGenerator.NormativeNormType.SignalingNorm,
+ HydraulicLocationValidationQueryGenerator.HydraulicLocationOutputType.WaveHeight,
+ 6);
reader.AssertReturnedDataIsValid(validateWaveHeightCalculationsWithSignalingNormOutput);
string validateWaveHeightCalculationsWithLowerLimitNormOutput =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT;" +
- "SELECT COUNT() = " +
- "( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].HydraulicLocationOutputEntity " +
- "JOIN [SOURCEPROJECT].HydraulicLocationEntity USING (HydraulicLocationEntityId) " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE NormativeNormType = 1 AND HydraulicLocationOutputType = 2 " +
- ") " +
- "FROM HydraulicLocationEntity NEWHL " +
- "JOIN HydraulicLocationCalculationEntity calc ON calc.HydraulicLocationCalculationEntityId = NEWHL.HydraulicLocationCalculationEntity7Id " +
- "JOIN HydraulicLocationOutputEntity NEW USING(HydraulicLocationCalculationEntityId) " +
- "JOIN [SOURCEPROJECT].HydraulicLocationOutputEntity OLD ON NEW.HydraulicLocationOutputEntityId = OLD.HydraulicLocationEntityOutputId " +
- "WHERE OLD.HydraulicLocationEntityId = NEWHL.HydraulicLocationEntityId;" +
- "DETACH DATABASE SOURCEPROJECT;";
+ HydraulicLocationValidationQueryGenerator.GetOutputValidationQuery(
+ sourceFilePath,
+ HydraulicLocationValidationQueryGenerator.NormativeNormType.LowerLimitNorm,
+ HydraulicLocationValidationQueryGenerator.HydraulicLocationOutputType.WaveHeight,
+ 7);
reader.AssertReturnedDataIsValid(validateWaveHeightCalculationsWithLowerLimitNormOutput);
}
private static void AssertDesignWaterLevelCalculations(MigratedDatabaseReader reader, string sourceFilePath)
{
- AssertNewHydraulicLocationCalculations(reader, sourceFilePath, 1);
+ string validateCalculation1Entities =
+ HydraulicLocationValidationQueryGenerator.GetNewCalculationsValidationQuery(sourceFilePath, 1);
+ reader.AssertReturnedDataIsValid(validateCalculation1Entities);
+
string validateDesignWaterLevelCalculationsWithSignalingNorm =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
- "SELECT COUNT() = " +
- "( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].HydraulicLocationEntity " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE NormativeNormType = 2 " +
- ") " +
- "FROM HydraulicLocationEntity AS NEW " +
- "JOIN [SOURCEPROJECT].HydraulicLocationEntity AS OLD ON OLD.HydraulicLocationEntityId = NEW.HydraulicLocationEntityId " +
- "JOIN HydraulicLocationCalculationEntity hlce ON NEW.HydraulicLocationCalculationEntity2Id = hlce.HydraulicLocationCalculationEntityId " +
- "JOIN AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE hlce.ShouldIllustrationPointsBeCalculated = OLD.ShouldDesignWaterLevelIllustrationPointsBeCalculated AND NormativeNormType = 2;" +
- "DETACH DATABASE SOURCEPROJECT;";
+ HydraulicLocationValidationQueryGenerator.GetDesignWaterLevelCalculationValidationQuery(
+ sourceFilePath,
+ HydraulicLocationValidationQueryGenerator.NormativeNormType.SignalingNorm,
+ 2);
reader.AssertReturnedDataIsValid(validateDesignWaterLevelCalculationsWithSignalingNorm);
string validateDesignWaterLevelCalculationsWithLowerLimitNorm =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
- "SELECT COUNT() = " +
- "( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].HydraulicLocationEntity " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE NormativeNormType = 1 " +
- ") " +
- "FROM HydraulicLocationEntity AS NEW " +
- "JOIN [SOURCEPROJECT].HydraulicLocationEntity AS OLD ON OLD.HydraulicLocationEntityId = NEW.HydraulicLocationEntityId " +
- "JOIN HydraulicLocationCalculationEntity hlce ON NEW.HydraulicLocationCalculationEntity3Id = hlce.HydraulicLocationCalculationEntityId " +
- "JOIN AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE hlce.ShouldIllustrationPointsBeCalculated = OLD.ShouldWaveHeightIllustrationPointsBeCalculated AND NormativeNormType = 1;" +
- "DETACH DATABASE SOURCEPROJECT;";
+ HydraulicLocationValidationQueryGenerator.GetDesignWaterLevelCalculationValidationQuery(
+ sourceFilePath,
+ HydraulicLocationValidationQueryGenerator.NormativeNormType.LowerLimitNorm,
+ 3);
reader.AssertReturnedDataIsValid(validateDesignWaterLevelCalculationsWithLowerLimitNorm);
- AssertNewHydraulicLocationCalculations(reader, sourceFilePath, 4);
+
+ string validateCalculation4Entities =
+ HydraulicLocationValidationQueryGenerator.GetNewCalculationsValidationQuery(sourceFilePath, 4);
+ reader.AssertReturnedDataIsValid(validateCalculation4Entities);
}
private static void AssertWaveHeightCalculations(MigratedDatabaseReader reader, string sourceFilePath)
{
- AssertNewHydraulicLocationCalculations(reader, sourceFilePath, 5);
+ string validateCalculation5Entities =
+ HydraulicLocationValidationQueryGenerator.GetNewCalculationsValidationQuery(sourceFilePath, 5);
+
+ reader.AssertReturnedDataIsValid(validateCalculation5Entities);
string validateWaveHeightCalculationsWithSignalingNorm =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
- "SELECT COUNT() = " +
- "( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].HydraulicLocationEntity " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE NormativeNormType = 2 " +
- ") " +
- "FROM HydraulicLocationEntity AS NEW " +
- "JOIN [SOURCEPROJECT].HydraulicLocationEntity AS OLD ON OLD.HydraulicLocationEntityId = NEW.HydraulicLocationEntityId " +
- "JOIN HydraulicLocationCalculationEntity hlce ON NEW.HydraulicLocationCalculationEntity6Id = hlce.HydraulicLocationCalculationEntityId " +
- "JOIN AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE hlce.ShouldIllustrationPointsBeCalculated = OLD.ShouldWaveHeightIllustrationPointsBeCalculated AND NormativeNormType = 2;" +
- "DETACH DATABASE SOURCEPROJECT;";
+ HydraulicLocationValidationQueryGenerator.GetWaveHeightCalculationValidationQuery(
+ sourceFilePath,
+ HydraulicLocationValidationQueryGenerator.NormativeNormType.SignalingNorm,
+ 6);
reader.AssertReturnedDataIsValid(validateWaveHeightCalculationsWithSignalingNorm);
string validateWaveHeightCalculationsWithLowerLimitNorm =
- $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
- "SELECT COUNT() = " +
- "( " +
- "SELECT COUNT() " +
- "FROM [SOURCEPROJECT].HydraulicLocationEntity " +
- "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE NormativeNormType = 1 " +
- ") " +
- "FROM HydraulicLocationEntity AS NEW " +
- "JOIN [SOURCEPROJECT].HydraulicLocationEntity AS OLD ON OLD.HydraulicLocationEntityId = NEW.HydraulicLocationEntityId " +
- "JOIN HydraulicLocationCalculationEntity hlce ON NEW.HydraulicLocationCalculationEntity7Id = hlce.HydraulicLocationCalculationEntityId " +
- "JOIN AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
- "WHERE hlce.ShouldIllustrationPointsBeCalculated = OLD.ShouldDesignWaterLevelIllustrationPointsBeCalculated AND NormativeNormType = 1;" +
- "DETACH DATABASE SOURCEPROJECT;";
+ HydraulicLocationValidationQueryGenerator.GetWaveHeightCalculationValidationQuery(
+ sourceFilePath,
+ HydraulicLocationValidationQueryGenerator.NormativeNormType.LowerLimitNorm,
+ 7);
reader.AssertReturnedDataIsValid(validateWaveHeightCalculationsWithLowerLimitNorm);
- AssertNewHydraulicLocationCalculations(reader, sourceFilePath, 8);
+
+ string validateCalculation8Entities =
+ HydraulicLocationValidationQueryGenerator.GetNewCalculationsValidationQuery(sourceFilePath, 8);
+ reader.AssertReturnedDataIsValid(validateCalculation8Entities);
}
+ ///
+ /// Class to generate queries which can be used if the hydraulic boundary locations
+ /// are correctly migrated.
+ ///
+ private static class HydraulicLocationValidationQueryGenerator
+ {
+ ///
+ /// Enum to indicate the hydraulic location output types.
+ ///
+ public enum HydraulicLocationOutputType
+ {
+ ///
+ /// Represents an output for a design water level
+ /// calculation.
+ ///
+ DesignWaterLevel = 1,
+
+ ///
+ /// Represents an output for a wave height calculation.
+ ///
+ WaveHeight = 2
+ }
+
+ ///
+ /// Enum to indicate the norm which was used.
+ ///
+ public enum NormativeNormType
+ {
+ ///
+ /// Represents the lower limit norm.
+ ///
+ LowerLimitNorm = 1,
+
+ ///
+ /// Represents the signaling norm.
+ ///
+ SignalingNorm = 2
+ }
+
+ ///
+ /// Generates a query to validate the migrated hydraulic boundary location output.
+ ///
+ /// The file path of the database to be verified.
+ /// The on which the output was calculated for.
+ /// The which the output represents.
+ /// The calculation on which the outputs should be set.
+ /// The query to validate the migrated hydraulic boundary location output.
+ public static string GetOutputValidationQuery(string sourceFilePath,
+ NormativeNormType normType,
+ HydraulicLocationOutputType outputType,
+ int calculationEntityNumber)
+ {
+ return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT;" +
+ "SELECT COUNT() = " +
+ "( " +
+ "SELECT COUNT() " +
+ "FROM [SOURCEPROJECT].HydraulicLocationOutputEntity " +
+ "JOIN [SOURCEPROJECT].HydraulicLocationEntity USING (HydraulicLocationEntityId) " +
+ "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
+ $"WHERE NormativeNormType = {(int) normType} AND HydraulicLocationOutputType = {(int) outputType} " +
+ ") " +
+ "FROM HydraulicLocationEntity NEWHL " +
+ $"JOIN HydraulicLocationCalculationEntity calc ON calc.HydraulicLocationCalculationEntityId = NEWHL.HydraulicLocationCalculationEntity{calculationEntityNumber}Id " +
+ "JOIN HydraulicLocationOutputEntity NEW USING(HydraulicLocationCalculationEntityId) " +
+ "JOIN [SOURCEPROJECT].HydraulicLocationOutputEntity OLD ON NEW.HydraulicLocationOutputEntityId = OLD.HydraulicLocationEntityOutputId " +
+ "WHERE OLD.HydraulicLocationEntityId = NEWHL.HydraulicLocationEntityId;" +
+ "DETACH DATABASE SOURCEPROJECT;";
+ }
+
+ ///
+ /// Generates a query to validate the migrated wave height calculations.
+ ///
+ /// The file path of the database to be verified.
+ /// The for which the input was set.
+ /// The calculation on which the input should be validated.
+ /// The query to validate the migrated hydraulic boundary location calculation input.
+ public static string GetWaveHeightCalculationValidationQuery(string sourceFilePath,
+ NormativeNormType normType,
+ int calculationEntityNumber)
+ {
+ return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
+ "SELECT COUNT() = " +
+ "( " +
+ "SELECT COUNT() " +
+ "FROM [SOURCEPROJECT].HydraulicLocationEntity " +
+ "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
+ $"WHERE NormativeNormType = {(int) normType} " +
+ ") " +
+ "FROM HydraulicLocationEntity AS NEW " +
+ "JOIN [SOURCEPROJECT].HydraulicLocationEntity AS OLD ON OLD.HydraulicLocationEntityId = NEW.HydraulicLocationEntityId " +
+ $"JOIN HydraulicLocationCalculationEntity hlce ON NEW.HydraulicLocationCalculationEntity{calculationEntityNumber}Id = hlce.HydraulicLocationCalculationEntityId " +
+ "JOIN AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
+ $"WHERE hlce.ShouldIllustrationPointsBeCalculated = OLD.ShouldWaveHeightIllustrationPointsBeCalculated AND NormativeNormType = {(int) normType};" +
+ "DETACH DATABASE SOURCEPROJECT;";
+ }
+
+ ///
+ /// Generates a query to validate the migrated design water level calculations.
+ ///
+ /// The file path of the database to be verified.
+ /// The for which the input was set.
+ /// The calculation on which the input should be validated.
+ /// The query to validate the migrated hydraulic boundary location calculation input.
+ public static string GetDesignWaterLevelCalculationValidationQuery(string sourceFilePath,
+ NormativeNormType normType,
+ int calculationEntityNumber)
+ {
+ return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
+ "SELECT COUNT() = " +
+ "( " +
+ "SELECT COUNT() " +
+ "FROM [SOURCEPROJECT].HydraulicLocationEntity " +
+ "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
+ $"WHERE NormativeNormType = {(int) normType} " +
+ ") " +
+ "FROM HydraulicLocationEntity AS NEW " +
+ "JOIN [SOURCEPROJECT].HydraulicLocationEntity AS OLD ON OLD.HydraulicLocationEntityId = NEW.HydraulicLocationEntityId " +
+ $"JOIN HydraulicLocationCalculationEntity hlce ON NEW.HydraulicLocationCalculationEntity{calculationEntityNumber}Id = hlce.HydraulicLocationCalculationEntityId " +
+ "JOIN AssessmentSectionEntity USING (AssessmentSectionEntityId) " +
+ $"WHERE hlce.ShouldIllustrationPointsBeCalculated = OLD.ShouldDesignWaterLevelIllustrationPointsBeCalculated AND NormativeNormType = {(int) normType};" +
+ "DETACH DATABASE SOURCEPROJECT;";
+ }
+
+ ///
+ /// Generates a query to validate the new hydraulic boundary location calculations that are not based on migrated data.
+ ///
+ /// The file path of the database to be verified.
+ /// The calculation on which the input should be validated.
+ /// The query to validate the migrated hydraulic boundary location calculation input.
+ public static string GetNewCalculationsValidationQuery(string sourceFilePath,
+ int calculationEntityNumber)
+ {
+ return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " +
+ "SELECT COUNT() = (SELECT COUNT() FROM [SOURCEPROJECT].HydraulicLocationEntity) " +
+ "FROM HydraulicLocationEntity AS NEW " +
+ $"JOIN HydraulicLocationCalculationEntity hlce ON NEW.HydraulicLocationCalculationEntity{calculationEntityNumber}Id = hlce.HydraulicLocationCalculationEntityId " +
+ "WHERE hlce.ShouldIllustrationPointsBeCalculated = 0;" +
+ "DETACH DATABASE SOURCEPROJECT;";
+ }
+ }
+
#endregion
}
}
\ No newline at end of file