Search in sources :

Example 16 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pdi-dataservice-server-plugin by pentaho.

the class TransDataServletTest method testDoGetException.

@Test
public void testDoGetException() throws Exception {
    when(factory.createBuilder(any(SQL.class))).thenThrow(new MetaStoreException("expected"));
    headers.put(HEADER_SQL, TEST_SQL_QUERY);
    servlet.service(request, response);
    verify(response).sendError(HttpServletResponse.SC_BAD_REQUEST);
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 17 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceMetaStoreUtilTest method testCheckConflict.

@Test
public void testCheckConflict() throws Exception {
    final ServiceTrans published = mock(ServiceTrans.class);
    when(published.getName()).thenReturn("PUBLISHED_SERVICE");
    metaStoreUtil = new DataServiceMetaStoreUtil(metaStoreUtil) {

        @Override
        protected MetaStoreFactory<ServiceTrans> getServiceTransFactory(IMetaStore metaStore) {
            return new MetaStoreFactory<ServiceTrans>(ServiceTrans.class, metaStore, NAMESPACE) {

                @Override
                public List<ServiceTrans> getElements() throws MetaStoreException {
                    return ImmutableList.of(published);
                }
            };
        }
    };
    DataServiceMeta local = createDataService("OTHER_SERVICE", transMeta);
    local.setStepname("OTHER_STEP");
    metaStoreUtil.getDataServiceFactory(transMeta).saveElement(local);
    // New data service with different properties
    metaStoreUtil.checkConflict(dataService, null);
    // Editing a data service with all new properties
    metaStoreUtil.checkConflict(dataService, local.getName());
    try {
        // New data service with the same name as an local data service
        dataService.setName(local.getName());
        metaStoreUtil.checkConflict(dataService, null);
        fail("Expected DataServiceAlreadyExistsException");
    } catch (DataServiceAlreadyExistsException e) {
        assertThat(e.getDataServiceMeta(), sameInstance(dataService));
    }
    // Editing a data service, no name change
    metaStoreUtil.checkConflict(dataService, local.getName());
    dataService = createDataService(DATA_SERVICE_NAME, transMeta);
    metaStoreUtil.checkConflict(dataService, null);
    try {
        // New data service with conflicting output step
        dataService.setStepname(local.getStepname());
        metaStoreUtil.checkConflict(dataService, null);
        fail("Expected DataServiceAlreadyExistsException");
    } catch (DataServiceAlreadyExistsException e) {
        assertThat(e.getDataServiceMeta(), sameInstance(dataService));
    }
    // Editing data service with same output step
    metaStoreUtil.checkConflict(dataService, local.getName());
    dataService = createDataService(DATA_SERVICE_NAME, transMeta);
    metaStoreUtil.checkConflict(dataService, null);
    dataService.setName(published.getName());
    when(published.getReferences()).thenReturn(ImmutableList.<ServiceTrans.Reference>of());
    metaStoreUtil.checkConflict(dataService, null);
    ServiceTrans.Reference reference = mock(ServiceTrans.Reference.class);
    when(reference.exists(repository)).thenReturn(false, true);
    when(published.getReferences()).thenReturn(ImmutableList.of(reference));
    metaStoreUtil.checkConflict(dataService, null);
    try {
        // New Data service with conflicting name in metastore
        metaStoreUtil.checkConflict(dataService, null);
        fail("Expected DataServiceAlreadyExistsException");
    } catch (DataServiceAlreadyExistsException e) {
        assertThat(e.getDataServiceMeta(), sameInstance(dataService));
    }
    try {
        // Editing Data service with conflicting name in metastore
        metaStoreUtil.checkConflict(dataService, local.getName());
        fail("Expected DataServiceAlreadyExistsException");
    } catch (DataServiceAlreadyExistsException e) {
        assertThat(e.getDataServiceMeta(), sameInstance(dataService));
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreFactory(org.pentaho.metastore.persist.MetaStoreFactory) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test) BaseTest(org.pentaho.di.trans.dataservice.BaseTest)

Example 18 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pdi-dataservice-server-plugin by pentaho.

the class SynchronizationListenerTest method testNoPrompt.

@Test
public void testNoPrompt() throws Exception {
    service.contentSafe(transMeta);
    service.setPrompt(false);
    verify(synchronizer).sync(same(transMeta), errorHandler.capture());
    verify(delegate, never()).showPrompt(anyString(), anyString());
    verify(delegate, never()).removeDataService(dataServiceMeta);
    verify(delegate, never()).suggestEdit(same(dataServiceMeta), anyString(), anyString());
    MetaStoreException metaStoreException = new MetaStoreException();
    errorHandler.getValue().apply(metaStoreException);
    verify(logChannel).logError(anyString(), same(metaStoreException));
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) Test(org.junit.Test)

Example 19 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pdi-dataservice-server-plugin by pentaho.

the class SynchronizationListenerTest method testContentSafe.

@Test
public void testContentSafe() throws Exception {
    service.contentSafe(transMeta);
    verify(synchronizer).sync(same(transMeta), errorHandler.capture());
    UndefinedDataServiceException undefinedException = new UndefinedDataServiceException(dataServiceMeta);
    when(delegate.showPrompt(anyString(), anyString())).thenReturn(false, true);
    errorHandler.getValue().apply(undefinedException);
    verify(delegate, never()).removeDataService(dataServiceMeta, false);
    errorHandler.getValue().apply(undefinedException);
    verify(delegate).removeDataService(dataServiceMeta);
    verify(logChannel, times(2)).logError(anyString(), same(undefinedException));
    DataServiceAlreadyExistsException conflictException = new DataServiceAlreadyExistsException(dataServiceMeta);
    errorHandler.getValue().apply(conflictException);
    verify(delegate).suggestEdit(same(dataServiceMeta), anyString(), anyString());
    verify(logChannel).logError(anyString(), same(conflictException));
    MetaStoreException metaStoreException = new MetaStoreException();
    errorHandler.getValue().apply(metaStoreException);
    verify(logChannel).logError(anyString(), same(metaStoreException));
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) Test(org.junit.Test)

Example 20 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.

the class NamedClusterEmbedManager method clear.

/**
 * Clear the embedded metastore of any named clusters
 */
public void clear() {
    NamedClusterServiceOsgi ncso = meta.getNamedClusterServiceOsgi();
    if (ncso != null) {
        // Don't kill the embedded if we don't have the service to rebuild
        addedAllClusters = false;
        addedAnyClusters = false;
        // saved.
        if (embeddedMetaStoreFactory != null) {
            try {
                List<NamedClusterOsgi> list = embeddedMetaStoreFactory.getElements();
                for (NamedClusterOsgi nc : list) {
                    namedClusterPool.put(nc.getName(), nc);
                    embeddedMetaStoreFactory.deleteElement(nc.getName());
                }
            } catch (MetaStoreException e) {
                logMetaStoreException(e);
            }
        }
    }
}
Also used : NamedClusterOsgi(org.pentaho.di.core.osgi.api.NamedClusterOsgi) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) NamedClusterServiceOsgi(org.pentaho.di.core.osgi.api.NamedClusterServiceOsgi)

Aggregations

MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)43 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)18 MetaStoreElementTypeExistsException (org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)18 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)17 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)17 LongObjectId (org.pentaho.di.repository.LongObjectId)12 IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)11 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)9 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)8 StringObjectId (org.pentaho.di.repository.StringObjectId)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 ObjectId (org.pentaho.di.repository.ObjectId)5 IMetaStore (org.pentaho.metastore.api.IMetaStore)5 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)4 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)4 List (java.util.List)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)2 NamedClusterOsgi (org.pentaho.di.core.osgi.api.NamedClusterOsgi)2