use of org.pentaho.agilebi.modeler.ModelerWorkspace in project data-access by pentaho.
the class DataSourceWizardServiceTest method testRemoveDswById.
public void testRemoveDswById(String dswId) throws Exception {
Domain mockDomain = mock(Domain.class);
IPentahoSession mockIPentahoSession = mock(IPentahoSession.class);
ModelerWorkspace mockModelerWorkspace = mock(ModelerWorkspace.class);
LogicalModel mockLogicalModel = mock(LogicalModel.class);
String mockObject = "not null";
doNothing().when(dataSourceWizardService).ensureDataAccessPermissionCheck();
doReturn(dswId).when(dataSourceWizardService).parseMondrianSchemaNameWrapper(dswId);
doReturn(mockDomain).when(dataSourceWizardService.metadataDomainRepository).getDomain(dswId);
doReturn(mockModelerWorkspace).when(dataSourceWizardService).createModelerWorkspace();
doReturn(null).when(mockModelerWorkspace).getLogicalModel(ModelerPerspective.ANALYSIS);
doReturn(mockLogicalModel).when(mockModelerWorkspace).getLogicalModel(ModelerPerspective.REPORTING);
doReturn(mockObject).when(mockLogicalModel).getProperty("MondrianCatalogRef");
doReturn(mockIPentahoSession).when(dataSourceWizardService).getSession();
doNothing().when(dataSourceWizardService.mondrianCatalogService).removeCatalog("not null", mockIPentahoSession);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
returnedDswId = (String) args[0];
return null;
}
}).when(dataSourceWizardService.metadataDomainRepository).removeDomain(dswId);
dataSourceWizardService.removeDSW(dswId);
assertEquals("The method should call removal for original id", dswId, returnedDswId);
verify(dataSourceWizardService, times(1)).removeDSW(dswId);
}
use of org.pentaho.agilebi.modeler.ModelerWorkspace in project data-access by pentaho.
the class DataSourceWizardServiceTest method testDoGetDSWFilesAsDownload.
@Test
public void testDoGetDSWFilesAsDownload() throws Exception {
Map<String, InputStream> mockFileData = mock(Map.class);
ModelerWorkspace mockModelerWorkspace = mock(ModelerWorkspace.class);
MondrianCatalogRepositoryHelper mockMondrianCatalogRepositoryHelper = mock(MondrianCatalogRepositoryHelper.class);
LogicalModel mockLogicalModel = mock(LogicalModel.class);
String mockObject = "not null";
String dswId = "dswId";
doReturn(true).when(dataSourceWizardService).canManageACL();
doReturn(mockFileData).when(dataSourceWizardService).getMetadataFiles(dswId);
doReturn(mockModelerWorkspace).when(dataSourceWizardService).createModelerWorkspace();
doReturn(null).when(mockModelerWorkspace).getLogicalModel(ModelerPerspective.ANALYSIS);
doReturn(mockLogicalModel).when(mockModelerWorkspace).getLogicalModel(ModelerPerspective.REPORTING);
doReturn(mockObject).when(mockLogicalModel).getProperty("MondrianCatalogRef");
doReturn(mockMondrianCatalogRepositoryHelper).when(dataSourceWizardService).createMondrianCatalogRepositoryHelper();
doNothing().when(dataSourceWizardService).parseMondrianSchemaNameWrapper(dswId, mockFileData);
Map<String, InputStream> response = dataSourceWizardService.doGetDSWFilesAsDownload("dswId");
assertEquals(mockFileData, response);
verify(dataSourceWizardService, times(1)).doGetDSWFilesAsDownload("dswId");
}
use of org.pentaho.agilebi.modeler.ModelerWorkspace in project data-access by pentaho.
the class DataSourceWizardServiceTest method testDoGetDSWFilesAsDownloadError.
@Test
public void testDoGetDSWFilesAsDownloadError() throws Exception {
Map<String, InputStream> mockFileData = mock(Map.class);
ModelerWorkspace mockModelerWorkspace = mock(ModelerWorkspace.class);
String dswId = "dswId";
// Test 1
doReturn(false).when(dataSourceWizardService).canManageACL();
try {
Map<String, InputStream> response = dataSourceWizardService.doGetDSWFilesAsDownload("dswId");
fail();
} catch (PentahoAccessControlException pace) {
// expected
}
verify(dataSourceWizardService, times(1)).doGetDSWFilesAsDownload("dswId");
}
use of org.pentaho.agilebi.modeler.ModelerWorkspace in project data-access by pentaho.
the class DataSourceWizardServiceTest method testErrorRemovingMondrianDoesNotStopXMIRemoval.
@Test
public void testErrorRemovingMondrianDoesNotStopXMIRemoval() throws Exception {
Domain mockDomain = mock(Domain.class);
IPentahoSession mockIPentahoSession = mock(IPentahoSession.class);
ModelerWorkspace mockModelerWorkspace = mock(ModelerWorkspace.class);
LogicalModel mockLogicalModel = mock(LogicalModel.class);
String mockObject = "not null";
String dswId = "dswId";
doNothing().when(dataSourceWizardService).ensureDataAccessPermissionCheck();
doReturn(dswId).when(dataSourceWizardService).parseMondrianSchemaNameWrapper(dswId);
doReturn(mockDomain).when(dataSourceWizardService.metadataDomainRepository).getDomain(dswId);
doReturn(mockModelerWorkspace).when(dataSourceWizardService).createModelerWorkspace();
doReturn(null).when(mockModelerWorkspace).getLogicalModel(ModelerPerspective.ANALYSIS);
doReturn(mockLogicalModel).when(mockModelerWorkspace).getLogicalModel(ModelerPerspective.REPORTING);
doReturn(mockObject).when(mockLogicalModel).getProperty("MondrianCatalogRef");
doReturn(mockIPentahoSession).when(dataSourceWizardService).getSession();
doThrow(new MondrianCatalogServiceException("who cares")).when(dataSourceWizardService.mondrianCatalogService).removeCatalog("not null", mockIPentahoSession);
doNothing().when(dataSourceWizardService.metadataDomainRepository).removeDomain(dswId);
dataSourceWizardService.removeDSW("dswId");
verify(dataSourceWizardService, times(1)).removeDSW("dswId");
verify(dataSourceWizardService.metadataDomainRepository).removeDomain(dswId);
}
use of org.pentaho.agilebi.modeler.ModelerWorkspace in project data-access by pentaho.
the class DataSourceWizardServiceTest method testRemoveDSWError.
@Test
public void testRemoveDSWError() throws Exception {
Domain mockDomain = mock(Domain.class);
IPentahoSession mockIPentahoSession = mock(IPentahoSession.class);
ModelerWorkspace mockModelerWorkspace = mock(ModelerWorkspace.class);
LogicalModel mockLogicalModel = mock(LogicalModel.class);
String mockObject = "not null";
String dswId = "dswId";
// Test 1
ConnectionServiceException cse = new ConnectionServiceException();
doThrow(cse).when(dataSourceWizardService).ensureDataAccessPermissionCheck();
try {
dataSourceWizardService.removeDSW("dswId");
fail();
} catch (PentahoAccessControlException pace) {
// expected
}
// Test 2
DatasourceServiceException mockDatasourceServiceException = mock(DatasourceServiceException.class);
doNothing().when(dataSourceWizardService).ensureDataAccessPermissionCheck();
doReturn(dswId).when(dataSourceWizardService).parseMondrianSchemaNameWrapper(dswId);
doReturn(mockDomain).when(dataSourceWizardService.metadataDomainRepository).getDomain(dswId);
doReturn(mockModelerWorkspace).when(dataSourceWizardService).createModelerWorkspace();
doReturn(null).when(mockModelerWorkspace).getLogicalModel(ModelerPerspective.ANALYSIS);
doReturn(mockLogicalModel).when(mockModelerWorkspace).getLogicalModel(ModelerPerspective.REPORTING);
doReturn(mockObject).when(mockLogicalModel).getProperty("MondrianCatalogRef");
doReturn(mockIPentahoSession).when(dataSourceWizardService).getSession();
doNothing().when(dataSourceWizardService.mondrianCatalogService).removeCatalog("not null", mockIPentahoSession);
doThrow(mockDatasourceServiceException).when(dataSourceWizardService.dswService).deleteLogicalModel(null, null);
dataSourceWizardService.removeDSW("dswId");
verify(dataSourceWizardService, times(2)).removeDSW("dswId");
}
Aggregations