Package yalp.data.validation

Source Code of yalp.data.validation.ValidationTest

package yalp.data.validation;

import org.junit.Test;
import yalp.i18n.MessagesBuilder;

import static org.fest.assertions.Assertions.assertThat;

public class ValidationTest {

    @Test
    public void verifyError() {

        new MessagesBuilder().build();

        Validation.current.set(new Validation());

        final String field = "f1";

        assertThat(Validation.error(field)).isNull();
        assertThat(Validation.errors(field)).isEmpty();

        final String errorMsg = "My errorMessage";

        Validation.addError(field, errorMsg);

        assertThat(Validation.error(field).message).isEqualTo(errorMsg);
        assertThat(Validation.errors(field)).containsOnly(Validation.error(field));

        // ticket [#109] - add an error with null-key
        Validation.addError(null, errorMsg);
        // make sure this null key does not break stuff
        assertThat(Validation.error(field).message).isEqualTo(errorMsg);
        assertThat(Validation.errors(field)).containsOnly(Validation.error(field));

    }

}
TOP

Related Classes of yalp.data.validation.ValidationTest

TOP
Copyright © 2018 www.massapi.com. 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.