Package org.springframework.binding.validation.support

Examples of org.springframework.binding.validation.support.DefaultValidationMessage


        assertContainsMessage(vm, vr.getMessages(Severity.INFO));
        assertEquals(false, vr.getHasErrors());
        assertEquals(false, vr.getHasWarnings());
        assertEquals(true, vr.getHasInfo());

        vm = new DefaultValidationMessage("field2", Severity.WARNING, "message");
        vr.addMessage(vm);
        assertEquals(2, vr.getMessageCount());
        assertEquals(1, vr.getMessageCount(Severity.WARNING));
        assertEquals(1, vr.getMessageCount("field2"));
        assertContainsMessage(vm, vr.getMessages());
        assertContainsMessage(vm, vr.getMessages("field2"));
        assertContainsMessage(vm, vr.getMessages(Severity.WARNING));
        assertEquals(false, vr.getHasErrors());
        assertEquals(true, vr.getHasWarnings());
        assertEquals(true, vr.getHasInfo());

        vm = new DefaultValidationMessage(ValidationMessage.GLOBAL_PROPERTY, Severity.ERROR, "message");
        vr.addMessage(vm);
        assertEquals(3, vr.getMessageCount());
        assertEquals(1, vr.getMessageCount(Severity.ERROR));
        assertEquals(1, vr.getMessageCount(ValidationMessage.GLOBAL_PROPERTY));
        assertContainsMessage(vm, vr.getMessages());
        assertContainsMessage(vm, vr.getMessages(ValidationMessage.GLOBAL_PROPERTY));
        assertContainsMessage(vm, vr.getMessages(Severity.ERROR));
        assertEquals(true, vr.getHasErrors());
        assertEquals(true, vr.getHasWarnings());
        assertEquals(true, vr.getHasInfo());

        vm = new DefaultValidationMessage("field1", Severity.ERROR, "message");
        vr.addMessage(vm);
        assertEquals(4, vr.getMessageCount());
        assertEquals(2, vr.getMessageCount(Severity.ERROR));
        assertEquals(2, vr.getMessageCount("field1"));
        assertContainsMessage(vm, vr.getMessages());
        assertContainsMessage(vm, vr.getMessages("field1"));
        assertContainsMessage(vm, vr.getMessages(Severity.ERROR));

        DefaultValidationResults vr2 = new DefaultValidationResults();
        vm = new DefaultValidationMessage("newField", Severity.INFO, "message");
        vr2.addMessage(vm);
        ValidationMessage vm2 = new DefaultValidationMessage("newField", Severity.ERROR, "message");
        vr2.addMessage(vm2);

        vr.addAllMessages(vr2.getMessages());
        assertEquals(6, vr.getMessageCount());
        assertEquals(3, vr.getMessageCount(Severity.ERROR));
View Full Code Here


        assertContainsMessage(vm, vr.getMessages(Severity.INFO));
        assertContainsMessage(vm2, vr.getMessages(Severity.ERROR));
    }

    public void testCanNotAddSameMessage() {
        ValidationMessage vm = new DefaultValidationMessage("field2", Severity.WARNING, "message");
        vr.addMessage(vm);
        assertEquals(1, vr.getMessageCount());
        assertEquals(1, vr.getMessageCount(Severity.WARNING));
        assertEquals(1, vr.getMessageCount("field2"));

        vr.addMessage(vm);
        assertEquals(1, vr.getMessageCount());
        assertEquals(1, vr.getMessageCount(Severity.WARNING));
        assertEquals(1, vr.getMessageCount("field2"));

        vm = new DefaultValidationMessage("field2", Severity.WARNING, "message");
        vr.addMessage(vm);
        assertEquals(1, vr.getMessageCount());
        assertEquals(1, vr.getMessageCount(Severity.WARNING));
        assertEquals(1, vr.getMessageCount("field2"));
View Full Code Here

import junit.framework.TestCase;

public class DefaultValidationMessageTests extends TestCase {

    public void testDefaultValidationMessage() {
        ValidationMessage vm = new DefaultValidationMessage("property", Severity.INFO, "message");
        assertEquals("property", vm.getProperty());
        assertEquals(Severity.INFO, vm.getSeverity());
        assertEquals("message", vm.getMessage());
    }
View Full Code Here

        assertEquals(Severity.INFO, vm.getSeverity());
        assertEquals("message", vm.getMessage());
    }
   
    public void testToString() {
        ValidationMessage vm = new DefaultValidationMessage("property", Severity.INFO, "message");
        assertTrue(vm.toString().endsWith("property = \'property\', severity = \'info\', message = \'message\']"));
    }
View Full Code Here

TOP

Related Classes of org.springframework.binding.validation.support.DefaultValidationMessage

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.