public virtual void test_resolveValues_dateBased_invalidDateAfter() { ValueStep step = ValueStep.of(date(2014, 4, 3), ValueAdjustment.ofReplace(300d)); ValueSchedule test = ValueSchedule.of(200d, ImmutableList.of(step)); assertThrowsIllegalArg(() => test.resolveValues(SCHEDULE), "ValueStep date is after the end of the schedule.*"); }
public virtual void test_resolveValues_indexBased_indexTooBig() { ValueStep step = ValueStep.of(3, ValueAdjustment.ofReplace(300d)); ValueSchedule test = ValueSchedule.of(200d, ImmutableList.of(step)); assertThrowsIllegalArg(() => test.resolveValues(SCHEDULE)); }
public virtual void test_resolveValues_dateBased_invalidChangeValue() { ValueStep step = ValueStep.of(date(2014, 4, 1), ValueAdjustment.ofReplace(300d)); ValueSchedule test = ValueSchedule.of(200d, ImmutableList.of(step)); assertThrowsIllegalArg(() => test.resolveValues(SCHEDULE), "ValueStep date does not match a period boundary.*"); }
public virtual void test_resolve_invalid() { ValueStepSequence test = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P12M, ADJ); ValueStep baseStep = ValueStep.of(date(2016, 1, 20), ValueAdjustment.ofReplace(500d)); assertThrowsIllegalArg(() => test.resolve(ImmutableList.of(baseStep), RollConventions.NONE)); }
public virtual void test_resolveValues_dateBased_indexZeroValid() { ValueStep step = ValueStep.of(date(2014, 1, 1), ValueAdjustment.ofReplace(300d)); ValueSchedule test = ValueSchedule.of(200d, ImmutableList.of(step)); assertEquals(test.resolveValues(SCHEDULE), DoubleArray.of(300d, 300d, 300d)); }
public virtual void test_resolveValues_sequenceAndStepClash() { ValueStepSequence seq = ValueStepSequence.of(date(2014, 2, 1), date(2014, 3, 1), Frequency.P1M, ValueAdjustment.ofDeltaAmount(100)); ValueStep step1 = ValueStep.of(date(2014, 2, 1), ValueAdjustment.ofReplace(350d)); ValueSchedule test = ValueSchedule.builder().initialValue(200d).steps(step1).stepSequence(seq).build(); assertThrowsIllegalArg(() => test.resolveValues(SCHEDULE)); }
public virtual void test_resolveValues_sequenceAndSteps() { ValueStepSequence seq = ValueStepSequence.of(date(2014, 2, 1), date(2014, 3, 1), Frequency.P1M, ValueAdjustment.ofDeltaAmount(100)); ValueStep step1 = ValueStep.of(date(2014, 1, 1), ValueAdjustment.ofReplace(350d)); ValueSchedule test = ValueSchedule.builder().initialValue(200d).steps(step1).stepSequence(seq).build(); assertEquals(test.resolveValues(SCHEDULE), DoubleArray.of(350d, 450d, 550d)); }
public virtual void test_resolveValues_indexBased_duplicateDefinitionInvalid() { ValueStep step1 = ValueStep.of(1, ValueAdjustment.ofReplace(300d)); ValueStep step2 = ValueStep.of(1, ValueAdjustment.ofReplace(400d)); ValueSchedule test = ValueSchedule.of(200d, ImmutableList.of(step1, step2)); assertThrowsIllegalArg(() => test.resolveValues(SCHEDULE)); }
public virtual void test_resolveValues_indexBased_duplicateDefinitionValid() { ValueStep step1 = ValueStep.of(1, ValueAdjustment.ofReplace(300d)); ValueStep step2 = ValueStep.of(1, ValueAdjustment.ofReplace(300d)); ValueSchedule test = ValueSchedule.of(200d, ImmutableList.of(step1, step2)); assertEquals(test.resolveValues(SCHEDULE), DoubleArray.of(200d, 300d, 300d)); }
public virtual void test_ofReplace() { ValueAdjustment test = ValueAdjustment.ofReplace(200); assertEquals(test.ModifyingValue, 200, TOLERANCE); assertEquals(test.Type, ValueAdjustmentType.REPLACE); assertEquals(test.adjust(100), 200, TOLERANCE); assertEquals(test.ToString(), "ValueAdjustment[result = 200.0]"); }
//------------------------------------------------------------------------- public virtual void Equals() { ValueAdjustment a1 = ValueAdjustment.ofReplace(200); ValueAdjustment a2 = ValueAdjustment.ofReplace(200); ValueAdjustment b = ValueAdjustment.ofDeltaMultiplier(200); ValueAdjustment c = ValueAdjustment.ofDeltaMultiplier(0.1); assertEquals(a1.Equals(a2), true); assertEquals(a1.Equals(b), false); assertEquals(a1.Equals(c), false); }
public virtual void test_resolveValues_dateBased_ignoreExcess() { ValueStep step1 = ValueStep.of(date(2014, 2, 1), ValueAdjustment.ofReplace(300d)); ValueStep step2 = ValueStep.of(date(2014, 2, 15), ValueAdjustment.ofReplace(300d)); // no change to value ValueStep step3 = ValueStep.of(date(2014, 3, 1), ValueAdjustment.ofReplace(400d)); ValueStep step4 = ValueStep.of(date(2014, 3, 15), ValueAdjustment.ofDeltaAmount(0d)); // no change to value ValueStep step5 = ValueStep.of(date(2014, 4, 1), ValueAdjustment.ofMultiplier(1d)); ValueSchedule test = ValueSchedule.of(200d, ImmutableList.of(step1, step2, step3, step4, step5)); assertEquals(test.resolveValues(SCHEDULE), DoubleArray.of(200d, 300d, 400d)); }
//------------------------------------------------------------------------- public virtual void test_resolve() { ValueStepSequence test = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ADJ); ValueStep baseStep = ValueStep.of(date(2016, 1, 20), ValueAdjustment.ofReplace(500d)); IList <ValueStep> steps = test.resolve(ImmutableList.of(baseStep), RollConventions.NONE); assertEquals(steps.Count, 4); assertEquals(steps[0], baseStep); assertEquals(steps[1], ValueStep.of(date(2016, 4, 20), ADJ)); assertEquals(steps[2], ValueStep.of(date(2016, 7, 20), ADJ)); assertEquals(steps[3], ValueStep.of(date(2016, 10, 20), ADJ)); }
public virtual void test_resolveValues_indexBased() { ValueStep step1 = ValueStep.of(1, ValueAdjustment.ofReplace(300d)); ValueStep step2 = ValueStep.of(2, ValueAdjustment.ofReplace(400d)); // no steps ValueSchedule test0 = ValueSchedule.of(200d, ImmutableList.of()); assertEquals(test0.resolveValues(SCHEDULE), DoubleArray.of(200d, 200d, 200d)); // step1 ValueSchedule test1a = ValueSchedule.of(200d, ImmutableList.of(step1)); assertEquals(test1a.resolveValues(SCHEDULE), DoubleArray.of(200d, 300d, 300d)); // step2 ValueSchedule test1b = ValueSchedule.of(200d, ImmutableList.of(step2)); assertEquals(test1b.resolveValues(SCHEDULE), DoubleArray.of(200d, 200d, 400d)); // step1 and step2 ValueSchedule test2 = ValueSchedule.of(200d, ImmutableList.of(step1, step2)); assertEquals(test2.resolveValues(SCHEDULE), DoubleArray.of(200d, 300d, 400d)); }
public virtual void test_serialization() { assertSerialization(ValueAdjustment.ofReplace(200)); }
//------------------------------------------------------------------------- public virtual void coverage() { coverImmutableBean(ValueAdjustment.ofReplace(200)); }