//------------------------------------------------------------------------- public virtual void test_of_String() { ConstantCurve test = ConstantCurve.of(NAME, VALUE); assertThat(test.Name).isEqualTo(CURVE_NAME); assertThat(test.YValue).isEqualTo(VALUE); assertThat(test.ParameterCount).isEqualTo(1); assertThat(test.getParameter(0)).isEqualTo(VALUE); assertThat(test.getParameterMetadata(0)).isEqualTo(ParameterMetadata.empty()); assertThat(test.withParameter(0, 2d)).isEqualTo(ConstantCurve.of(NAME, 2d)); assertThat(test.withPerturbation((i, v, m) => v + 1d)).isEqualTo(ConstantCurve.of(NAME, VALUE + 1d)); assertThat(test.Metadata).isEqualTo(METADATA); assertThat(test.withMetadata(METADATA2)).isEqualTo(ConstantCurve.of(METADATA2, VALUE)); }
//------------------------------------------------------------------------- public virtual void test_lookup() { ConstantCurve test = ConstantCurve.of(CURVE_NAME, VALUE); assertThat(test.yValue(0d)).isEqualTo(VALUE); assertThat(test.yValue(-10d)).isEqualTo(VALUE); assertThat(test.yValue(100d)).isEqualTo(VALUE); assertThat(test.yValueParameterSensitivity(0d).Sensitivity.toArray()).containsExactly(1d); assertThat(test.yValueParameterSensitivity(-10d).Sensitivity.toArray()).containsExactly(1d); assertThat(test.yValueParameterSensitivity(100d).Sensitivity.toArray()).containsExactly(1d); assertThat(test.firstDerivative(0d)).isEqualTo(0d); assertThat(test.firstDerivative(-10d)).isEqualTo(0d); assertThat(test.firstDerivative(100d)).isEqualTo(0d); }
//------------------------------------------------------------------------- public virtual void coverage() { coverImmutableBean(COMBINED_CURVE); CombinedCurve test = CombinedCurve.of(ConstantCurve.of(DefaultCurveMetadata.builder().curveName("name1").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).build(), 1d), ConstantCurve.of(DefaultCurveMetadata.builder().curveName("name2").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).build(), 2d)); coverBeanEquals(COMBINED_CURVE, test); }
public virtual void test_serialization() { ConstantCurve test = ConstantCurve.of(CURVE_NAME, VALUE); assertSerialization(test); }