use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetProperties.
@Test
public void testDoGetProperties() throws Exception {
RepositoryFileDto mockRepositoryFileDto = mock(RepositoryFileDto.class);
doReturn(mockRepositoryFileDto).when(fileResource.fileService).doGetProperties(PATH_ID);
RepositoryFileDto testDto = fileResource.doGetProperties(PATH_ID);
assertEquals(mockRepositoryFileDto, testDto);
verify(fileResource.fileService, times(1)).doGetProperties(PATH_ID);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetGeneratedContentError.
@Test
public void testDoGetGeneratedContentError() throws Exception {
Exception mockFileNotFoundException = mock(FileNotFoundException.class);
doThrow(mockFileNotFoundException).when(fileResource.fileService).doGetGeneratedContent(PATH_ID);
Messages mockMessages = mock(Messages.class);
doReturn(mockMessages).when(fileResource).getMessagesInstance();
// Test 1
List<RepositoryFileDto> testList = fileResource.doGetGeneratedContent(PATH_ID);
assertEquals(0, testList.size());
// Test 2
Throwable mockThrowable = mock(RuntimeException.class);
doThrow(mockThrowable).when(fileResource.fileService).doGetGeneratedContent(PATH_ID);
testList = fileResource.doGetGeneratedContent(PATH_ID);
assertEquals(0, testList.size());
verify(fileResource.fileService, times(2)).doGetGeneratedContent(PATH_ID);
verify(fileResource, times(1)).getMessagesInstance();
verify(mockMessages, times(1)).getString("FileResource.GENERATED_CONTENT_FAILED", PATH_ID);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testDoGetGeneratedContentForSchedule.
@Test
public void testDoGetGeneratedContentForSchedule() throws Exception {
String lineageId = "test.prpt";
FileService mockFileService = mock(FileService.class);
doReturn(mockFileService).when(schedulerService).getFileService();
SessionResource mockSessionResource = mock(SessionResource.class);
doReturn(mockSessionResource).when(schedulerService).getSessionResource();
String currentUserDir = "currentUserDir";
doReturn(currentUserDir).when(mockSessionResource).doGetCurrentUserDir();
List<RepositoryFileDto> mockList = mock(List.class);
doReturn(mockList).when(mockFileService).searchGeneratedContent(currentUserDir, lineageId, QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID);
List<RepositoryFileDto> list = schedulerService.doGetGeneratedContentForSchedule(lineageId);
assertEquals(mockList, list);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class UnifiedRepositoryToWebServiceAdapter method getDataForReadInBatch.
@Override
@SuppressWarnings("unchecked")
public <T extends IRepositoryFileData> java.util.List<T> getDataForReadInBatch(final List<RepositoryFile> files, final Class<T> dataClass) {
List<RepositoryFileDto> fileDtos = new ArrayList<RepositoryFileDto>(files.size());
for (RepositoryFile file : files) {
fileDtos.add(repositoryFileAdapter.marshal(file));
}
if (dataClass.equals(NodeRepositoryFileData.class)) {
List<NodeRepositoryFileDataDto> nodeData = repoWebService.getDataAsNodeForReadInBatch(fileDtos);
List<T> data = new ArrayList<T>(nodeData.size());
for (NodeRepositoryFileDataDto node : nodeData) {
data.add((T) nodeRepositoryFileDataAdapter.unmarshal(node));
}
return data;
} else if (dataClass.equals(SimpleRepositoryFileData.class)) {
List<SimpleRepositoryFileDataDto> nodeData = repoWebService.getDataAsBinaryForReadInBatch(fileDtos);
List<T> data = new ArrayList<T>(nodeData.size());
for (SimpleRepositoryFileDataDto node : nodeData) {
data.add((T) SimpleRepositoryFileDataDto.convert(node));
}
return data;
} else {
throw new IllegalArgumentException();
}
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class RepositoryFileUtils method convertFromRepositoryFileTree.
public static RepositoryFileTreeDto convertFromRepositoryFileTree(RepositoryFileTree tree) {
RepositoryFileTreeDto fileTreeDto = new RepositoryFileTreeDto();
List<RepositoryFileTreeDto> fileList = new ArrayList<RepositoryFileTreeDto>();
RepositoryFileDto file = convertFromRepositoryFile(tree.getFile());
fileTreeDto.setFile(file);
for (RepositoryFileTree treeItem : tree.getChildren()) {
fileList.add(convertFromRepositoryFileTree(treeItem));
}
fileTreeDto.setChildren(fileList);
return fileTreeDto;
}
Aggregations