### Question:
DefaultObjectMessageSource extends DelegatingMessageSource implements ObjectMessageSource { public String getMessage(Object object, Object[] args, Locale locale) throws NoSuchObjectMessageException { String message = getFullyResolvedMessage(object, args, locale, false); if (message == null && object != null) { throw new NoSuchObjectMessageException(object, locale); } return message; } DefaultObjectMessageSource();  DefaultObjectMessageSource(MessageSource parent); String getMessage(Object object, Object[] args, Locale locale);  }### Answer:
@Test public void shouldGetMappedMessage() throws Exception { String actual = this.messageSource.getMessage(new Mapped(), null, LOCALE); assertThat(actual, is("mapped")); }
@Test public void shouldGetNullMessageForNullObject() throws Exception { String actual = this.messageSource.getMessage((Object) null, null, LOCALE); assertThat(actual, is(nullValue())); }
@Test public void shouldGetMessageForEnum() throws Exception { String actual = this.messageSource.getMessage(NumberEnum.ONE, null, LOCALE); assertThat(actual, is("1")); }
@Test public void shouldGetMessageForBooleanTrue() throws Exception { String actual = this.messageSource.getMessage(true, null, LOCALE); assertThat(actual, is("Yes")); }
@Test public void shouldGetMessageForBooleanFalse() throws Exception { String actual = this.messageSource.getMessage(Boolean.FALSE, null, LOCALE); assertThat(actual, is("No")); }
@Test public void shouldGetMessageWithExpandedArguments() throws Exception { String actual = this.messageSource.getMessage(new MappedArguments("x", NumberEnum.ONE, true), null, LOCALE); assertThat(actual, is("a x b 1 c Yes")); }
@Test public void shouldGetMessageWithExpandedNullArgument() throws Exception { String actual = this.messageSource.getMessage(new MappedArguments(null, NumberEnum.ONE, true), null, LOCALE); assertThat(actual, is("a b 1 c Yes")); }
@Test public void shouldGetMessageWithExpandedArrayArguments() throws Exception { String actual = this.messageSource.getMessage(new MappedArray(1, 2, 3, 4), null, LOCALE); assertThat(actual, is("numbers 1,2,3,4")); }
@Test public void shouldGetMessageWithExpandedCollectionArguments() throws Exception { String actual = this.messageSource.getMessage(new MappedCollection(NumberEnum.ONE, 2, 3, 4), null, LOCALE); assertThat(actual, is("collection 1,2,3,4")); }
@Test public void shouldLeaveUnmachedParameters() throws Exception { String actual = this.messageSource.getMessage(new MappedWithMissingParameters(), null, LOCALE); assertThat(actual, is("mapped {missing}")); }
@Test public void shouldThrowNoSuchObjectExceptionIfNotMapped() throws Exception { this.thrown.expect(NoSuchObjectMessageException.class); this.thrown.expectMessage("Unable to convert object of type " + INNER + "NotMapped to a message for locale en_GB"); this.messageSource.getMessage(new NotMapped(), null, LOCALE); }
@Test public void shouldResolveMessageWithArguments() throws Exception { String actual = this.messageSource.getMessage(new MappedWithArguments(), new Object[] { 1, 2 }, LOCALE); assertThat(actual, is("mapped args 2 1")); }