use of com.google.firestore.admin.v1.Field in project tapestry-5 by apache.
the class RequiredTest method blank_value.
@Test
public void blank_value() {
MessageFormatter formatter = mockMessageFormatter();
Field field = mockFieldWithLabel("My Field");
train_format(formatter, "{message}", "My Field");
Html5Support html5Support = mockHtml5Support();
replay();
try {
new Required(null, html5Support).validate(field, null, formatter, "");
unreachable();
} catch (ValidationException ex) {
assertEquals(ex.getMessage(), "{message}");
}
verify();
}
use of com.google.firestore.admin.v1.Field in project tapestry-5 by apache.
the class RequiredTest method empty_collection_value.
@Test
public void empty_collection_value() {
MessageFormatter formatter = mockMessageFormatter();
Field field = mockFieldWithLabel("My Field");
train_format(formatter, "{message}", "My Field");
Html5Support html5Support = mockHtml5Support();
replay();
try {
new Required(null, html5Support).validate(field, null, formatter, Arrays.asList());
unreachable();
} catch (ValidationException ex) {
assertEquals(ex.getMessage(), "{message}");
}
verify();
}
use of com.google.firestore.admin.v1.Field in project tapestry-5 by apache.
the class RequiredTest method non_blank_value.
@Test
public void non_blank_value() throws Exception {
MessageFormatter formatter = mockMessageFormatter();
Field field = mockField();
Html5Support html5Support = mockHtml5Support();
replay();
new Required(null, html5Support).validate(field, null, formatter, "not null");
verify();
}
use of com.google.firestore.admin.v1.Field in project tapestry-5 by apache.
the class RequiredTest method not_empty_collection_value.
@Test
public void not_empty_collection_value() throws Exception {
MessageFormatter formatter = mockMessageFormatter();
Field field = mockField();
Html5Support html5Support = mockHtml5Support();
replay();
new Required(null, html5Support).validate(field, null, formatter, Arrays.asList("A", "B"));
verify();
}
use of com.google.firestore.admin.v1.Field in project tapestry-5 by apache.
the class FieldTranslatorSourceImplTest method create_default_translator_with_name_and_null_key.
@Test
public void create_default_translator_with_name_and_null_key() {
Field field = mockField();
Messages messages = mockMessages();
Locale locale = Locale.ENGLISH;
Class propertyType = Map.class;
TranslatorSource ts = mockTranslatorSource();
FormSupport fs = mockFormSupport();
Translator translator = mockTranslator("maptrans", Map.class);
Messages globalMessages = mockMessages();
MessageFormatter formatter = mockMessageFormatter();
MarkupWriter writer = mockMarkupWriter();
String label = "Field Label";
String message = "Woops, did it again.";
AnnotationProvider ap = mockAnnotationProvider(null);
train_findByType(ts, propertyType, translator);
train_getFormValidationId(fs, "myform");
train_contains(messages, "myform-myfield-maptrans-message", false);
train_contains(messages, "myfield-maptrans-message", false);
train_getMessageKey(translator, null);
train_getMessageFormatter(globalMessages, "maptrans-message", formatter);
train_getLabel(field, label);
train_format(formatter, message, label);
translator.render(field, message, writer, fs);
replay();
FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, globalMessages, fs);
FieldTranslator ft = source.createDefaultTranslator(field, "myfield", messages, locale, propertyType, ap);
assertEquals(ft.getType(), Map.class);
ft.render(writer);
verify();
}
Aggregations