コード例 #1
0
        public virtual void test_builder_validEmpty()
        {
            ValueSchedule test = ValueSchedule.builder().build();

            assertEquals(test.InitialValue, 0d, TOLERANCE);
            assertEquals(test.Steps, ImmutableList.of());
        }
コード例 #2
0
        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.*");
        }
コード例 #3
0
        public virtual void test_of_intStepsList_empty()
        {
            ValueSchedule test = ValueSchedule.of(10000d, Lists.newArrayList());

            assertEquals(test.InitialValue, 10000d, TOLERANCE);
            assertEquals(test.Steps, ImmutableList.of());
        }
コード例 #4
0
        public virtual void test_constant_ALWAYS_1()
        {
            ValueSchedule test = ValueSchedule.ALWAYS_1;

            assertEquals(test.InitialValue, 1d, TOLERANCE);
            assertEquals(test.Steps, ImmutableList.of());
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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.*");
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        public virtual void test_of_intStepsArray()
        {
            ValueSchedule test = ValueSchedule.of(10000d, STEP1, STEP2);

            assertEquals(test.InitialValue, 10000d, TOLERANCE);
            assertEquals(test.Steps, ImmutableList.of(STEP1, STEP2));
        }
コード例 #9
0
        //-------------------------------------------------------------------------
        public virtual void test_resolveValues_sequence()
        {
            ValueStepSequence seq  = ValueStepSequence.of(date(2014, 2, 1), date(2014, 3, 1), Frequency.P1M, ValueAdjustment.ofDeltaAmount(100));
            ValueSchedule     test = ValueSchedule.of(200d, seq);

            assertEquals(test.resolveValues(SCHEDULE), DoubleArray.of(200d, 300d, 400d));
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        public virtual void test_of_sequence()
        {
            ValueStepSequence seq  = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ValueAdjustment.ofDeltaAmount(-100));
            ValueSchedule     test = ValueSchedule.of(10000d, seq);

            assertEquals(test.InitialValue, 10000d, TOLERANCE);
            assertEquals(test.Steps, ImmutableList.of());
            assertEquals(test.StepSequence, seq);
        }
コード例 #15
0
        public virtual void test_builder_validFull()
        {
            ValueStepSequence seq  = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ValueAdjustment.ofDeltaAmount(-100));
            ValueSchedule     test = ValueSchedule.builder().initialValue(2000d).steps(STEP1, STEP2).stepSequence(seq).build();

            assertEquals(test.InitialValue, 2000d, TOLERANCE);
            assertEquals(test.Steps, ImmutableList.of(STEP1, STEP2));
            assertEquals(test.StepSequence, seq);
        }
コード例 #16
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ValueStepSequence seq = ValueStepSequence.of(date(2014, 2, 1), date(2014, 3, 1), Frequency.P1M, ValueAdjustment.ofDeltaAmount(100));

            ValueSchedule test = ValueSchedule.of(10000d, Lists.newArrayList(STEP1, STEP2));

            coverImmutableBean(test);
            coverBeanEquals(test, ValueSchedule.of(20000d, seq));
        }
コード例 #17
0
        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));
        }
コード例 #18
0
        //-------------------------------------------------------------------------
        public virtual void Equals()
        {
            ValueSchedule a1 = ValueSchedule.of(10000d, Lists.newArrayList(STEP1, STEP2));
            ValueSchedule a2 = ValueSchedule.of(10000d, Lists.newArrayList(STEP1, STEP2));
            ValueSchedule b  = ValueSchedule.of(5000d, Lists.newArrayList(STEP1, STEP2));
            ValueSchedule c  = ValueSchedule.of(10000d, Lists.newArrayList(STEP1));

            assertEquals(a1.Equals(a2), true);
            assertEquals(a1.Equals(b), false);
            assertEquals(a1.Equals(c), false);
        }
コード例 #19
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         ValueSchedule other = (ValueSchedule)obj;
         return(JodaBeanUtils.equal(initialValue, other.initialValue) && JodaBeanUtils.equal(steps, other.steps) && JodaBeanUtils.equal(stepSequence, other.stepSequence));
     }
     return(false);
 }
コード例 #20
0
        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));
        }
コード例 #21
0
 public virtual void test_serialization()
 {
     assertSerialization(ValueSchedule.of(10000d, Lists.newArrayList(STEP1, STEP2)));
 }