diff --git a/src/main/java/pro/fessional/mirana/i18n/I18nNotice.java b/src/main/java/pro/fessional/mirana/i18n/I18nNotice.java index 789d410..bc48710 100644 --- a/src/main/java/pro/fessional/mirana/i18n/I18nNotice.java +++ b/src/main/java/pro/fessional/mirana/i18n/I18nNotice.java @@ -10,7 +10,7 @@ *
* specified message for user to know what and why. * - * - type - notice type, 'BindingValidation', 'IllegalArgument', 'IllegalState' + * - type - notice type, 'Validation', 'IllegalArgument', 'IllegalState' * - target - target input name, 'city', 'tab1.zipcode' * - message - default i18n message * - i18nCode - i18n template code @@ -22,6 +22,15 @@ */ public class I18nNotice extends I18nMessage { + /** + * the notice type that should be able to locate the input + */ + public enum Type { + Validation, + IllegalArgument, + IllegalState, + } + protected String type; protected String target; public String getType() { diff --git a/src/test/java/pro/fessional/mirana/i18n/I18nNoticeTest.java b/src/test/java/pro/fessional/mirana/i18n/I18nNoticeTest.java index c6e77a3..c4b4e24 100644 --- a/src/test/java/pro/fessional/mirana/i18n/I18nNoticeTest.java +++ b/src/test/java/pro/fessional/mirana/i18n/I18nNoticeTest.java @@ -1,6 +1,7 @@ package pro.fessional.mirana.i18n; import org.junit.jupiter.api.Test; +import pro.fessional.mirana.i18n.I18nNotice.Type; import java.util.Locale; @@ -23,11 +24,11 @@ void testI18nNoticeSettersAndGetters() { @Test void testI18nNoticeEquals() { I18nNotice notice1 = new I18nNotice(); - notice1.setType("BindingValidation"); + notice1.setType(Type.IllegalState.name()); notice1.setTarget("city"); I18nNotice notice2 = new I18nNotice(); - notice2.setType("BindingValidation"); + notice2.setType(Type.IllegalState.name()); notice2.setTarget("city"); I18nNotice notice3 = new I18nNotice(); @@ -41,11 +42,11 @@ void testI18nNoticeEquals() { @Test void testI18nNoticeHashCode() { I18nNotice notice1 = new I18nNotice(); - notice1.setType("BindingValidation"); + notice1.setType(Type.IllegalArgument.name()); notice1.setTarget("city"); I18nNotice notice2 = new I18nNotice(); - notice2.setType("BindingValidation"); + notice2.setType(Type.IllegalArgument.name()); notice2.setTarget("city"); assertEquals(notice1.hashCode(), notice2.hashCode()); @@ -54,13 +55,13 @@ void testI18nNoticeHashCode() { @Test void testI18nNoticeToString() { I18nNotice notice = new I18nNotice(); - notice.setType("BindingValidation"); + notice.setType(Type.Validation.name()); notice.setTarget("city"); notice.message = "default message"; notice.i18nCode = "i18n_code"; notice.i18nArgs = new Object[]{ "arg1", "arg2" }; - String expected = "I18nNotice{type='BindingValidation', target='city', message='default message', i18nCode='i18n_code', i18nArgs=[arg1, arg2]} "; + String expected = "I18nNotice{type='Validation', target='city', message='default message', i18nCode='i18n_code', i18nArgs=[arg1, arg2]} "; assertEquals(expected, notice.toString()); }