/** * @verifies return a localized message if specified */ @Test public void getDisplayString_shouldReturnALocalizedMessageIfSpecified() throws Exception { String UUID = "0cbe2ed3-cd5f-4f46-9459-26127c9265ab"; MessageSourceService messageSourceService = mock(MessageSourceService.class); when(messageSourceService.getMessage("ui.i18n.Location.name." + UUID)).thenReturn("Correct"); ServiceContext.getInstance().setMessageSourceService(messageSourceService); Location location = new Location(); location.setName("Incorrect"); location.setUuid(UUID); MockLocationResource resource = new MockLocationResource(); String display = resource.getDisplayString(location); assertThat(display, is("Correct")); }
/** * @verifies return the empty string when no localized message is specified and the name * property is null */ @Test public void getDisplayString_shouldReturnTheEmptyStringWhenNoLocalizedMessageIsSpecifiedAndTheNamePropertyIsNull() throws Exception { Location location = new Location(); location.setName(null); MockLocationResource resource = new MockLocationResource(); String display = resource.getDisplayString(location); assertThat(display, is("")); }
/** * @verifies return the name property when no localized message is specified */ @Test public void getDisplayString_shouldReturnTheNamePropertyWhenNoLocalizedMessageIsSpecified() throws Exception { Location location = new Location(); location.setName("Correct"); MockLocationResource resource = new MockLocationResource(); String display = resource.getDisplayString(location); assertThat(display, is("Correct")); }