/// <summary> /// Tests the tokens() method when the bean has a single property. The tokens should include the single property /// name plus the tokens of the property value. /// </summary> public virtual void tokensSingleProperty() { SwapLegAmount amount = SwapLegAmount.builder().amount(CurrencyAmount.of(Currency.AUD, 7)).payReceive(PayReceive.PAY).type(SwapLegType.FIXED).currency(Currency.AUD).build(); LegAmounts amounts = LegAmounts.of(amount); BeanTokenEvaluator evaluator = new BeanTokenEvaluator(); ISet <string> tokens = evaluator.tokens(amounts); assertThat(tokens).isEqualTo(ImmutableSet.of("amounts", "0", "aud", "pay", "fixed")); }
public virtual void tokens() { Bean bean = BeanTokenEvaluatorTest.bean(); BeanTokenEvaluator evaluator = new BeanTokenEvaluator(); ISet <string> tokens = evaluator.tokens(bean); ImmutableSet <string> expectedTokens = ImmutableSet.of("buySell", "currency", "notional", "startDate", "endDate", "businessDayAdjustment", "paymentDate", "fixedRate", "index", "indexInterpolated", "fixingDateOffset", "dayCount", "discounting"); assertThat(tokens).isEqualTo(expectedTokens); }
public virtual void evaluate() { Bean bean = BeanTokenEvaluatorTest.bean(); BeanTokenEvaluator evaluator = new BeanTokenEvaluator(); EvaluationResult notional1 = evaluator.evaluate(bean, FUNCTIONS, "notional", ImmutableList.of()); assertThat(notional1.Result).hasValue(1_000_000d); EvaluationResult notional2 = evaluator.evaluate(bean, FUNCTIONS, "Notional", ImmutableList.of()); assertThat(notional2.Result).hasValue(1_000_000d); }
/// <summary> /// Tests evaluating a bean with a single property. There are 2 different expected behaviours: /// /// 1) If the token matches the property, the property value is returned and the token is consumed. This is the same /// as the normal bean behaviour. /// 2) If the token doesn't match the property it is assumed to match something on the property's value. In this /// case the property value is returned and no tokens are consumed. /// </summary> public virtual void evaluateSingleProperty() { SwapLegAmount amount = SwapLegAmount.builder().amount(CurrencyAmount.of(Currency.AUD, 7)).payReceive(PayReceive.PAY).type(SwapLegType.FIXED).currency(Currency.AUD).build(); LegAmounts amounts = LegAmounts.of(amount); BeanTokenEvaluator evaluator = new BeanTokenEvaluator(); EvaluationResult result1 = evaluator.evaluate(amounts, FUNCTIONS, "amounts", ImmutableList.of("foo", "bar")); assertThat(result1.Result).hasValue(ImmutableList.of(amount)); assertThat(result1.RemainingTokens).isEqualTo(ImmutableList.of("foo", "bar")); EvaluationResult result2 = evaluator.evaluate(amounts, FUNCTIONS, "baz", ImmutableList.of("foo", "bar")); assertThat(result2.Result).hasValue(ImmutableList.of(amount)); assertThat(result2.RemainingTokens).isEqualTo(ImmutableList.of("baz", "foo", "bar")); }