use of org.pentaho.platform.web.http.api.resources.SessionResource in project pentaho-platform by pentaho.
the class FileServiceTest method testSearchGeneratedContentFileNotFound.
@Test
public void testSearchGeneratedContentFileNotFound() {
String lineageId = "test.prpt", pathId = "test.prpt", userFolder = "public/admin";
SessionResource sessionResource = mock(SessionResource.class);
doReturn(userFolder).when(sessionResource).doGetCurrentUserDir();
doReturn(sessionResource).when(fileService).getSessionResource();
try {
doReturn(null).when(fileService).doGetProperties(pathId);
fileService.searchGeneratedContent(userFolder, lineageId, QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID);
fail();
} catch (FileNotFoundException e) {
}
}
use of org.pentaho.platform.web.http.api.resources.SessionResource in project pentaho-platform by pentaho.
the class FileServiceTest method testDoGetGeneratedContentFileNotFound.
@Test
public void testDoGetGeneratedContentFileNotFound() {
String pathId = "test.prpt", userFolder = "public/admin";
SessionResource sessionResource = mock(SessionResource.class);
doReturn(userFolder).when(sessionResource).doGetCurrentUserDir();
doReturn(sessionResource).when(fileService).getSessionResource();
try {
doReturn(null).when(fileService).doGetProperties(pathId);
fileService.doGetGeneratedContent(pathId);
fail();
} catch (FileNotFoundException e) {
}
}
use of org.pentaho.platform.web.http.api.resources.SessionResource in project pentaho-platform by pentaho.
the class FileServiceTest method testDoGetGeneratedContentForUserFileNotFound.
@Test
public void testDoGetGeneratedContentForUserFileNotFound() {
String pathId = "test.prpt", user = "admin", userFolder = "public/admin";
SessionResource sessionResource = mock(SessionResource.class);
doReturn(userFolder).when(sessionResource).doGetUserDir(user);
doReturn(sessionResource).when(fileService).getSessionResource();
try {
doReturn(null).when(fileService).doGetProperties(pathId);
fileService.doGetGeneratedContent(pathId, user);
fail();
} catch (FileNotFoundException e) {
}
}
use of org.pentaho.platform.web.http.api.resources.SessionResource in project pentaho-platform by pentaho.
the class FileServiceTest method testSearchGeneratedContent.
@Test
public void testSearchGeneratedContent() {
String lineageId = "test.prpt", pathId = "test.prpt", 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(lineageId).when(mockedFileMetadata).get(QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID);
when(fileService.repository.getFileMetadata(mockedChild.getId())).thenReturn(mockedFileMetadata);
doReturn(pathId).when(fileDetailsMock).getId();
doReturn(userFolder).when(sessionResource).doGetCurrentUserDir();
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.searchGeneratedContent(userFolder, lineageId, QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID);
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 FileServiceTest method testDoGetGeneratedContent.
@Test
public void testDoGetGeneratedContent() {
String pathId = "test.prpt", 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).doGetCurrentUserDir();
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);
assertEquals(list.size(), 1);
} catch (FileNotFoundException e) {
e.printStackTrace();
fail();
} catch (Throwable t) {
fail();
}
}
Aggregations