Search in sources :

Example 46 with PentahoAccessControlException

use of org.pentaho.platform.api.engine.PentahoAccessControlException in project data-access by pentaho.

the class AnalysisResourceTest method testdeleteSchemaError.

@Test
public void testdeleteSchemaError() throws Exception {
    Response mockResponse = mock(Response.class);
    // Test 1
    PentahoAccessControlException mockException = mock(PentahoAccessControlException.class);
    doThrow(mockException).when(analysisResource.service).removeAnalysis("analysisId");
    try {
        Response response = analysisResource.deleteSchema("analysisId");
        fail("should have gotten a WebApplicationException");
    } catch (WebApplicationException e) {
    // Good
    }
    verify(analysisResource, times(1)).deleteSchema("analysisId");
}
Also used : Response(javax.ws.rs.core.Response) WebApplicationException(javax.ws.rs.WebApplicationException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) Test(org.junit.Test)

Example 47 with PentahoAccessControlException

use of org.pentaho.platform.api.engine.PentahoAccessControlException in project data-access by pentaho.

the class AnalysisResourceTest method testDoGetAnalysisFilesAsDownloadError.

@Test
public void testDoGetAnalysisFilesAsDownloadError() throws Exception {
    // Test 1
    PentahoAccessControlException mockException = mock(PentahoAccessControlException.class);
    RepositoryException repositoryException = mock(RepositoryException.class);
    doThrow(mockException).doThrow(repositoryException).when(analysisResource.service).doGetAnalysisFilesAsDownload("analysisId");
    try {
        Response response = analysisResource.downloadSchema("analysisId");
        fail("Should have gotten a WebApplicationException");
    } catch (WebApplicationException e) {
    // Good
    }
    try {
        Response response = analysisResource.downloadSchema("analysisId");
        fail("Should have gotten a WebApplicationException");
    } catch (WebApplicationException e) {
    // Good
    }
    verify(analysisResource, times(2)).downloadSchema("analysisId");
}
Also used : Response(javax.ws.rs.core.Response) WebApplicationException(javax.ws.rs.WebApplicationException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) Test(org.junit.Test)

Example 48 with PentahoAccessControlException

use of org.pentaho.platform.api.engine.PentahoAccessControlException in project data-access by pentaho.

the class DataSourceWizardResourceTest method testDownloadError.

@Test
public void testDownloadError() throws Exception {
    Response mockResponse = mock(Response.class);
    // Test 1
    PentahoAccessControlException mockPentahoAccessControlException = mock(PentahoAccessControlException.class);
    doThrow(mockPentahoAccessControlException).when(dataSourceWizardResource.service).doGetDSWFilesAsDownload("dswId");
    doReturn(mockResponse).when(dataSourceWizardResource).buildUnauthorizedResponse();
    Response response = dataSourceWizardResource.downloadDsw("dswId");
    assertEquals(mockResponse, response);
    verify(dataSourceWizardResource, times(1)).downloadDsw("dswId");
}
Also used : Response(javax.ws.rs.core.Response) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) Test(org.junit.Test)

Aggregations

PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)48 Test (org.junit.Test)28 InputStream (java.io.InputStream)13 Response (javax.ws.rs.core.Response)13 FileNotFoundException (java.io.FileNotFoundException)10 WebApplicationException (javax.ws.rs.WebApplicationException)10 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)6 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)6 PlatformInitializationException (org.pentaho.platform.engine.core.system.boot.PlatformInitializationException)6 PlatformImportException (org.pentaho.platform.plugin.services.importer.PlatformImportException)6 DataAccessException (org.springframework.dao.DataAccessException)6 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)6 Domain (org.pentaho.metadata.model.Domain)5 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)5 FileInputStream (java.io.FileInputStream)4 Consumes (javax.ws.rs.Consumes)4 Facet (org.codehaus.enunciate.Facet)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ModelerWorkspace (org.pentaho.agilebi.modeler.ModelerWorkspace)4 FormDataContentDisposition (com.sun.jersey.core.header.FormDataContentDisposition)3