use of freemarker.template.SimpleScalar in project ninja by ninjaframework.
the class TemplateEngineFreemarkerI18nMethodTest method testThatKeyWithPlaceholderReturnsDefaultKeyWhenKeyCannotBeFound.
@Test
public void testThatKeyWithPlaceholderReturnsDefaultKeyWhenKeyCannotBeFound() throws Exception {
Optional<Result> resultOptional = Optional.of(result);
List args = new ArrayList();
args.add(new SimpleScalar("my.message.key"));
args.add(new SimpleScalar("1000"));
Mockito.when(messages.get(Matchers.eq("my.message.key"), Matchers.eq(context), Matchers.eq(resultOptional), Matchers.any(Object.class))).thenReturn(Optional.<String>empty());
TemplateModel returnValue = templateEngineFreemarkerI18nMethod.exec(args);
assertThat(((SimpleScalar) returnValue).getAsString(), CoreMatchers.equalTo("my.message.key"));
// There must have been logged something because we did not find
// the value for the key...
Mockito.verify(mockAppender).doAppend(Matchers.anyObject());
}
use of freemarker.template.SimpleScalar in project ninja by ninjaframework.
the class TemplateEngineFreemarkerI18nMethodTest method testThatSingleKeyWithValueWorks.
@Test
public void testThatSingleKeyWithValueWorks() throws Exception {
Optional<Result> resultOptional = Optional.of(result);
Mockito.when(messages.get("my.message.key", context, resultOptional)).thenReturn(Optional.of("This simulates the translated message!"));
List args = new ArrayList();
args.add(new SimpleScalar("my.message.key"));
TemplateModel returnValue = templateEngineFreemarkerI18nMethod.exec(args);
assertThat(((SimpleScalar) returnValue).getAsString(), CoreMatchers.equalTo("This simulates the translated message!"));
Mockito.verify(mockAppender, Mockito.never()).doAppend(Matchers.anyObject());
}
use of freemarker.template.SimpleScalar in project ninja by ninjaframework.
the class TemplateEngineFreemarkerPrettyTimeMethod method exec.
@Override
public TemplateModel exec(List args) throws TemplateModelException {
Date date = getFormattableObject(args.get(0));
String result = prettyTime.format(date);
return new SimpleScalar(result);
}
use of freemarker.template.SimpleScalar in project android by JetBrains.
the class FmUnderscoreToCamelCaseMethodTest method check.
@SuppressWarnings("rawtypes")
private void check(String s, String expected) throws TemplateModelException {
FmUnderscoreToCamelCaseMethod method = new FmUnderscoreToCamelCaseMethod();
List list = Collections.singletonList(new SimpleScalar(s));
assertEquals(expected, ((SimpleScalar) method.exec(list)).getAsString());
}
use of freemarker.template.SimpleScalar in project android by JetBrains.
the class FmClassNameToResourceMethodTest method check.
@SuppressWarnings("rawtypes")
private void check(String s, String expected) throws TemplateModelException {
FmClassNameToResourceMethod method = new FmClassNameToResourceMethod();
List list = Collections.singletonList(new SimpleScalar(s));
assertEquals(expected, ((SimpleScalar) method.exec(list)).getAsString());
}
Aggregations