use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetGeneratedContentForUserError.
@Test
public void testDoGetGeneratedContentForUserError() throws Exception {
String user = "user";
Exception mockFileNotFoundException = mock(FileNotFoundException.class);
doThrow(mockFileNotFoundException).when(fileResource.fileService).doGetGeneratedContent(PATH_ID, user);
Messages mockMessages = mock(Messages.class);
doReturn(mockMessages).when(fileResource).getMessagesInstance();
// Test 1
List<RepositoryFileDto> testList = fileResource.doGetGeneratedContentForUser(PATH_ID, user);
assertEquals(0, testList.size());
// Test 2
Throwable mockThrowable = mock(RuntimeException.class);
doThrow(mockThrowable).when(fileResource.fileService).doGetGeneratedContent(PATH_ID, user);
testList = fileResource.doGetGeneratedContentForUser(PATH_ID, user);
assertEquals(0, testList.size());
verify(fileResource.fileService, times(2)).doGetGeneratedContent(PATH_ID, user);
verify(fileResource, times(1)).getMessagesInstance();
verify(mockMessages, times(1)).getString("FileResource.GENERATED_CONTENT_FOR_USER_FAILED", PATH_ID, user);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceTest method testSetContentCreatorError.
@Test
public void testSetContentCreatorError() throws Exception {
RepositoryFileDto mockRepositoryFileDto = mock(RepositoryFileDto.class);
Response mockNotFoundResponse = mock(Response.class);
doReturn(mockNotFoundResponse).when(fileResource).buildStatusResponse(Response.Status.NOT_FOUND);
Response mockInternalServerErrorResponse = mock(Response.class);
doReturn(mockInternalServerErrorResponse).when(fileResource).buildStatusResponse(Response.Status.INTERNAL_SERVER_ERROR);
Messages mockMessages = mock(Messages.class);
doReturn(mockMessages).when(fileResource).getMessagesInstance();
// Test 1
Exception mockFileNotFoundException = mock(FileNotFoundException.class);
doThrow(mockFileNotFoundException).when(fileResource.fileService).doSetContentCreator(PATH_ID, mockRepositoryFileDto);
Response testResponse = fileResource.doSetContentCreator(PATH_ID, mockRepositoryFileDto);
assertEquals(mockNotFoundResponse, testResponse);
// Test 2
Throwable mockThrowable = mock(RuntimeException.class);
doThrow(mockThrowable).when(fileResource.fileService).doSetContentCreator(PATH_ID, mockRepositoryFileDto);
testResponse = fileResource.doSetContentCreator(PATH_ID, mockRepositoryFileDto);
assertEquals(mockInternalServerErrorResponse, testResponse);
verify(fileResource, times(1)).buildStatusResponse(Response.Status.NOT_FOUND);
verify(fileResource, times(1)).buildStatusResponse(Response.Status.INTERNAL_SERVER_ERROR);
verify(fileResource.fileService, times(2)).doSetContentCreator(PATH_ID, mockRepositoryFileDto);
verify(mockMessages, times(1)).getErrorString("FileResource.FILE_NOT_FOUND", PATH_ID);
verify(mockMessages, times(1)).getString("SystemResource.GENERAL_ERROR");
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetContentCreatorError.
@Test
public void testDoGetContentCreatorError() throws Exception {
Throwable mockThrowable = mock(RuntimeException.class);
doThrow(mockThrowable).when(fileResource.fileService).doGetContentCreator(PATH_ID);
RepositoryFileDto testDto = fileResource.doGetContentCreator(PATH_ID);
assertNull(testDto);
verify(fileResource.fileService, times(1)).doGetContentCreator(PATH_ID);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetPropertiesError.
@Test
public void testDoGetPropertiesError() throws Exception {
Exception mockFileNotFoundException = mock(FileNotFoundException.class);
doThrow(mockFileNotFoundException).when(fileResource.fileService).doGetProperties(PATH_ID);
Messages mockMessages = mock(Messages.class);
doReturn(mockMessages).when(fileResource).getMessagesInstance();
RepositoryFileDto testDto = fileResource.doGetProperties(PATH_ID);
assertNull(testDto);
verify(fileResource.fileService, times(1)).doGetProperties(PATH_ID);
verify(fileResource, times(1)).getMessagesInstance();
verify(mockMessages, times(1)).getString("SystemResource.GENERAL_ERROR");
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetContentCreator.
@Test
public void testDoGetContentCreator() throws Exception {
RepositoryFileDto mockRepositoryFileDto = mock(RepositoryFileDto.class);
doReturn(mockRepositoryFileDto).when(fileResource.fileService).doGetContentCreator(PATH_ID);
RepositoryFileDto testDto = fileResource.doGetContentCreator(PATH_ID);
assertEquals(mockRepositoryFileDto, testDto);
verify(fileResource.fileService, times(1)).doGetContentCreator(PATH_ID);
}
Aggregations