Package org.apache.myfaces.extensions.cdi.message.api

Examples of org.apache.myfaces.extensions.cdi.message.api.Message


   }
   
    @Test
   public void createMessageWithHiddenArgumentsTest()
   {
       Message message = new TestMessage("{xyz123}").addArgument("123", 456, "789");

       assertEquals("???xyz123??? (123,456,789)", message.toString(this.messageContext));
   }
View Full Code Here


    }

    @Test
    public void directTextResolvingTest()
    {
        Message message = this.messageContext.message().text("{hello}").create();
        String messageText = message.toString(this.messageContext);

        checkDefaultHelloMessage(messageText);
    }
View Full Code Here

public class MessageSeverityTest extends AbstractMessageContextAwareTest
{
    @Test
    public void createMessageWithDefaultSeverityTest()
    {
        Message message = this.messageContext.message().text("hello open message").create();

        assertNotNull(message);
        assertTrue(message.getPayload().containsKey(MessageSeverity.class));
        assertTrue(message.getPayload().containsValue(MessageSeverity.INFO));

        assertTrue(message instanceof MessageWithSeverity);
        assertTrue(MessageSeverity.INFO.equals(((MessageWithSeverity) message).getSeverity()));
    }
View Full Code Here

    }

    @Test
    public void createMessageWithSeverityWarnTest()
    {
        Message message = this.messageContext.message().text("hello open message").payload(MessageSeverity.WARN).create();

        assertNotNull(message);
        assertTrue(message.getPayload().containsKey(MessageSeverity.class));
        assertTrue(message.getPayload().containsValue(MessageSeverity.WARN));

        assertTrue(message instanceof MessageWithSeverity);
        assertTrue(MessageSeverity.WARN.equals(((MessageWithSeverity) message).getSeverity()));
    }
View Full Code Here

    public void namedArgumentBuilderTest()
    {
        Number arg1 = new BigDecimal("123.4567");
        Date arg2 = new Date();
        String text = "#1: {arg1} and #2: {arg2}";
        Message message1 = this.messageContext.message().text(text)
                .namedArgument("arg1", arg1).namedArgument("arg2", arg2).create();

        Message message2 = new DefaultMessage(text)
                .addArgument(NamedArguments.add("arg1", arg1).add("arg2", arg2).create());
        ((MessageContextConfigAware)message2).setMessageContextConfig(this.messageContext.config());

        assertEquals(message1, message2);
        assertEquals(message1.toString(), message2.toString());
        assertEquals(message1.toString(this.messageContext), message2.toString(this.messageContext));
    }
View Full Code Here

    public void convertNamedArgumentTest()
    {
        Number arg1 = new BigDecimal("123.4567");
        Date arg2 = new Date();
        String text = "#1: {arg1} and #2: {arg2}";
        Message message1 = this.messageContext.message().text(text)
                .namedArgument("arg1", arg1).namedArgument("arg2", arg2).create();

        Map<String, Serializable> arguments = new HashMap<String, Serializable>();
        arguments.put("arg1", arg1);
        arguments.put("arg2", arg2);
        Message message2 = new DefaultMessage(text).addArgument(NamedArguments.convert(arguments));
        ((MessageContextConfigAware)message2).setMessageContextConfig(this.messageContext.config());

        assertEquals(message1, message2);
        assertEquals(message1.toString(), message2.toString());
        assertEquals(message1.toString(this.messageContext), message2.toString(this.messageContext));
    }
View Full Code Here

    }

    @Test
    public void customMessageTypeViaCustomMessageBuilder1Test()
    {
        Message message = TestMessageBuilder.label().text("{hello}").create();

        assertEquals("test label", message.toString(this.messageContext));
    }
View Full Code Here

    }

    @Test
    public void customMessageTypeViaCustomMessageBuilder2Test()
    {
        Message message = TestMessageBuilder.technicalMessage().text("{hello}").create();

        assertEquals("hello codi", message.toString(this.messageContext));
    }
View Full Code Here

    }

    @Test
    public void newMessageFactoryTestViaMessageContext()
    {
        Message message = DefaultMessageContext.create(new TestMessageFactory()).message().text("{hello}").create();

        assertEquals(TestMessage.class, message.getClass());
    }
View Full Code Here

    }

    @Test
    public void newMessageFactoryTestViaMessageBuilder()
    {
        Message message = SimpleMessageBuilder.message(new TestMessageFactory()).text("{hello}").create();

        assertEquals(TestMessage.class, message.getClass());
    }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.extensions.cdi.message.api.Message

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.