Index: Ringtoets/Common/src/Ringtoets.Common.Service/AssemblyTool/AssemblyToolCategoriesCalculationService.cs =================================================================== diff -u -rd092c6839036b4971bf5d288f2a1ae7dcdcb2a4c -r7eb086070edadc5f5d24683b9a72be9c1c5ef209 --- Ringtoets/Common/src/Ringtoets.Common.Service/AssemblyTool/AssemblyToolCategoriesCalculationService.cs (.../AssemblyToolCategoriesCalculationService.cs) (revision d092c6839036b4971bf5d288f2a1ae7dcdcb2a4c) +++ Ringtoets/Common/src/Ringtoets.Common.Service/AssemblyTool/AssemblyToolCategoriesCalculationService.cs (.../AssemblyToolCategoriesCalculationService.cs) (revision 7eb086070edadc5f5d24683b9a72be9c1c5ef209) @@ -26,6 +26,8 @@ using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Categories; using Ringtoets.AssemblyTool.KernelWrapper.Kernels; using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Service.Properties; namespace Ringtoets.Common.Service.AssemblyTool { @@ -50,10 +52,18 @@ IAssemblyCategoriesCalculator calculator = AssemblyToolCalculatorFactory.Instance.CreateAssemblyCategoriesCalculator( AssemblyToolKernelWrapperFactory.Instance); - IEnumerable categories = calculator.CalculateAssessmentSectionCategories( - AssemblyCategoryInputConverter.Convert(input)); + try + { + IEnumerable categories = calculator.CalculateAssessmentSectionCategories( + AssemblyCategoryInputConverter.Convert(input)); - return AssemblyCategoryConverter.ConvertAssessmentSectionAssemblyCategories(categories); + return AssemblyCategoryConverter.ConvertAssessmentSectionAssemblyCategories(categories); + } + catch (Exception e) when (e is AssemblyCategoriesCalculatorException || e is AssemblyCategoryConversionException) + { + CalculationServiceHelper.LogExceptionAsError(Resources.AssemblyToolCategoriesCalculationService_CalculateAssessmentSectionAssemblyCategories_Error_in_assembly_categories_calculation, e); + return new AssessmentSectionAssemblyCategory[0]; + } } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs =================================================================== diff -u -r7371a70ed0751d341d41a7b951b780d286f83791 -r7eb086070edadc5f5d24683b9a72be9c1c5ef209 --- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7371a70ed0751d341d41a7b951b780d286f83791) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7eb086070edadc5f5d24683b9a72be9c1c5ef209) @@ -40,7 +40,7 @@ // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -82,6 +82,16 @@ } /// + /// Looks up a localized string similar to Er is een onverwachte fout opgetreden bij het bepalen van categoriegrenzen.. + /// + public static string AssemblyToolCategoriesCalculationService_CalculateAssessmentSectionAssemblyCategories_Error_in_assembly_categories_calculation { + get { + return ResourceManager.GetString("AssemblyToolCategoriesCalculationService_CalculateAssessmentSectionAssemblyCatego" + + "ries_Error_in_assembly_categories_calculation", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Berekening is beƫindigd.. /// public static string Calculation_ended { Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx =================================================================== diff -u -r7371a70ed0751d341d41a7b951b780d286f83791 -r7eb086070edadc5f5d24683b9a72be9c1c5ef209 --- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 7371a70ed0751d341d41a7b951b780d286f83791) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 7eb086070edadc5f5d24683b9a72be9c1c5ef209) @@ -215,4 +215,7 @@ Fout bij het uitlezen van de illustratiepunten voor berekening {0}: {1} Het uitlezen van illustratiepunten wordt overgeslagen. + + Er is een onverwachte fout opgetreden bij het bepalen van categoriegrenzen. + \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/AssemblyTool/AssemblyToolCategoriesCalculationServiceTest.cs =================================================================== diff -u -rd092c6839036b4971bf5d288f2a1ae7dcdcb2a4c -r7eb086070edadc5f5d24683b9a72be9c1c5ef209 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/AssemblyTool/AssemblyToolCategoriesCalculationServiceTest.cs (.../AssemblyToolCategoriesCalculationServiceTest.cs) (revision d092c6839036b4971bf5d288f2a1ae7dcdcb2a4c) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/AssemblyTool/AssemblyToolCategoriesCalculationServiceTest.cs (.../AssemblyToolCategoriesCalculationServiceTest.cs) (revision 7eb086070edadc5f5d24683b9a72be9c1c5ef209) @@ -20,14 +20,19 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; +using Core.Common.TestUtil; +using log4net.Core; using NUnit.Framework; using Ringtoets.AssemblyTool.Data.Input; using Ringtoets.AssemblyTool.Data.Output; using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Categories; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Categories; using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Service.AssemblyTool; namespace Ringtoets.Common.Service.Test.AssemblyTool @@ -96,6 +101,69 @@ } } + [Test] + public void CalculateAssessmentSectionAssemblyCategories_CalculatorThrowsException_LogErrorAndReturnEmptyOutput() + { + var input = new AssemblyCategoryInput(0, 0); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + AssemblyCategoriesCalculatorStub calculator = calculatorFactory.LastCreatedAssemblyCategoriesCalculator; + calculator.ThrowExceptionOnCalculate = true; + + //Call + IEnumerable output = null; + Action test = () => output = AssemblyToolCategoriesCalculationService.CalculateAssessmentSectionAssemblyCategories(input); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(test, tuples => + { + Tuple[] messages = tuples as Tuple[] ?? tuples.ToArray(); + Assert.AreEqual(1, messages.Length); + + Tuple tuple1 = messages[0]; + Assert.AreEqual("Er is een onverwachte fout opgetreden bij het bepalen van categoriegrenzen.", tuple1.Item1); + Assert.AreEqual(Level.Error, tuple1.Item2); + Assert.IsInstanceOf(tuple1.Item3); + }); + CollectionAssert.IsEmpty(output); + } + } + + [Test] + public void CalculateAssessmentSectionAssemblyCategories_ErrorInConversion_LogErrorAndReturnEmptyOutput() + { + var input = new AssemblyCategoryInput(0, 0); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + AssemblyCategoriesCalculatorStub calculator = calculatorFactory.LastCreatedAssemblyCategoriesCalculator; + calculator.AssessmentSectionCategoriesOutput = new[] + { + new AssessmentSectionAssemblyCategoryResult(0, 1, (AssessmentSectionAssemblyCategoryResultType) 99) + }; + + //Call + IEnumerable output = null; + Action test = () => output = AssemblyToolCategoriesCalculationService.CalculateAssessmentSectionAssemblyCategories(input); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(test, tuples => + { + Tuple[] messages = tuples as Tuple[] ?? tuples.ToArray(); + Assert.AreEqual(1, messages.Length); + + Tuple tuple1 = messages[0]; + Assert.AreEqual("Er is een onverwachte fout opgetreden bij het bepalen van categoriegrenzen.", tuple1.Item1); + Assert.AreEqual(Level.Error, tuple1.Item2); + Assert.IsInstanceOf(tuple1.Item3); + }); + CollectionAssert.IsEmpty(output); + } + } + private static AssessmentSectionAssemblyCategoryType GetAssessmentSectionAssemblyCategoryType( AssessmentSectionAssemblyCategoryResultType categoryType) {