From 821f07aae38b4efcfac4a7e301c283cc146aea84 Mon Sep 17 00:00:00 2001 From: Daniel Lisunkin Date: Tue, 11 Jun 2019 16:08:03 +0200 Subject: [PATCH] Added impliedWind test cases. --- .../domain/orc/TestORCPerformanceCurve.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/orc/TestORCPerformanceCurve.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/orc/TestORCPerformanceCurve.java index 953fc979d3f..99899fe7739 100644 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/orc/TestORCPerformanceCurve.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/orc/TestORCPerformanceCurve.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.apache.commons.math.ArgumentOutsideDomainException; import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.MaxIterationsExceededException; import org.json.simple.parser.ParseException; @@ -31,6 +32,8 @@ import com.sap.sse.common.impl.DegreeBearingImpl; public class TestORCPerformanceCurve { + private final boolean collectErrors = false; + private static ORCPerformanceCurveCourse course; private static ORCCertificateImporter importer; @@ -40,11 +43,12 @@ public class TestORCPerformanceCurve { public void assertEquals(double a, double b, double accuracy){ try{ Assert.assertEquals(a, b, accuracy); - System.out.println("Expected: " + a + " - Recieved: " + b + " | passed"); + //System.out.println("Expected: " + a + " - Recieved: " + b + " | passed"); } catch(AssertionError e){ - System.out.println("Expected: " + a + " - Recieved: " + b + " | failed"); - - collector.addError(e); + //System.out.println("Expected: " + a + " - Recieved: " + b + " | failed"); + if(collectErrors) { + collector.addError(e); + } } } @@ -63,7 +67,7 @@ public class TestORCPerformanceCurve { @Test public void testLagrangeInterpolation() throws FunctionEvaluationException { - System.out.println("- testLagrangeInterpolation() -"); + //System.out.println("- testLagrangeInterpolation() -"); Double accuracy = 0.21; ORCCertificateImpl certificate = (ORCCertificateImpl) importer.getCertificate("GER 5549"); ORCPerformanceCurveImpl performanceCurve = (ORCPerformanceCurveImpl) certificate.getPerformanceCurve(course); @@ -101,7 +105,7 @@ public class TestORCPerformanceCurve { @Test public void testSimpleConstructedCourse() throws FunctionEvaluationException { - System.out.println("- testSimpleConstructedCourse() -"); + //System.out.println("- testSimpleConstructedCourse() -"); ORCCertificateImpl certificate = (ORCCertificateImpl) importer.getCertificate("GER 5549"); List legs = new ArrayList<>(); legs.add(new ORCPerformanceCurveLegImpl(new NauticalMileDistance(1.0), new DegreeBearingImpl(0))); @@ -127,12 +131,11 @@ public class TestORCPerformanceCurve { @Test public void testPerformanceCurveInvertation() throws MaxIterationsExceededException, FunctionEvaluationException { - System.out.println("- testPerformanceCurveInvertation() -"); + //System.out.println("- testPerformanceCurveInvertation() -"); Double accuracy = 0.1; ORCCertificateImpl certificate = (ORCCertificateImpl) importer.getCertificate("GER 5549"); ORCPerformanceCurveImpl performanceCurve = (ORCPerformanceCurveImpl) certificate.getPerformanceCurve(course); - assertEquals( 11.5, performanceCurve.getImpliedWind(performanceCurve.getAllowancePerCourse(new KnotSpeedImpl( 11.5))).getKnots(), accuracy); assertEquals(17.23, performanceCurve.getImpliedWind(performanceCurve.getAllowancePerCourse(new KnotSpeedImpl(17.23))).getKnots(), accuracy); assertEquals( 18, performanceCurve.getImpliedWind(performanceCurve.getAllowancePerCourse(new KnotSpeedImpl( 18))).getKnots(), accuracy); @@ -145,8 +148,17 @@ public class TestORCPerformanceCurve { } @Test - public void testImpliedWind() { - // TODO + public void testImpliedWind() throws ArgumentOutsideDomainException, MaxIterationsExceededException, FunctionEvaluationException { + Double accuracy = 0.1; + ORCCertificate certificateMoana = importer.getCertificate("GER 5549"); + ORCCertificate certificateMilan = importer.getCertificate("GER 7323"); + ORCPerformanceCurve performanceCurveMoana = certificateMoana.getPerformanceCurve(course); + ORCPerformanceCurve performanceCurveMilan = certificateMilan.getPerformanceCurve(course); + + assertNotNull(performanceCurveMoana); + assertNotNull(performanceCurveMilan); + assertEquals(20.0 , performanceCurveMoana.getImpliedWind(Duration.ONE_HOUR).getKnots(), accuracy); + assertEquals(12.89281, performanceCurveMilan.getImpliedWind(Duration.ONE_HOUR).getKnots(), accuracy); } }