Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs =================================================================== diff -u -r91e78bc36345ae134554f210943cc0f9496dcfbd -r21d08a0982d604446e0ca8272f192bc33d7438f0 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs (.../PipingConfigurationImporter.cs) (revision 91e78bc36345ae134554f210943cc0f9496dcfbd) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs (.../PipingConfigurationImporter.cs) (revision 21d08a0982d604446e0ca8272f192bc33d7438f0) @@ -183,13 +183,28 @@ pipingCalculation.InputParameters.ExitPointL = (RoundedDouble) readCalculation.ExitPointL.Value; } + if (readCalculation.StochasticSoilModel != null) + { + StochasticSoilModel soilModel = failureMechanism.StochasticSoilModels.FirstOrDefault(ssm => ssm.Name == readCalculation.StochasticSoilModel); + + if (soilModel != null) + { + pipingCalculation.InputParameters.StochasticSoilModel = soilModel; + } + else + { + log.Warn("Ondergrondmodel bestaat niet. Berekening overgeslagen."); + return; + } + } + validCalculationItems.Add(pipingCalculation); // Validate when set: // - HR location X // - Surface line X // - Entry/Exit point X - // - Stochastic soil model + // - Stochastic soil model X // - Stochastic soil profile // Validate the stochastic soil model crosses the surface line when set // Validate the stochastic soil profile is part of the soil model Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingConfigurationImporterTest.cs =================================================================== diff -u -r91e78bc36345ae134554f210943cc0f9496dcfbd -r21d08a0982d604446e0ca8272f192bc33d7438f0 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingConfigurationImporterTest.cs (.../PipingConfigurationImporterTest.cs) (revision 91e78bc36345ae134554f210943cc0f9496dcfbd) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingConfigurationImporterTest.cs (.../PipingConfigurationImporterTest.cs) (revision 21d08a0982d604446e0ca8272f192bc33d7438f0) @@ -223,18 +223,55 @@ { // Setup var calculationGroup = new CalculationGroup(); + + string filePath = Path.Combine(path, "validConfigurationFullCalculationContainingHydraulicBoundaryLocation.xml"); + var importer = new PipingConfigurationImporter(filePath, + calculationGroup, + new[] + { + new HydraulicBoundaryLocation(1, "HRlocatie", 10, 20), + }, + new PipingFailureMechanism()); + + // Call + bool succesful = false; + Action call = () => succesful = importer.Import(); + + // Assert + TestHelper.AssertLogMessageIsGenerated(call, "Profielschematisatie bestaat niet. Berekening overgeslagen.", 1); + Assert.IsTrue(succesful); + CollectionAssert.IsEmpty(calculationGroup.Children); + } + + [Test] + public void Import_StochastichSoilModelInvalid_LogMessageAndContinueImport() + { + // Setup + string filePath = Path.Combine(path, "validConfigurationFullCalculationContainingHydraulicBoundaryLocation.xml"); + + var calculationGroup = new CalculationGroup(); + var surfaceLine = new RingtoetsPipingSurfaceLine + { + Name = "Profielschematisatie" + }; + surfaceLine.SetGeometry(new[] + { + new Point3D(3.5, 2.3, 8.0), + new Point3D(6.9, 2.0, 2.0) + }); + var pipingFailureMechanism = new PipingFailureMechanism(); pipingFailureMechanism.SurfaceLines.AddRange(new[] { - new RingtoetsPipingSurfaceLine() + surfaceLine }, "path"); - string filePath = Path.Combine(path, "validConfigurationFullCalculationContainingHydraulicBoundaryLocation.xml"); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "HRlocatie", 10, 20); var importer = new PipingConfigurationImporter(filePath, calculationGroup, new[] { - new HydraulicBoundaryLocation(1, "HRlocatie", 10, 20), + hydraulicBoundaryLocation }, pipingFailureMechanism); @@ -243,7 +280,7 @@ Action call = () => succesful = importer.Import(); // Assert - TestHelper.AssertLogMessageIsGenerated(call, "Profielschematisatie bestaat niet. Berekening overgeslagen.", 1); + TestHelper.AssertLogMessageIsGenerated(call, "Ondergrondmodel bestaat niet. Berekening overgeslagen.", 1); Assert.IsTrue(succesful); CollectionAssert.IsEmpty(calculationGroup.Children); } @@ -264,12 +301,17 @@ new Point3D(3.5, 2.3, 8.0), new Point3D(6.9, 2.0, 2.0) }); + var stochasticSoilModel = new StochasticSoilModel(1, "Ondergrondmodel", "Segment"); var pipingFailureMechanism = new PipingFailureMechanism(); pipingFailureMechanism.SurfaceLines.AddRange(new[] { surfaceLine }, "path"); + pipingFailureMechanism.StochasticSoilModels.AddRange(new[] + { + stochasticSoilModel + }, "path"); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "HRlocatie", 10, 20); var importer = new PipingConfigurationImporter(filePath, @@ -288,10 +330,12 @@ Assert.AreEqual(1, calculationGroup.Children.Count); PipingCalculation calculation = calculationGroup.Children[0] as PipingCalculation; + Assert.AreEqual("Calculation", calculation.Name); Assert.AreSame(hydraulicBoundaryLocation, calculation.InputParameters.HydraulicBoundaryLocation); Assert.AreSame(surfaceLine, calculation.InputParameters.SurfaceLine); Assert.AreEqual(1.1, calculation.InputParameters.EntryPointL.Value); Assert.AreEqual(2.2, calculation.InputParameters.ExitPointL.Value); + Assert.AreSame(stochasticSoilModel, calculation.InputParameters.StochasticSoilModel); } private class ExpectedProgressNotification