ResultsFormatter { @SuppressWarnings("unchecked") public Object format(Object value, ValueSpecification valueSpec, TypeFormatter.Format format, Object inlineKey) { TypeFormatter formatter = getFormatter(value, valueSpec); return formatter.format(value, valueSpec, format, inlineKey); } ResultsFormatter();  ResultsFormatter(CurrencyDisplay currencyDisplay); @SuppressWarnings("unchecked") Object format(Object value, ValueSpecification valueSpec, TypeFormatter.Format format, Object inlineKey); DataType getDataType(Class<?> type); @SuppressWarnings("unchecked") DataType getDataTypeForValue(Object value, ValueSpecification valueSpec); static final Object VALUE_UNAVAILABLE; }
@Test public void formatHistoryForValueNameWithUnknownType() { ResultsFormatter formatter = new ResultsFormatter(); UniqueId uid = UniqueId.of("scheme", "value"); ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.POSITION, uid); ValueProperties props = ValueProperties.builder().with(ValuePropertyNames.FUNCTION, "fn").get(); formatter.format(123d, new ValueSpecification("unknown value name", spec, props), TypeFormatter.Format.HISTORY, null); }
@Test public void currencyAmountCanHaveCurrencyOutput() { ResultsFormatter formatter = new ResultsFormatter(); CurrencyAmount value = CurrencyAmount.of(Currency.USD, 123.45); Object result = formatter.format(value, null, TypeFormatter.Format.CELL, null); assertTrue(result instanceof String); assertEquals(result, "USD 123.45"); }
@Test public void currencyAmountCanHaveCurrencySuppressed() { ResultsFormatter formatter = new ResultsFormatter(SUPPRESS_CURRENCY); CurrencyAmount value = CurrencyAmount.of(Currency.USD, 123.45); Object result = formatter.format(value, null, TypeFormatter.Format.CELL, null); assertTrue(result instanceof String); assertEquals(result, "123.45"); }
@Test public void unknownValueSpecCanHaveCurrencyOutput() { ResultsFormatter formatter = new ResultsFormatter(); Object result = formatter.format(123.45, buildValueSpecificationWithCurrency("unknown value name"), TypeFormatter.Format.CELL, null); assertTrue(result instanceof String); assertEquals(result, "USD 123"); }
@Test public void unknownValueSpecCanHaveCurrencySuppressed() { ResultsFormatter formatter = new ResultsFormatter(SUPPRESS_CURRENCY); Object result = formatter.format(123.45, buildValueSpecificationWithCurrency("unknown value name"), TypeFormatter.Format.CELL, null); assertTrue(result instanceof String); assertEquals(result, "123"); }
@Test public void knownValueSpecCanHaveCurrencyOutput() { ResultsFormatter formatter = new ResultsFormatter(); Object result = formatter.format(123.45, buildValueSpecificationWithCurrency(ValueRequirementNames.PRESENT_VALUE), TypeFormatter.Format.CELL, null); assertTrue(result instanceof String); assertEquals(result, "USD 123"); }
@Test public void knownValueSpecCanHaveCurrencySuppressed() { ResultsFormatter formatter = new ResultsFormatter(SUPPRESS_CURRENCY); Object result = formatter.format(123.45, buildValueSpecificationWithCurrency(ValueRequirementNames.PRESENT_VALUE), TypeFormatter.Format.CELL, null); assertTrue(result instanceof String); assertEquals(result, "123"); }