Пример #1
0
        public virtual void evaluate()
        {
            TradeTokenEvaluator evaluator = new TradeTokenEvaluator();
            Trade trade = TradeTokenEvaluatorTest.trade();

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

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

            EvaluationResult initialPrice = evaluator.evaluate(trade, FUNCTIONS, "price", ImmutableList.of());

            assertThat(initialPrice.Result).hasValue(456d);

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

            assertThat(initialPrice2.Result).hasValue(456d);

            EvaluationResult counterparty = evaluator.evaluate(trade, FUNCTIONS, "counterparty", ImmutableList.of());

            assertThat(counterparty.Result).hasValue(StandardId.of("cpty", "a"));

            // Optional property with no value
            EvaluationResult tradeTime = evaluator.evaluate(trade, FUNCTIONS, "tradeTime", ImmutableList.of());

            assertThat(tradeTime.Result).Failure;

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

            assertThat(foo.Result).Failure;
        }
Пример #2
0
        public virtual void tokens()
        {
            TradeTokenEvaluator evaluator = new TradeTokenEvaluator();
            ISet <string>       tokens    = evaluator.tokens(trade());
            ISet <string>       expected  = ImmutableSet.of("quantity", "price", "security", "id", "counterparty", "tradeDate", "tradeTime", "zone", "settlementDate", "attributes", "info");

            assertThat(tokens).isEqualTo(expected);
        }