org.springframework.validation.DefaultMessageCodesResolver.Format Java Examples
The following examples show how to use
org.springframework.validation.DefaultMessageCodesResolver.Format.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultMessageCodesResolverTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void shouldSupportPostfixFormat() throws Exception { resolver.setMessageCodeFormatter(Format.POSTFIX_ERROR_CODE); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes, is(equalTo(new String[] { "objectName.errorCode", "errorCode" }))); }
Example #2
Source File: DefaultMessageCodesResolverTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void shouldSupportFieldPostfixFormat() throws Exception { resolver.setMessageCodeFormatter(Format.POSTFIX_ERROR_CODE); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field", TestBean.class); assertThat(codes, is(equalTo(new String[] { "objectName.field.errorCode", "field.errorCode", "org.springframework.tests.sample.beans.TestBean.errorCode", "errorCode" }))); }
Example #3
Source File: DefaultMessageCodesResolverTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void shouldSupportCustomFormat() throws Exception { resolver.setMessageCodeFormatter(new MessageCodeFormatter() { @Override public String format(String errorCode, String objectName, String field) { return DefaultMessageCodesResolver.Format.toDelimitedString( "CUSTOM-" + errorCode, objectName, field); } }); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes, is(equalTo(new String[] { "CUSTOM-errorCode.objectName", "CUSTOM-errorCode" }))); }
Example #4
Source File: DefaultMessageCodesResolverTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void shouldSupportPostfixFormat() throws Exception { resolver.setMessageCodeFormatter(Format.POSTFIX_ERROR_CODE); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes, is(equalTo(new String[] { "objectName.errorCode", "errorCode" }))); }
Example #5
Source File: DefaultMessageCodesResolverTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void shouldSupportFieldPostfixFormat() throws Exception { resolver.setMessageCodeFormatter(Format.POSTFIX_ERROR_CODE); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field", TestBean.class); assertThat(codes, is(equalTo(new String[] { "objectName.field.errorCode", "field.errorCode", "org.springframework.tests.sample.beans.TestBean.errorCode", "errorCode" }))); }
Example #6
Source File: DefaultMessageCodesResolverTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void shouldSupportCustomFormat() throws Exception { resolver.setMessageCodeFormatter(new MessageCodeFormatter() { @Override public String format(String errorCode, String objectName, String field) { return DefaultMessageCodesResolver.Format.toDelimitedString( "CUSTOM-" + errorCode, objectName, field); } }); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes, is(equalTo(new String[] { "CUSTOM-errorCode.objectName", "CUSTOM-errorCode" }))); }
Example #7
Source File: DefaultMessageCodesResolverTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void shouldSupportPostfixFormat() throws Exception { resolver.setMessageCodeFormatter(Format.POSTFIX_ERROR_CODE); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes, is(equalTo(new String[] { "objectName.errorCode", "errorCode" }))); }
Example #8
Source File: DefaultMessageCodesResolverTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void shouldSupportFieldPostfixFormat() throws Exception { resolver.setMessageCodeFormatter(Format.POSTFIX_ERROR_CODE); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field", TestBean.class); assertThat(codes, is(equalTo(new String[] { "objectName.field.errorCode", "field.errorCode", "org.springframework.tests.sample.beans.TestBean.errorCode", "errorCode" }))); }
Example #9
Source File: DefaultMessageCodesResolverTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void shouldSupportCustomFormat() throws Exception { resolver.setMessageCodeFormatter(new MessageCodeFormatter() { @Override public String format(String errorCode, String objectName, String field) { return DefaultMessageCodesResolver.Format.toDelimitedString( "CUSTOM-" + errorCode, objectName, field); } }); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes, is(equalTo(new String[] { "CUSTOM-errorCode.objectName", "CUSTOM-errorCode" }))); }
Example #10
Source File: MessageCodesFormat.java From sinavi-jfw with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public String format(String errorCode, String objectName, String field) { return Format.toDelimitedString(objectName, field); }