use of org.pentaho.platform.web.http.api.resources.SessionResource in project pentaho-platform by pentaho.
the class FileServiceTest method testDoGetGeneratedContentForUser.
@Test
public void testDoGetGeneratedContentForUser() {
String pathId = "test.prpt", user = "admin", userFolder = "public/admin";
RepositoryFileDto fileDetailsMock = mock(RepositoryFileDto.class);
RepositoryFile workspaceFolder = mock(RepositoryFile.class);
doReturn(userFolder).when(workspaceFolder).getId();
SessionResource sessionResource = mock(SessionResource.class);
List<RepositoryFile> children = new ArrayList<RepositoryFile>();
RepositoryFile mockedChild = mock(RepositoryFile.class);
doReturn(false).when(mockedChild).isFolder();
children.add(mockedChild);
Map<String, Serializable> mockedFileMetadata = mock(Map.class);
doReturn(pathId).when(mockedFileMetadata).get(PentahoJcrConstants.PHO_CONTENTCREATOR);
when(fileService.repository.getFileMetadata(mockedChild.getId())).thenReturn(mockedFileMetadata);
doReturn(pathId).when(fileDetailsMock).getId();
doReturn(userFolder).when(sessionResource).doGetUserDir(user);
doReturn(workspaceFolder).when(fileService.repository).getFile(userFolder);
doReturn(sessionResource).when(fileService).getSessionResource();
doReturn(children).when(fileService.repository).getChildren(userFolder);
RepositoryFileDto mockedRepositoryFileDto = mock(RepositoryFileDto.class);
doReturn(mockedRepositoryFileDto).when(fileService).toFileDto(mockedChild, null, false);
try {
doReturn(fileDetailsMock).when(fileService).doGetProperties(pathId);
List<RepositoryFileDto> list = fileService.doGetGeneratedContent(pathId, user);
assertEquals(list.size(), 1);
} catch (FileNotFoundException e) {
e.printStackTrace();
fail();
} catch (Throwable t) {
fail();
}
}
use of org.pentaho.platform.web.http.api.resources.SessionResource 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);
}
Aggregations