/** * @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")); }