use of freemarker.core.TemplateNumberFormat in project robozonky by RoboZonky.
the class InterestNumberFormatFactoryTest method formal.
@Test
void formal() throws TemplateValueFormatException {
final TemplateNumberFormat f = InterestNumberFormatFactory.INSTANCE.get("", Locale.ENGLISH, Environment.getCurrentEnvironment());
assertSoftly(softly -> {
softly.assertThat(f.isLocaleBound()).isTrue();
softly.assertThat(f.getDescription()).isNotNull().isNotEmpty();
softly.assertThatThrownBy(() -> InterestNumberFormatFactory.INSTANCE.get("someparam", Locale.ENGLISH, Environment.getCurrentEnvironment())).isInstanceOf(InvalidFormatParametersException.class);
});
}
use of freemarker.core.TemplateNumberFormat in project robozonky by RoboZonky.
the class InterestNumberFormatFactoryTest method formattingCzech.
@DisabledOnJre(JRE.JAVA_8)
@Test
void formattingCzech() throws TemplateValueFormatException, TemplateModelException {
final BigDecimal n = new BigDecimal("0.0001");
final TemplateNumberFormat f = InterestNumberFormatFactory.INSTANCE.get("", Defaults.LOCALE, Environment.getCurrentEnvironment());
final TemplateNumberModel m = () -> n;
final String result = f.formatToPlainText(m);
assertThat(result.trim()).isEqualTo("0,01" + (char) 160 + "%");
}
use of freemarker.core.TemplateNumberFormat in project robozonky by RoboZonky.
the class InterestNumberFormatFactoryTest method formattingCzech2.
@DisabledOnJre(JRE.JAVA_8)
@Test
void formattingCzech2() throws TemplateValueFormatException, TemplateModelException {
final BigDecimal n = new BigDecimal("0.0000");
final TemplateNumberFormat f = InterestNumberFormatFactory.INSTANCE.get("", Defaults.LOCALE, Environment.getCurrentEnvironment());
final TemplateNumberModel m = () -> n;
final String result = f.formatToPlainText(m);
assertThat(result.trim()).isEqualTo("0" + (char) 160 + "%");
}
use of freemarker.core.TemplateNumberFormat in project robozonky by RoboZonky.
the class InterestNumberFormatFactoryTest method formattingCzech3.
@DisabledOnJre(JRE.JAVA_8)
@Test
void formattingCzech3() throws TemplateValueFormatException, TemplateModelException {
final BigDecimal n = new BigDecimal("0.001");
final TemplateNumberFormat f = InterestNumberFormatFactory.INSTANCE.get("", Defaults.LOCALE, Environment.getCurrentEnvironment());
final TemplateNumberModel m = () -> n;
final String result = f.formatToPlainText(m);
assertThat(result.trim()).isEqualTo("0,1" + (char) 160 + "%");
}
use of freemarker.core.TemplateNumberFormat in project robozonky by RoboZonky.
the class InterestNumberFormatFactoryTest method formattingEnglish.
@Test
void formattingEnglish() throws TemplateValueFormatException, TemplateModelException {
final BigDecimal n = new BigDecimal("0.0001");
final TemplateNumberFormat f = InterestNumberFormatFactory.INSTANCE.get("", Locale.ENGLISH, Environment.getCurrentEnvironment());
final TemplateNumberModel m = () -> n;
final Object result = f.formatToPlainText(m);
assertThat(result).isEqualTo("0.01%");
}
Aggregations