List of usage examples for org.springframework.context MessageSourceResolvable getCodes
@Nullable String[] getCodes();
From source file:org.openmrs.ui.framework.MockMessageSource.java
@Override public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { return helper(resolvable.getCodes()[0], resolvable.getDefaultMessage()); }
From source file:com.github.pjungermann.config.specification.constraint.InvalidConstraintConfigErrorTest.java
@Test public void getMessage_always_resolvableWithCorrectCodeAndArguments() { InvalidConstraintConfigError error = new InvalidConstraintConfigError(new FakeConstraint(), null); MessageSourceResolvable resolvable = error.getMessage(); String[] codes = resolvable.getCodes(); assertEquals(1, codes.length);/* w ww. ja v a 2s .c o m*/ assertEquals("errors.constraints.config.invalid", codes[0]); assertArrayEquals(new Object[] { "fake-key", "fake", null, new SourceLine(new File("fake"), -1) }, resolvable.getArguments()); assertEquals(codes[0], resolvable.getDefaultMessage()); }
From source file:com.github.pjungermann.config.errors.AbstractConfigFileErrorTest.java
@Test public void getMessage_always_returnsResolvableWithCorrectCodesAndArgsAndDefaultMessage() { MessageSourceResolvable resolvable = error.getMessage(); String[] codes = resolvable.getCodes(); Object[] arguments = resolvable.getArguments(); String defaultMessage = resolvable.getDefaultMessage(); assertEquals(error.getMessageCode(), codes[0]); assertEquals(ConfigFileError.DEFAULT_MESSAGE_CODE, codes[1]); assertArrayEquals(error.getMessageArguments(), arguments); assertEquals(error.getMessageCode(), defaultMessage); }
From source file:com.github.pjungermann.config.specification.types.TypeConversionFailedErrorTest.java
@Test public void getMessage_always_returnMessageResolvableWithCorrectCodes() { TypeConversionFailedError error = new TypeConversionFailedError("fake-key", "fake-value", Long.class, new ClassCastException()); MessageSourceResolvable resolvable = error.getMessage(); assertArrayEquals(new String[] { TypeConversionFailedError.MESSAGE_CODE }, resolvable.getCodes()); assertArrayEquals(new Object[] { error.key, error.value, error.type, error.cause }, resolvable.getArguments());/*from w ww . j a v a 2 s . co m*/ assertEquals(TypeConversionFailedError.MESSAGE_CODE, resolvable.getDefaultMessage()); }
From source file:com.github.pjungermann.config.specification.constraint.multi.NoCollectionErrorTest.java
@Test public void getMessage_always_correctDataUsed() { CollectionKey key = new CollectionKey("fake-key", "fake-collection-key", new IntRange(true, 1, 100), "fake-property"); NoCollectionError error = new NoCollectionError(key, "invalid value"); MessageSourceResolvable resolvable = error.getMessage(); assertNotNull(resolvable);/*from www . j a va2s . co m*/ assertArrayEquals(new String[] { error.getMessageCode() }, resolvable.getCodes()); assertArrayEquals(new Object[] { key.key, key.collectionKey, "invalid value" }, resolvable.getArguments()); assertEquals(error.getMessageCode(), resolvable.getDefaultMessage()); }
From source file:com.github.pjungermann.config.specification.constraint.multi.UnsupportedCollectionEntryPropertyErrorTest.java
@Test public void getMessage_always_correctDataUsed() { CollectionKey key = new CollectionKey("fake-key", "fake-collection-key", new IntRange(true, 1, 100), "fake-property"); UnsupportedCollectionEntryPropertyError error = new UnsupportedCollectionEntryPropertyError(key, "invalid value"); MessageSourceResolvable resolvable = error.getMessage(); assertNotNull(resolvable);//ww w. ja v a 2 s.co m assertArrayEquals(new String[] { error.getMessageCode() }, resolvable.getCodes()); assertArrayEquals(new Object[] { key.key, key.collectionKey, "invalid value" }, resolvable.getArguments()); assertEquals(error.getMessageCode(), resolvable.getDefaultMessage()); }
From source file:com.github.pjungermann.config.specification.constraint.multi.PropertyFieldAccessFailedErrorTest.java
@Test public void getMessage_always_correctDataUsed() { CollectionKey key = new CollectionKey("fake-key", "fake-collection-key", new IntRange(true, 1, 100), "fake-property"); PropertyFieldAccessFailedError error = new PropertyFieldAccessFailedError(key, "invalid value", "fake-field"); MessageSourceResolvable resolvable = error.getMessage(); assertNotNull(resolvable);//from w w w .j av a 2 s. c o m assertArrayEquals(new String[] { error.getMessageCode() }, resolvable.getCodes()); assertArrayEquals(new Object[] { key.key, key.collectionKey, "invalid value", "fake-field" }, resolvable.getArguments()); assertEquals(error.getMessageCode(), resolvable.getDefaultMessage()); }
From source file:com.github.pjungermann.config.specification.constraint.multi.PropertyGetterAccessFailedErrorTest.java
@Test public void getMessage_always_correctDataUsed() { CollectionKey key = new CollectionKey("fake-key", "fake-collection-key", new IntRange(true, 1, 100), "fake-property"); PropertyGetterAccessFailedError error = new PropertyGetterAccessFailedError(key, "invalid value", "fake-getter"); MessageSourceResolvable resolvable = error.getMessage(); assertNotNull(resolvable);/*from w ww. j av a 2 s . c om*/ assertArrayEquals(new String[] { error.getMessageCode() }, resolvable.getCodes()); assertArrayEquals(new Object[] { key.key, key.collectionKey, "invalid value", "fake-getter" }, resolvable.getArguments()); assertEquals(error.getMessageCode(), resolvable.getDefaultMessage()); }
From source file:com.github.pjungermann.config.errors.KeysWithoutSpecificationErrorTest.java
@Test public void getMessage_always_returnCorrectMessage() { List<String> keys = Arrays.asList("key1", "key2", "key3"); KeysWithoutSpecificationError error = new KeysWithoutSpecificationError(keys); MessageSourceResolvable resolvable = error.getMessage(); assertNotNull(resolvable);//from w ww . j ava 2s . com assertArrayEquals(new String[] { error.getMessageCode() }, resolvable.getCodes()); assertArrayEquals(new Object[] { new TreeSet<>(keys) }, resolvable.getArguments()); assertEquals(error.getMessageCode(), resolvable.getDefaultMessage()); }
From source file:com.github.pjungermann.config.specification.constraint.NoSuchConstraintErrorTest.java
@Test public void getMessage_always_useCorrectCodes() { MessageSourceResolvable resolvable = error.getMessage(); assertNotNull(resolvable);/*from w w w. j a v a 2 s. c o m*/ assertArrayEquals(new String[] { NoSuchConstraintError.MESSAGE_CODE }, resolvable.getCodes()); assertArrayEquals(new Object[] { error.name, error.key, error.sourceLine }, resolvable.getArguments()); assertEquals("errors.no_such_constraint", resolvable.getDefaultMessage()); }