Example #1
0
        public virtual void tokens()
        {
            PositionTokenEvaluator evaluator = new PositionTokenEvaluator();
            ISet <string>          tokens    = evaluator.tokens(trade());
            ISet <string>          expected  = ImmutableSet.of("longQuantity", "shortQuantity", "quantity", "security", "info", "id", "attributes");

            assertThat(tokens).isEqualTo(expected);
        }
Example #2
0
        public virtual void evaluate()
        {
            PositionTokenEvaluator evaluator = new PositionTokenEvaluator();
            Position pos = trade();

            EvaluationResult quantity = evaluator.evaluate(pos, FUNCTIONS, "quantity", ImmutableList.of());

            assertThat(quantity.Result).hasValue(6d);

            EvaluationResult initialPrice = evaluator.evaluate(pos, FUNCTIONS, "security", ImmutableList.of());

            assertThat(initialPrice.Result).hasValue(SECURITY);

            // Check that property name isn't case sensitive
            EvaluationResult initialPrice2 = evaluator.evaluate(pos, FUNCTIONS, "Security", ImmutableList.of());

            assertThat(initialPrice2.Result).hasValue(SECURITY);

            // Unknown property
            EvaluationResult foo = evaluator.evaluate(pos, FUNCTIONS, "foo", ImmutableList.of());

            assertThat(foo.Result).Failure;
        }