Package com.sirenian.hellbound.domain

Examples of com.sirenian.hellbound.domain.Segments$Translator


        ComponentResources resources = mockComponentResources();
        FieldComponent field = mockFieldComponent();
        Messages messages = mockMessages();
        TranslatorSource ts = mockTranslatorSource();
        FormSupport fs = mockFormSupport();
        Translator translator = mockTranslator("map", Map.class);
        Messages globalMessages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        MarkupWriter writer = mockMarkupWriter();
        String label = "My Label";
        String message = "Formatted Message";

        train_getComponent(resources, field);
        train_getId(resources, "myfield");
        train_getContainerMessages(resources, messages);

        train_get(ts, "map", translator);

        train_getFormValidationId(fs, "myform");

        train_contains(messages, "myform-myfield-map-message", false);
        train_contains(messages, "myfield-map-message", false);
        train_getMessageKey(translator, "mykey");
        train_getMessageFormatter(globalMessages, "mykey", formatter);

        train_getLabel(field, label);
        train_format(formatter, message, label);

        translator.render(field, message, writer, fs);

        replay();

        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, globalMessages, fs);
View Full Code Here


        return newMock(FieldTranslator.class);
    }

    protected final Translator mockTranslator(String name, Class type)
    {
        Translator translator = mockTranslator();

        train_getName(translator, name);
        train_getType(translator, type);

        return translator;
View Full Code Here

        Defense.notNull(locale, "locale");


        if (propertyType == null) return null;

        Translator translator = translatorSource.findByType(propertyType);

        if (translator == null) return null;

        return createTranslator(field, overrideId, overrideMessages, locale, translator);
    }
View Full Code Here

        Defense.notNull(resources, "resources");
        Defense.notBlank(translatorName, "translatorName");

        Field field = (Field) resources.getComponent();

        Translator translator = translatorSource.get(translatorName);

        return createTranslator(field, resources.getId(), resources.getContainerMessages(), resources.getLocale(),
                                translator);
    }
View Full Code Here

    }

    @Test
    public void found_translator_by_name()
    {
        Translator translator = mockTranslator("mock", String.class);

        replay();

        TranslatorSource source = new TranslatorSourceImpl(newConfiguration(String.class, translator));
View Full Code Here

    }

    @Test
    public void key_and_type_mismatch()
    {
        Translator t = mockTranslator();

        train_getType(t, Long.class);

        replay();
View Full Code Here

    }

    @Test
    public void name_collision_with_standard_translators()
    {
        Translator t1 = mockTranslator("fred", Integer.class);
        Translator t2 = mockTranslator("fred", Long.class);

        Map<Class, Translator> configuration = CollectionFactory.newMap();
        configuration.put(Integer.class, t1);
        configuration.put(Long.class, t2);
View Full Code Here

    }

    @Test
    public void get_alternate_translator_by_name()
    {
        Translator t1 = mockTranslator("fred", Integer.class);
        Translator t2 = mockTranslator();

        Map<Class, Translator> configuration = newConfiguration(Integer.class, t1);

        Map<String, Translator> alternates = CollectionFactory.newMap();
        alternates.put("barney", t2);
View Full Code Here

    }

    @Test
    public void name_collision_between_standard_and_alternate_translator()
    {
        Translator t1 = mockTranslator("fred", Integer.class);
        Translator t2 = mockTranslator();

        Map<Class, Translator> configuration = newConfiguration(Integer.class, t1);

        Map<String, Translator> alternates = CollectionFactory.newMap();
        alternates.put("fred", t2);
View Full Code Here

    }

    @Test
    public void unknown_translator_is_failure()
    {
        Translator fred = mockTranslator("fred", String.class);
        Translator barney = mockTranslator("barney", Long.class);

        Map<Class, Translator> configuration = CollectionFactory.newMap();

        configuration.put(String.class, fred);
        configuration.put(Long.class, barney);
View Full Code Here

TOP

Related Classes of com.sirenian.hellbound.domain.Segments$Translator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.