use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileServiceIT method getMockedRepositoryFileDtoList.
public List<RepositoryFileDto> getMockedRepositoryFileDtoList(String[] fileNames) {
List<RepositoryFileDto> repoFileDtoList = new ArrayList<>();
for (String fileName : fileNames) {
RepositoryFileDto repoFileDto = mock(RepositoryFileDto.class);
when(repoFileDto.getName()).thenReturn(fileName);
when(repoFileDto.getId()).thenReturn(fileName);
repoFileDtoList.add(repoFileDto);
}
return repoFileDtoList;
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileServiceIT method testDoGetFileAcl.
@Test
public void testDoGetFileAcl() {
RepositoryFileDto file = mock(RepositoryFileDto.class);
RepositoryFileAclDto fileAcl = mock(RepositoryFileAclDto.class);
when(fileAcl.isEntriesInheriting()).thenReturn(false);
when(fileService.defaultUnifiedRepositoryWebService.getFile(nullable(String.class))).thenReturn(file);
when(fileService.defaultUnifiedRepositoryWebService.getAcl(nullable(String.class))).thenReturn(fileAcl);
doNothing().when(fileService).addAdminRole(fileAcl);
String pathId = "/usr/dir/file.txt";
fileService.doGetFileAcl(pathId);
verify(fileService).addAdminRole(fileAcl);
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileServiceIT method testDoSetLocalProperties.
@Test
public void testDoSetLocalProperties() throws Exception {
String pathId = "path:to:file:file1.ext";
String fileId = "file1";
String locale = "";
doReturn("/path/to/file/file1.ext").when(fileService).idToPath(pathId);
RepositoryFileDto repositoryFileDto = mock(RepositoryFileDto.class);
doReturn(fileId).when(repositoryFileDto).getId();
doReturn(repositoryFileDto).when(fileService.defaultUnifiedRepositoryWebService).getFile(nullable(String.class));
Properties fileProperties = mock(Properties.class);
doReturn(false).when(fileProperties).isEmpty();
List<StringKeyStringValueDto> properties = new ArrayList<StringKeyStringValueDto>();
properties.add(new StringKeyStringValueDto("key1", "value1"));
properties.add(new StringKeyStringValueDto("key2", "value2"));
fileService.doSetLocaleProperties(pathId, locale, properties);
verify(fileService.defaultUnifiedRepositoryWebService).getFile("/path/to/file/file1.ext");
verify(fileService.defaultUnifiedRepositoryWebService).setLocalePropertiesForFileByFileId(nullable(String.class), nullable(String.class), any(Properties.class));
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileServiceIT method doGetDeletedFiles.
@Test
public void doGetDeletedFiles() {
RepositoryFileDto repositoryFileDto = mock(RepositoryFileDto.class);
RepositoryFileDto repositoryFileDto1 = mock(RepositoryFileDto.class);
List<RepositoryFileDto> fileDtos = new ArrayList<RepositoryFileDto>();
fileDtos.add(repositoryFileDto);
fileDtos.add(repositoryFileDto1);
// Test 1
doReturn(fileDtos).when(fileService.defaultUnifiedRepositoryWebService).getDeletedFiles();
List<RepositoryFileDto> repositoryFiles = fileService.doGetDeletedFiles();
assertEquals(2, repositoryFiles.size());
// Test 2
doReturn(null).when(fileService.defaultUnifiedRepositoryWebService).getDeletedFiles();
repositoryFiles = fileService.doGetDeletedFiles();
assertEquals(null, repositoryFiles);
verify(fileService.defaultUnifiedRepositoryWebService, times(2)).getDeletedFiles();
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileServiceIT method testDoGetLocalProperties.
@Test
public void testDoGetLocalProperties() throws Exception {
String pathId = "path:to:file:file1.ext";
String fileId = "file1";
String locale = "";
doReturn("/path/to/file/file1.ext").when(fileService).idToPath(pathId);
Set<String> propertiesList = new HashSet<String>();
propertiesList.add("prop1");
propertiesList.add("prop2");
RepositoryFileDto repositoryFileDto = mock(RepositoryFileDto.class);
doReturn(fileId).when(repositoryFileDto).getId();
doReturn(repositoryFileDto).when(fileService.defaultUnifiedRepositoryWebService).getFile(nullable(String.class));
Properties properties = mock(Properties.class);
doReturn("value1").when(properties).getProperty("prop1");
doReturn("value2").when(properties).getProperty("prop2");
doReturn(false).when(properties).isEmpty();
doReturn(propertiesList).when(properties).stringPropertyNames();
PropertiesWrapper propertiesWrapper = mock(PropertiesWrapper.class);
when(propertiesWrapper.getProperties()).thenReturn(properties);
doReturn(propertiesWrapper).when(fileService.defaultUnifiedRepositoryWebService).getLocalePropertiesForFileById(nullable(String.class), nullable(String.class));
List<StringKeyStringValueDto> keyValueList = fileService.doGetLocaleProperties(pathId, locale);
verify(fileService.defaultUnifiedRepositoryWebService).getFile("/path/to/file/file1.ext");
verify(properties).getProperty("prop1");
verify(properties).getProperty("prop2");
verify(properties).isEmpty();
verify(properties).stringPropertyNames();
verify(fileService.defaultUnifiedRepositoryWebService).getLocalePropertiesForFileById(nullable(String.class), nullable(String.class));
assertEquals(2, keyValueList.size());
assertEquals("prop1", keyValueList.get(1).getKey());
assertEquals("prop2", keyValueList.get(0).getKey());
assertEquals("value1", keyValueList.get(1).getValue());
assertEquals("value2", keyValueList.get(0).getValue());
}
Aggregations