Package org.apache.tapestry5.annotations

Examples of org.apache.tapestry5.annotations.Mixin


    @SuppressWarnings("unchecked")
    @Test
    public void validator_with_constraint() throws Exception
    {
        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        Messages messages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        Integer five = 5;
        FormSupport fs = mockFormSupport();

        Map<String, Validator> map = singletonMap("minLength", validator);

        train_getConstraintType(validator, Integer.class);

        train_getFormValidationId(fs, "myform");

        train_coerce(coercer, "5", Integer.class, five);

        train_getComponentResources(field, resources);
        train_getId(resources, "fred");
        train_getContainerMessages(resources, containerMessages);
        train_contains(containerMessages, "myform-fred-minLength-message", false);
        train_contains(containerMessages, "fred-minLength-message", false);

        train_getLocale(resources, Locale.FRENCH);

        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);

        train_getMessageKey(validator, "key");
        train_getMessageFormatter(messages, "key", formatter);

        train_isRequired(validator, false);
        train_getValueType(validator, Object.class);
        validator.validate(field, five, formatter, inputValue);

        replay();

        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, null);
View Full Code Here


        }
    }

    private void replaceFieldWithMixin(MutableComponentModel model, PlasticField field)
    {
        Mixin annotation = field.getAnnotation(Mixin.class);

        field.claim(annotation);

        String mixinType = annotation.value();

        String[] order = annotation.order();

        String fieldType = field.getTypeName();

        String mixinClassName = InternalUtils.isBlank(mixinType) ? fieldType : resolver
                .resolveMixinTypeToClassName(mixinType);
View Full Code Here

        }
    }

    private void replaceFieldWithMixin(MutableComponentModel model, TransformField field)
    {
        Mixin annotation = field.getAnnotation(Mixin.class);

        field.claim(annotation);

        String mixinType = annotation.value();

        String[] order = annotation.order();

        String fieldType = field.getType();

        String mixinClassName = InternalUtils.isBlank(mixinType) ? fieldType : resolver
                .resolveMixinTypeToClassName(mixinType);
View Full Code Here

    {
        List<String> fields = transformation.findFieldsWithAnnotation(Mixin.class);

        for (String fieldName : fields)
        {
            Mixin annotation = transformation.getFieldAnnotation(fieldName, Mixin.class);

            String mixinType = annotation.value();

            String fieldType = transformation.getFieldType(fieldName);

            String mixinClassName = InternalUtils.isBlank(mixinType) ? fieldType : resolver
                    .resolveMixinTypeToClassName(mixinType);
View Full Code Here

    public void field_with_explicit_type()
    {
        ComponentClassResolver resolver = mockComponentClassResolver();
        ClassTransformation transformation = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        Mixin annotation = newMixin("Bar");

        train_findFieldsWithAnnotation(transformation, Mixin.class, "fred");
        train_getFieldAnnotation(transformation, "fred", Mixin.class, annotation);
        train_getFieldType(transformation, "fred", "foo.bar.Baz");
View Full Code Here

    public void field_with_no_specific_mixin_type()
    {
        ComponentClassResolver resolver = mockComponentClassResolver();
        ClassTransformation transformation = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        Mixin annotation = newMixin("");

        train_findFieldsWithAnnotation(transformation, Mixin.class, "fred");
        train_getFieldAnnotation(transformation, "fred", Mixin.class, annotation);
        train_getFieldType(transformation, "fred", "foo.bar.Baz");
View Full Code Here

        expect(resolver.resolveMixinTypeToClassName(mixinType)).andReturn(mixinClassName);
    }

    private Mixin newMixin(String value)
    {
        Mixin annotation = newMock(Mixin.class);

        expect(annotation.value()).andReturn(value);

        return annotation;
    }
View Full Code Here

    {
        List<String> fields = transformation.findFieldsWithAnnotation(Mixin.class);

        for (String fieldName : fields)
        {
            Mixin annotation = transformation.getFieldAnnotation(fieldName, Mixin.class);

            transformation.claimField(fieldName, annotation);
           
            String mixinType = annotation.value();

            String fieldType = transformation.getFieldType(fieldName);

            String mixinClassName = InternalUtils.isBlank(mixinType) ? fieldType : resolver
                    .resolveMixinTypeToClassName(mixinType);
View Full Code Here

                {
                    setupRequestFromLink(link);
                    continue;
                }

                Document result = response.getRenderedDocument();

                if (result == null)
                    throw new RuntimeException(String.format("Render of page '%s' did not result in a Document.",
                            pageName));
View Full Code Here

                {
                    setupRequestFromLink(link);
                    continue;
                }

                Document result = response.getRenderedDocument();

                if (result == null)
                    throw new RuntimeException(String.format("Render request '%s' did not result in a Document.",
                            request.getPath()));
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.annotations.Mixin

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.