public virtual void test_withValuesXy_badSize()
        {
            ConstantNodalCurve @base = ConstantNodalCurve.of(METADATA, XVALUE, YVALUE);

            assertThrowsIllegalArg(() => @base.withValues(DoubleArray.EMPTY, DoubleArray.EMPTY));
            assertThrowsIllegalArg(() => @base.withValues(DoubleArray.of(4d), DoubleArray.of(6d, 0d)));
        }
        //-------------------------------------------------------------------------
        public virtual void test_values()
        {
            ConstantNodalCurve test = ConstantNodalCurve.of(METADATA, XVALUE, YVALUE);

            assertThat(test.yValue(10.2421)).isEqualTo(YVALUE);
            assertThat(test.yValueParameterSensitivity(10.2421).MarketDataName).isEqualTo(CURVE_NAME);
            assertThat(test.yValueParameterSensitivity(10.2421).Sensitivity).isEqualTo(DoubleArray.of(1d));
            assertThat(test.firstDerivative(10.2421)).isEqualTo(0d);
        }
        public virtual void test_of_noCurveMetadata()
        {
            ConstantNodalCurve test = ConstantNodalCurve.of(METADATA_NOPARAM, XVALUE, YVALUE);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.getParameter(0)).isEqualTo(YVALUE);
            assertThat(test.getParameterMetadata(0)).isEqualTo(SimpleCurveParameterMetadata.of(ValueType.YEAR_FRACTION, XVALUE));
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ConstantNodalCurve test = ConstantNodalCurve.of(METADATA, XVALUE, YVALUE);

            coverImmutableBean(test);
            ConstantNodalCurve test2 = ConstantNodalCurve.of(METADATA_ENTRIES, 55d, 23d);

            coverBeanEquals(test, test2);
        }
        //-------------------------------------------------------------------------
        public virtual void test_withNode()
        {
            ConstantNodalCurve           @base = ConstantNodalCurve.of(METADATA_ENTRIES, XVALUE, YVALUE);
            SimpleCurveParameterMetadata param = SimpleCurveParameterMetadata.of(ValueType.YEAR_FRACTION, XVALUE);
            ConstantNodalCurve           test  = @base.withNode(XVALUE, 2d, param);

            assertThat(test.XValue).isEqualTo(XVALUE);
            assertThat(test.YValue).isEqualTo(2d);
            assertThat(test.getParameterMetadata(0)).isEqualTo(param);
        }
        //-------------------------------------------------------------------------
        public virtual void test_withValuesXy()
        {
            ConstantNodalCurve @base = ConstantNodalCurve.of(METADATA, XVALUE, YVALUE);
            ConstantNodalCurve test  = @base.withValues(XVALUE_ARRAY_NEW, YVALUE_BUMPED_ARRAY);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.Metadata).isEqualTo(METADATA);
            assertThat(test.XValues).isEqualTo(XVALUE_ARRAY_NEW);
            assertThat(test.YValues).isEqualTo(YVALUE_BUMPED_ARRAY);
        }
Пример #7
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         ConstantNodalCurve other = (ConstantNodalCurve)obj;
         return(JodaBeanUtils.equal(metadata, other.metadata) && JodaBeanUtils.equal(xValue, other.xValue) && JodaBeanUtils.equal(yValue_Renamed, other.yValue_Renamed));
     }
     return(false);
 }
        //-------------------------------------------------------------------------
        public virtual void test_of_CurveMetadata()
        {
            ConstantNodalCurve test   = ConstantNodalCurve.of(METADATA_ENTRIES, XVALUE, YVALUE);
            ConstantNodalCurve testRe = ConstantNodalCurve.of(METADATA_ENTRIES, XVALUE, YVALUE);

            assertThat(test).isEqualTo(testRe);
            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.getParameter(0)).isEqualTo(YVALUE);
            assertThrowsIllegalArg(() => test.getParameter(1));
            assertThat(test.getParameterMetadata(0)).isSameAs(METADATA_ENTRIES.ParameterMetadata.get().get(0));
            assertThat(test.withParameter(0, 2d)).isEqualTo(ConstantNodalCurve.of(METADATA_ENTRIES, XVALUE, 2d));
            assertThrowsIllegalArg(() => test.withParameter(1, 2d));
            assertThat(test.withPerturbation((i, v, m) => v - 2d)).isEqualTo(ConstantNodalCurve.of(METADATA_ENTRIES, XVALUE, YVALUE_BUMPED));
            assertThat(test.Metadata).isEqualTo(METADATA_ENTRIES);
            assertThat(test.XValues).isEqualTo(XVALUE_ARRAY);
            assertThat(test.YValues).isEqualTo(YVALUE_ARRAY);
        }
        public virtual void test_withNode_invalid()
        {
            ConstantNodalCurve test = ConstantNodalCurve.of(METADATA_ENTRIES, XVALUE, YVALUE);

            assertThrowsIllegalArg(() => test.withNode(1, 2, ParameterMetadata.empty()));
        }
        public virtual void test_serialization()
        {
            ConstantNodalCurve test = ConstantNodalCurve.of(METADATA, XVALUE, YVALUE);

            assertSerialization(test);
        }
        public virtual void test_withMetadata_badSize()
        {
            ConstantNodalCurve @base = ConstantNodalCurve.of(METADATA, XVALUE, YVALUE);

            assertThrowsIllegalArg(() => @base.withMetadata(METADATA_ENTRIES2));
        }