Search in sources :

Example 41 with MetaStoreException

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

the class AnnotationsQueryServiceTest method testLogsExceptionOnWriteEror.

@Test
public void testLogsExceptionOnWriteEror() throws Exception {
    final DataServiceDelegate dataServiceFactory = mock(DataServiceDelegate.class);
    final DataServiceContext dataServiceContext = mock(DataServiceContext.class);
    final DataServiceResolver dataServiceResolver = mock(DataServiceResolver.class);
    final MetastoreLocator metastoreLocator = mock(MetastoreLocator.class);
    when(dataServiceContext.getDataServiceDelegate()).thenReturn(dataServiceFactory);
    when(metastoreLocator.getMetastore()).thenReturn(null);
    final AnnotationsQueryService queryService = new AnnotationsQueryService(metastoreLocator, dataServiceResolver);
    Query query = queryService.prepareQuery("show annotations from annotatedService", 0, Collections.<String, String>emptyMap());
    MetaStoreException metaStoreException = new MetaStoreException("Unable to load dataservice annotatedService");
    when(dataServiceResolver.getDataService("annotatedService")).thenReturn(null);
    try {
        query.writeTo(new ByteArrayOutputStream());
        fail("should have got exception");
    } catch (IOException e) {
        assertEquals("Error while executing 'show annotations from annotatedService'", e.getMessage());
    }
}
Also used : DataServiceContext(org.pentaho.di.trans.dataservice.DataServiceContext) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) DataServiceDelegate(org.pentaho.di.trans.dataservice.ui.DataServiceDelegate) DataServiceResolver(org.pentaho.di.trans.dataservice.resolvers.DataServiceResolver) MetastoreLocator(org.pentaho.osgi.metastore.locator.api.MetastoreLocator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Test(org.junit.Test)

Example 42 with MetaStoreException

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

the class SynchronizationListener method onStepChange.

@Override
public void onStepChange(TransMeta transMeta, StepMeta oldMeta, StepMeta newMeta) {
    if (Objects.equal(oldMeta.getName(), newMeta.getName())) {
        return;
    }
    try {
        DataServiceMeta dataService = delegate.getDataServiceByStepName(transMeta, oldMeta.getName());
        if (dataService != null) {
            dataService.setStepname(newMeta.getName());
            delegate.save(dataService);
        }
    } catch (MetaStoreException e) {
        delegate.getLogChannel().logError(e.getMessage(), e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta)

Example 43 with MetaStoreException

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

the class DataServiceDialogControllerTest method testError.

@Test
public void testError() throws Exception {
    UndefinedDataServiceException undefinedException = new UndefinedDataServiceException(dataServiceMeta);
    doThrow(undefinedException).doReturn(dataServiceMeta).when(delegate).checkDefined(dataServiceMeta);
    DataServiceAlreadyExistsException alreadyExistsException = new DataServiceAlreadyExistsException(dataServiceMeta);
    doThrow(alreadyExistsException).doReturn(dataServiceMeta).when(delegate).checkConflict(dataServiceMeta, null);
    MetaStoreException metaStoreException = new MetaStoreException();
    doThrow(metaStoreException).doNothing().when(delegate).save(dataServiceMeta);
    controller.saveAndClose();
    verify(messageBox).setMessage(undefinedException.getMessage());
    controller.saveAndClose();
    verify(messageBox).setMessage(alreadyExistsException.getMessage());
    verify(delegate, never()).save(any(DataServiceMeta.class));
    controller.saveAndClose();
    verify(messageBox, times(3)).open();
    verify(logChannel).logError(anyString(), same(metaStoreException));
    verify(dialog, never()).dispose();
    controller.saveAndClose();
    verify(dialog).dispose();
    verifyNoMoreInteractions(logChannel);
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UndefinedDataServiceException(org.pentaho.di.trans.dataservice.serialization.UndefinedDataServiceException) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) DataServiceAlreadyExistsException(org.pentaho.di.trans.dataservice.serialization.DataServiceAlreadyExistsException) Test(org.junit.Test)

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