use of org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto in project pentaho-platform by pentaho.
the class ZipExportProcessor method getAvailableLocales.
/**
* lookup the list of available locale values
*
* @param fileId
* @return
*/
private List<LocaleMapDto> getAvailableLocales(Serializable fileId) {
List<LocaleMapDto> availableLocales = new ArrayList<LocaleMapDto>();
List<Locale> locales = getUnifiedRepository().getAvailableLocalesForFileById(fileId);
if (locales != null && !locales.isEmpty()) {
for (Locale locale : locales) {
availableLocales.add(new LocaleMapDto(locale.toString(), null));
}
}
return availableLocales;
}
use of org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetFileLocalesError.
@Test
public void testDoGetFileLocalesError() throws Exception {
Messages mockMessages = mock(Messages.class);
doReturn(mockMessages).when(fileResource).getMessagesInstance();
// Test 1
Exception mockFileNotFoundException = mock(FileNotFoundException.class);
doThrow(mockFileNotFoundException).when(fileResource.fileService).doGetFileLocales(PATH_ID);
List<LocaleMapDto> testLocales = fileResource.doGetFileLocales(PATH_ID);
assertEquals(0, testLocales.size());
// Test 2
Throwable mockThrowable = mock(RuntimeException.class);
doThrow(mockThrowable).when(fileResource.fileService).doGetFileLocales(PATH_ID);
testLocales = fileResource.doGetFileLocales(PATH_ID);
assertEquals(0, testLocales.size());
verify(fileResource, times(2)).getMessagesInstance();
verify(mockMessages, times(1)).getErrorString("FileResource.FILE_NOT_FOUND", PATH_ID);
verify(mockMessages, times(1)).getString("SystemResource.GENERAL_ERROR");
}
Aggregations