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());
}
}
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);
}
}
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);
}
Aggregations